AutoViML / AutoViz

Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.
Apache License 2.0
1.7k stars 196 forks source link

Error when calling AutoViz (v0.1.808) with Bokeh as the chart_format on certain datasets: Unexpected option 'colorbar'... #108

Closed patrickm663 closed 4 months ago

patrickm663 commented 4 months ago

Hi

I am getting a strange error when using Bokeh as the backend, whereas SVG works. Part of the visualisation gets produced before throwing an error.

After testing Iris and Penguins data from Seaborn, the issue likely stems from the structure of the Planets dataset that is not being handled correctly. In fact, all of these datasets from Seaborn seem to fail:

What they all have in common is that they contain a date of sorts, however, datasets like "glue" have an int64 for its Year column so this may just be coincidence.

Below is a MWE (Classic Jupyter Notebook view):

import seaborn as sns
from autoviz.AutoViz_Class import AutoViz_Class

planets = sns.load_dataset("planets")

AV = AutoViz_Class()
%matplotlib inline
dft = AV.AutoViz(
    "",
    sep=",",
    depVar="",
    dfte=planets,
    header=0,
    verbose=1,
    lowess=False,
    chart_format="bokeh",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
    save_plot_dir=None
)
ValueError: Unexpected option 'colorbar' for Curve type across all extensions. Similar options for current extension ('bokeh') are: ['bgcolor', 'color', 'toolbar'].

Below is the stacktrace:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[9], line 3
      1 AV = AutoViz_Class()
----> 3 dft = AV.AutoViz(
      4     "",
      5     sep=",",
      6     depVar="",
      7     dfte=planets,
      8     header=0,
      9     verbose=1,
     10     lowess=False,
     11     chart_format="bokeh",
     12     max_rows_analyzed=150000,
     13     max_cols_analyzed=30,
     14     save_plot_dir=None
     15 )

