when use eda(display_format = 'bokeh') from pycaret with jupyterlab ,the bokeh plot cannot change by selecting different var - jupyter-lab

when use eda(display_format = 'bokeh') from pycaret with jupyterlab ,the bokeh plot cannot change by selecting different var.But it run smoothly in notebook.the plot like this

AutoViz is an optional dependency in pycaret and hence, this issue should be filed in the AutoViz repo.

Related

backtesting.py ploting function not working

I'm trying to learn backtesting.py, when I run the following sample code, it pops up these errors, anyone could help? I tried to uninstall the Bokeh package and reinstall an older version, but it doen't work.
BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale
C:\Users\paul_\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\formatters.py:399: UserWarning: DatetimeFormatter scales now only accept a single format. Using the first prodvided: '%d %b'
warnings.warn(f"DatetimeFormatter scales now only accept a single format. Using the first prodvided: {fmt[0]!r} ")
BokehDeprecationWarning: Passing lists of formats for DatetimeTickFormatter scales was deprecated in Bokeh 3.0. Configure a single string format for each scale
C:\Users\paul_\AppData\Local\Programs\Python\Python310\lib\site-packages\bokeh\models\formatters.py:399: UserWarning: DatetimeFormatter scales now only accept a single format. Using the first prodvided: '%m/%Y'
warnings.warn(f"DatetimeFormatter scales now only accept a single format. Using the first prodvided: {fmt[0]!r} ")
GridPlot(id='p11925', ...)
import bokeh
import datetime
import pandas_ta as ta
import pandas as pd
from backtesting import Backtest
from backtesting import Strategy
from backtesting.lib import crossover
from backtesting.test import GOOG
class RsiOscillator(Strategy):
upper_bound = 70
lower_bound = 30
rsi_window = 14
# Do as much initial computation as possible
def init(self):
self.rsi = self.I(ta.rsi, pd.Series(self.data.Close), self.rsi_window)
# Step through bars one by one
# Note that multiple buys are a thing here
def next(self):
if crossover(self.rsi, self.upper_bound):
self.position.close()
elif crossover(self.lower_bound, self.rsi):
self.buy()
bt = Backtest(GOOG, RsiOscillator, cash=10_000, commission=.002)
stats = bt.run()
bt.plot()
An issue was opened for this in the GitHub repo:
https://github.com/kernc/backtesting.py/issues/803
A comment in the issue suggests to downgrade bokeh to 2.4.3:
python3 -m pip install bokeh==2.4.3
This worked for me.
I had a similar issue, using Spyder IDE.
Found out I need to call the below for the plot to show for Spyder.
backtesting.set_bokeh_output(notebook=False)
I have update Python to version 3.11 & downgrade bokeh to 2.4.3
This worked for me.
Downgrading Bokeh didn't work for me.
But, after importing backtesting in Jupyter, I needed to do:
backtesting.set_bokeh_output(notebook=False)
The expected plot was then generated in a new interactive browser tab.

Display Pycaret graphs on Azure Notebooks

Pycaret has some rich functions to plot metrics for the models. In the docs, they use jupyter notebooks and it runs perfectly. I'm using Azure Notebooks and I'm not able to display the graphs.
My code is as below:
plot_model(tuned_model)
output: IntProgress(value=0, description='Processing: ', max=5)
I've also tried to use display, like this:
display(plot_model(tuned_model))
But it returns the same output, not showing up any graph.
When I've tried to show other graphs, not from pycaret, it runs normally as below: (Graph shows up after that)
plt.xlabel('date')
plt.ylabel('sales')
plt.plot(train.index,train['sessoes'],label='train')
plt.plot(test.index,test['sessoes'],label='test')
plt.legend()
display(plt.show())
In this link you can check some examples of what I'm trying to plot (Cell 24):
https://github.com/pycaret/pycaret/blob/master/examples/TimeSeries_Forecasting.ipynb
Does anyone knows how to show up pycaret graphs on Azure notebooks?

Labels not showing in python igraph