File /opt/conda/lib/python3.11/site-packages/autoviz/AutoViz_Class.py:256, in AutoViz_Class.AutoViz(self, filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    254 ####################################################################################
    255 if chart_format.lower() in ['bokeh','server','bokeh_server','bokeh-server', 'html']:
--> 256     dft = AutoViz_Holo(filename, sep, depVar, dfte, header, verbose,
    257                 lowess,chart_format,max_rows_analyzed,
    258                     max_cols_analyzed, save_plot_dir)
    259 else:
    260     dft = self.AutoViz_Main(filename, sep, depVar, dfte, header, verbose,
    261                 lowess,chart_format,max_rows_analyzed,
    262                     max_cols_analyzed, save_plot_dir)

File /opt/conda/lib/python3.11/site-packages/autoviz/AutoViz_Holo.py:232, in AutoViz_Holo(filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    230     ls_objects.append(drawobj6)
    231 if len(date_vars) > 0:
--> 232     drawobj7 = draw_date_vars_hv(dfin,dep,date_vars, nums, chart_format, problem_type, mk_dir, verbose)
    233     ls_objects.append(drawobj7)
    234 if len(nums) > 0 and len(cats) > 0:

File /opt/conda/lib/python3.11/site-packages/autoviz/AutoViz_Holo.py:1047, in draw_date_vars_hv(df, dep, datevars, nums, chart_format, modeltype, mk_dir, verbose)
   1043     return hv.Curve(conti_df).opts(**opts)
   1045 widgets = pn.WidgetBox(x, y)
-> 1047 hv_panel = pn.Row(widgets, create_figure).servable('Cross-selector')    
   1048 #####################################################
   1049 ##### Save all the chart objects here ##############
   1050 if chart_format in ['server', 'bokeh_server', 'bokeh-server']:
   1051     #server = pn.serve(hv_panel, start=True, show=True)

File /opt/conda/lib/python3.11/site-packages/panel/layout/base.py:630, in ListPanel.__init__(self, *objects, **params)
    626     if 'objects' in params:
    627         raise ValueError("A %s's objects should be supplied either "
    628                          "as positional arguments or as a keyword, "
    629                          "not both." % type(self).__name__)
--> 630     params['objects'] = [panel(pane) for pane in objects]
    631 elif 'objects' in params:
    632     params['objects'] = [panel(pane) for pane in params['objects']]

File /opt/conda/lib/python3.11/site-packages/panel/layout/base.py:630, in <listcomp>(.0)
    626     if 'objects' in params:
    627         raise ValueError("A %s's objects should be supplied either "
    628                          "as positional arguments or as a keyword, "
    629                          "not both." % type(self).__name__)
--> 630     params['objects'] = [panel(pane) for pane in objects]
    631 elif 'objects' in params:
    632     params['objects'] = [panel(pane) for pane in params['objects']]

File /opt/conda/lib/python3.11/site-packages/panel/pane/base.py:81, in panel(obj, **kwargs)
     79 if kwargs.get('name', False) is None:
     80     kwargs.pop('name')
---> 81 pane = PaneBase.get_pane_type(obj, **kwargs)(obj, **kwargs)
     82 if len(pane.layout) == 1 and pane._unpack:
     83     return pane.layout[0]

File /opt/conda/lib/python3.11/site-packages/panel/param.py:786, in ParamMethod.__init__(self, object, **params)
    784 self._validate_object()
    785 if not self.defer_load:
--> 786     self._replace_pane()

File /opt/conda/lib/python3.11/site-packages/panel/param.py:838, in ParamMethod._replace_pane(self, force, *args)
    836     new_object = Spacer()
    837 else:
--> 838     new_object = self.eval(self.object)
    839 if inspect.isawaitable(new_object):
    840     param.parameterized.async_executor(partial(self._eval_async, new_object))

File /opt/conda/lib/python3.11/site-packages/panel/param.py:818, in ParamMethod.eval(self, function)
    816         args = (getattr(dep.owner, dep.name) for dep in arg_deps)
    817         kwargs = {n: getattr(dep.owner, dep.name) for n, dep in kw_deps.items()}
--> 818 return function(*args, **kwargs)

File /opt/conda/lib/python3.11/site-packages/param/parameterized.py:407, in depends.<locals>._depends(*args, **kw)
    405 @wraps(func)
    406 def _depends(*args, **kw):
--> 407     return func(*args, **kw)

File /opt/conda/lib/python3.11/site-packages/autoviz/AutoViz_Holo.py:1043, in draw_date_vars_hv.<locals>.create_figure(x, y)
   1041 dft = df.set_index(df[x])
   1042 conti_df = df[[x,y]].set_index(df[x]).drop(x, axis=1)
-> 1043 return hv.Curve(conti_df).opts(**opts)

File /opt/conda/lib/python3.11/site-packages/holoviews/core/accessors.py:47, in AccessorPipelineMeta.pipelined.<locals>.pipelined_call(*args, **kwargs)
     44     inst._obj._in_method = True
     46 try:
---> 47     result = __call__(*args, **kwargs)
     49     if not in_method:
     50         init_op = factory.instance(
     51             output_type=type(inst),
     52             kwargs={'mode': getattr(inst, 'mode', None)},
     53         )

File /opt/conda/lib/python3.11/site-packages/holoviews/core/accessors.py:573, in Opts.__call__(self, *args, **kwargs)
    567         msg = ("Calling the .opts method with options broken down by options "
    568                "group (i.e. separate plot, style and norm groups) is deprecated. "
    569                "Use the .options method converting to the simplified format "
    570                "instead or use hv.opts.apply_groups for backward compatibility.")
    571         param.main.param.warning(msg)
--> 573 return self._dispatch_opts( *args, **kwargs)

File /opt/conda/lib/python3.11/site-packages/holoviews/core/accessors.py:577, in Opts._dispatch_opts(self, *args, **kwargs)
    575 def _dispatch_opts(self, *args, **kwargs):
    576     if self._mode is None:
--> 577         return self._base_opts(*args, **kwargs)
    578     elif self._mode == 'holomap':
    579         return self._holomap_opts(*args, **kwargs)

File /opt/conda/lib/python3.11/site-packages/holoviews/core/accessors.py:656, in Opts._base_opts(self, *args, **kwargs)
    653     return opts.apply_groups(self._obj, **dict(kwargs, **new_kwargs))
    655 kwargs['clone'] = False if clone is None else clone
--> 656 return self._obj.options(*new_args, **kwargs)

File /opt/conda/lib/python3.11/site-packages/holoviews/core/data/__init__.py:207, in PipelineMeta.pipelined.<locals>.pipelined_fn(*args, **kwargs)
    204     inst._in_method = True
    206 try:
--> 207     result = method_fn(*args, **kwargs)
    208     if PipelineMeta.disable:
    209         return result

File /opt/conda/lib/python3.11/site-packages/holoviews/core/data/__init__.py:1219, in Dataset.options(self, *args, **kwargs)
   1217 @wraps(Dimensioned.options)
   1218 def options(self, *args, **kwargs):
-> 1219     return super(Dataset, self).options(*args, **kwargs)

File /opt/conda/lib/python3.11/site-packages/holoviews/core/dimension.py:1303, in Dimensioned.options(self, *args, **kwargs)
   1301     expanded_backends = opts._expand_by_backend(options, backend)
   1302 else:
-> 1303     expanded_backends = [(backend, opts._expand_options(options, backend))]
   1305 obj = self
   1306 for backend, expanded in expanded_backends:

File /opt/conda/lib/python3.11/site-packages/holoviews/util/__init__.py:379, in opts._expand_options(cls, options, backend)
    373         else:
    374             valid_options = sorted({
    375                 keyword
    376                 for group_opts in obj_options.groups.values()
    377                 for keyword in group_opts.allowed_keywords
    378             })
--> 379             cls._options_error(opt, objtype, backend, valid_options)
    380 return expanded

File /opt/conda/lib/python3.11/site-packages/holoviews/util/__init__.py:422, in opts._options_error(cls, opt, objtype, backend, valid_options)
    419     return
    421 if matches:
--> 422     raise ValueError('Unexpected option %r for %s type '
    423                      'across all extensions. Similar options '
    424                      'for current extension (%r) are: %s.' %
    425                      (opt, objtype, current_backend, matches))
    426 else:
    427     raise ValueError('Unexpected option %r for %s type '
    428                      'across all extensions. No similar options '
    429                      'found.' % (opt, objtype))

ValueError: Unexpected option 'colorbar' for Curve type across all extensions. Similar options for current extension ('bokeh') are: ['bgcolor', 'color', 'toolbar'].
patrickm663 commented 4 months ago

Forgot to add:

AutoViML commented 4 months ago

Hi @patrickm663 Sorry for the errors. I noticed that with pandas 2.0 and numpy >1.24 and newer python versions, the entire python ecosystem has gone for a toss. I am sorry to say but it is hitting open source developers like me hard. We now have to have different versions for different python versions. I have tried my best to maintain support for AutoViz in these trying times for python ecosystem. So please try to install directly from the github if possible to get the latest updates.

pip install git+https://github.com/AutoViML/AutoViz.git --user

For now, I have fixed your error 👍

You can check it by upgrading to autoviz version 0.1.901 as follows pip install autoviz==0.1.901

or pip install autoviz --upgrade

Thanks AutoVimal

AutoViML commented 4 months ago

Hi @patrickm663 Sorry for the errors. I noticed that with pandas 2.0 and numpy >1.24 and newer python versions, the entire python ecosystem has gone for a toss. I am sorry to say but it is hitting open source developers like me hard. We now have to have different versions for different python versions. I have tried my best to maintain support for AutoViz in these trying times for python ecosystem. So please try to install directly from the github if possible to get the latest updates.

pip install git+https://github.com/AutoViML/AutoViz.git --user

For now, I have fixed your error 👍

You can check it by upgrading to autoviz version 0.1.901 as follows pip install autoviz==0.1.901

or pip install autoviz --upgrade

Thanks AutoVimal

patrickm663 commented 3 months ago

Hi

Sorry for the delayed response but thanks very much for looking into this!

Interestingly, I came across it when cleaning up the 'mess' caused by Pandas updating and breaking some old code. This prompted a further look at some notebooks that hadn't run in a while (to see if they still worked correctly with updated dependencies) and noted the edge-case here that had previously worked.

Many thanks again!

Best wishes Patrick