Why vertex and edge labels won't appear in my graphs?
g = Graph()
g.add_vertices(3)
g.add_edges([(0,1), (1,2), (2,0)])
g.vs["label"]=["A", "B", "C"]
g.es["label"]=["ciao", "lol", "weee"]
layout = g.layout("kk")
plot(g, layout=layout, bbox=(300,300), margin=20)
All of this on macOS Catalina Version 10.15.2, in Spyder, python version 3.7.4
SOLUTION
As pointed out by Sreeram Nair, it is sufficient to save the plot in a pdf to get the graph with the labels.
plot(g, "my_graph.pdf")
gives the following
Basically, there's something wrong in the SVG implementation of Qt (on which the Python notebook is based), or igraph is using SVG incorrectly (not sure which is the case) and QtSVG is not able to render the fonts. Saving a figure to PDF or PNG or whatever format skips Qt entirely, so there's no problem there as explained in the Github issue.
So, could you try saving it and try if the labels appear?

plt.plot() runs infinitely when trying to plot pandas series or dataframes

I've got a trouble when trying to run my jupyter notebook on another computer.
Here I want to plot some time series with matplotlib.pyplot module in order to overlay some points afterwards :
plt.plot(data_df["timestamp"],data_df["sensor_00"])
But then the interpreter/jupyter notebook keep running and only output the following information :
[<matplotlib.lines.Line2D at 0x2a0f892a908>]
Yet the code is working if I use the dataframe's plot argument :
data_df.set_index("timestamp")["sensor_00"].plot()
Outputs:
Just like I'd want ! I know i could just content myself with the dataframe's plotting method but I'll need the matplolib library for further visualizations.
This trouble happens with pandas objects and even when converting the values I want in numpy array, I just keep the program running and not displaying any output.
configuration on both computers :
OS : windows 10 (same as the last computer I did run before).
matplotlib version: 3.1.0 (updated on the computer but didn't work either)
Pandas version : 0.24.2
Python version : 3.7.3 on the new computer and 3.6.8 on the latter but I've tested on a 3.6.8 environment and still didn't work
Alright after a few things I tried, my "timestamp" feature wasn't typed as a datetime object.
What I did to solve the problem :
data_df = data_df.set_index("timestamp")
data_df.index = pd.DatetimeIndex(data_df.index)
Once the timestamp feature is now datetime object it plots fast just as it's supposed to do.

Altair Area Chart Doesn't Display Properly (though It looks fine as a Bar Chart)

I'm not able to identify why the first half of my area chart looks so unusual, while a bar chart of the same dataset looks completely normal.
Here is the dataframe data in csv format:
Month,Poll_Num
SEP,29.7
AUG,28.8
JUL,29.9
JUN,30.3
MAY,35.9
APR,32.2
MAR,30.6
FEB,28.5
JAN,29.9
DEC,22.2
NOV,27.2
I used the following code to plot this data as a bar chart:
alt.Chart(dataframe).mark_bar().encode(
x=alt.X('Month', sort=list(dataframe.Month)),
y=alt.Y('Poll_Num'))
To create the area chart from the same dataframe, all I did was call the mark_area() method instead of mark_bar()
alt.Chart(dataframe).mark_area().encode(
x=alt.X('Month', sort=list(dataframe.Month)),
y=alt.Y('Poll_Num'))
Any ideas on what I might be doing wrong, or what's causing this unusual looking area chart?
This is due to you rendering your chart with an older version of vega-lite – the bug was fixed in vega-lite 3.4. The incorrect version of the chart, rendered with Vega-Lite 3.3 or older, looks like this:
The correct version of the chart, rendered with Vega-Lite 3.4 or newer, looks like this:
To fix it, make certain your frontend renderer is up-to-date. How to do this depends on what frontend you are using:
For JupyterLab: update to the most recent version of JupyterLab (the vega-lite renderer is bundled with it)
For Jupyter Notebook: update the vega package to the most recent version (pip install -U vega).
For Colab, Kaggle, or Altair's built-in serve() method: make certain you are using Altair version 3.2 or newer (pip install -U altair).

Resources