AutoViML/AutoViz

ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x103f249b0>.

icozma opened this issue ยท 19 comments

icozma commented

When running the sample, on Python 3.10.9, it throws an exception as bellow:

import pandas as pd
from autoviz import AutoViz_Class

AV = AutoViz_Class()

data = {'col1': [1, 2, 3, 4, 5], 'col2': [5, 4, 3, 2, 1]}
df = pd.DataFrame(data)

dft = AV.AutoViz(
    "",
    sep=",",
    depVar="",
    dfte=df,
    header=0,
    verbose=1,
    lowess=False,
    chart_format="server",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
    save_plot_dir=None
)
ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x103f249b0>.

The full exception message is:

Exception has occurred: ValueError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x1044d3570>.
  File "/...................................................../.venv/lib/python3.10/site-packages/param/__init__.py", line 1383, in _validate_class_
    raise ValueError(
  File "/...................................................../.venv/lib/python3.10/site-packages/param/__init__.py", line 1371, in _validate
    self._validate_class_(val, self.class_, self.is_instance)
  File "/...................................................../.venv/lib/python3.10/site-packages/param/__init__.py", line 1367, in __init__
    self._validate(default)
  File "/...................................................../.venv/lib/python3.10/site-packages/holoviews/plotting/bokeh/hex_tiles.py", line 30, in hex_binning
    aggregator = param.ClassSelector(
  File "/...................................................../.venv/lib/python3.10/site-packages/holoviews/plotting/bokeh/hex_tiles.py", line 22, in <module>
    class hex_binning(Operation):
  File "/...................................................../.venv/lib/python3.10/site-packages/holoviews/plotting/bokeh/__init__.py", line 40, in <module>
    from .hex_tiles import HexTilesPlot
  File "/...................................................../.venv/lib/python3.10/site-packages/hvplot/converter.py", line 25, in <module>
    from holoviews.plotting.bokeh import OverlayPlot, colormap_generator
  File "/...................................................../.venv/lib/python3.10/site-packages/hvplot/__init__.py", line 12, in <module>
    from .converter import HoloViewsConverter
  File "/...................................................../.venv/lib/python3.10/site-packages/autoviz/AutoViz_Utils.py", line 61, in <module>
    import hvplot.pandas
  File "/...................................................../.venv/lib/python3.10/site-packages/autoviz/AutoViz_Holo.py", line 5, in <module>
    from autoviz.AutoViz_Utils import *
  File "/...................................................../.venv/lib/python3.10/site-packages/autoviz/AutoViz_Class.py", line 61, in <module>
    from autoviz.AutoViz_Holo import AutoViz_Holo
  File "/...................................................../.venv/lib/python3.10/site-packages/autoviz/__init__.py", line 3, in <module>
    from .AutoViz_Class import AutoViz_Class
  File "/...................................................../x.py", line 1, in <module>
    from autoviz import AutoViz_Class
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x1044d3570>.

Hi @icozma :
This error seems related to Python 3.10 and higher. I am currently running on Python 3.7 and 3.8.

Let me see whether I can upgrade AutoViz to Python 3.10 version or higher. I'll also have to check if importing hvplot and pyviz can be made within function calls so I can remove their versions from requirements.txt and setup.py files. It seems like hvplot and pyviz are changing too much for me to hold AutoViz to a consistent version.
Give me a few days.

Hey @icozma ๐Ÿ‘
I have some Good News! I have removed some references to Seaborn styles which have been deprecated. That seems to have fixed some issues. Can you please upgrade your AutoViz version to the latest version (0.1.735) and let me know whether your issues are fixed?
Thanks
Auto Vimal

oyinig commented

I tried the Autoviz upgraded version, I stopped getting errors about seaborn (Python - 3.10.6, autoviz - 0.1.735), but the new error says:

Traceback (most recent call last): File "C:\Users\A\Documents\langcorn\Eagle-Eye-Chain\application\autoViz.py", line 1, in <module> from autoviz import AutoViz_Class File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\autoviz\__init__.py", line 3, in <module> from .AutoViz_Class import AutoViz_Class File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\autoviz\AutoViz_Class.py", line 60, in <module> from autoviz.AutoViz_Holo import AutoViz_Holo File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\autoviz\AutoViz_Holo.py", line 5, in <module> from autoviz.AutoViz_Utils import * File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\autoviz\AutoViz_Utils.py", line 61, in <module> import hvplot.pandas File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\hvplot\__init__.py", line 12, in <module> from .converter import HoloViewsConverter File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\hvplot\converter.py", line 25, in <module> from holoviews.plotting.bokeh import OverlayPlot, colormap_generator File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\holoviews\plotting\bokeh\__init__.py", line 40, in <module> from .hex_tiles import HexTilesPlot File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\holoviews\plotting\bokeh\hex_tiles.py", line 22, in <module> class hex_binning(Operation): File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\holoviews\plotting\bokeh\hex_tiles.py", line 30, in hex_binning aggregator = param.ClassSelector( File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\param\__init__.py", line 1367, in __init__ self._validate(default) File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\param\__init__.py", line 1371, in _validate self._validate_class_(val, self.class_, self.is_instance) File "C:\Users\A\Documents\langcorn\autoviz-venv\lib\site-packages\param\__init__.py", line 1383, in _validate_class_ raise ValueError( ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x000002024D3B90B0>.

This is similar to the original error posted

Hi @icozma
I have finally found the dependency problems with Python 3.10+ and fixed them I think.
I have a new version 0.1.801 of AutoViz - please pip install and try it ๐Ÿ‘
Thanks for your patience,
Auto Vimal

icozma commented

For the above dataframe there is something printing:

Imported v0.1.803. After importing autoviz, you must run '%matplotlib inline' to display charts inline.
    AV = AutoViz_Class()
    dfte = AV.AutoViz(filename, sep=',', depVar='', dfte=None, header=0, verbose=1, lowess=False,
               chart_format='svg',max_rows_analyzed=150000,max_cols_analyzed=30, save_plot_dir=None)
Shape of your Data Set loaded: (5, 2)
#######################################################################################
######################## C L A S S I F Y I N G  V A R I A B L E S  ####################
#######################################################################################
Classifying variables in data set...
    Number of Numeric Columns =  0
    Number of Integer-Categorical Columns =  0
    Number of String-Categorical Columns =  0
    Number of Factor-Categorical Columns =  0
    Number of String-Boolean Columns =  0
    Number of Numeric-Boolean Columns =  0
    Number of Discrete String Columns =  0
    Number of NLP String Columns =  0
    Number of Date Time Columns =  0
    Number of ID Columns =  2
    Number of Columns to Delete =  0
    2 Predictors classified...
        2 variable(s) removed since they were ID or low-information variables
        List of variables removed: ['col1', 'col2']

but still throws this:

ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x1036c62b0>.

Comments copied from #98

Here's the output of import autoviz:

Imported v0.1.803. After importing autoviz, you must run '%matplotlib inline' to display charts inline.
AV = AutoViz_Class()
dfte = AV.AutoViz(filename, sep=',', depVar='', dfte=None, header=0, verbose=1, lowess=False,
chart_format='svg',max_rows_analyzed=150000,max_cols_analyzed=30, save_plot_dir=None)

For the code snippet from my previous post, here's the output:

Shape of your Data Set loaded: (20640, 9)
#######################################################################################
######################## C L A S S I F Y I N G  V A R I A B L E S  ####################
#######################################################################################
Classifying variables in data set...
    Number of Numeric Columns =  8
    Number of Integer-Categorical Columns =  0
    Number of String-Categorical Columns =  0
    Number of Factor-Categorical Columns =  0
    Number of String-Boolean Columns =  0
    Number of Numeric-Boolean Columns =  0
    Number of Discrete String Columns =  0
    Number of NLP String Columns =  0
    Number of Date Time Columns =  0
    Number of ID Columns =  0
    Number of Columns to Delete =  0
    8 Predictors classified...
        No variables removed since no ID or low-information variables found in data set

################ Regression problem #####################
 ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x000001E943902730>. 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[16], line 11
      8 from autoviz import AutoViz_Class
     10 AV = AutoViz_Class()
---> 11 av = AV.AutoViz(filename='', sep=',', header=0, 
     12                 depVar='MedHouseVal', 
     13                 dfte=test, 
     14                 lowess=False,
     15                 max_rows_analyzed=150000, max_cols_analyzed=100, 
     16                 verbose=1, chart_format='bokeh', 
     17                 save_plot_dir=None
     18                )

File ~\Python\venvs\eda311\Lib\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 ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:202, in AutoViz_Holo(filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    200     print('No scatter plots with depVar when no depVar is given.')
    201 else:
--> 202     drawobj1 = draw_scatters_hv(dfin,nums,chart_format,problem_type,
    203                   dep, classes, lowess, mk_dir, verbose)
    204     ls_objects.append(drawobj1)
    205 ### You can draw pair scatters only if there are 2 or more numeric variables ####

File ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:375, in draw_scatters_hv(dft, nums, chart_format, problem_type, dep, classes, lowess, mk_dir, verbose)
    373 def draw_scatters_hv(dft, nums, chart_format, problem_type,
    374                   dep=None, classes=None, lowess=False, mk_dir='AutoViz_Plots', verbose=0):
--> 375     ensure_hvplot_imported()
    376     ######## SCATTER PLOTS ARE USEFUL FOR COMPARING NUMERIC VARIABLES
    377     ##### we are going to modify dfin and classes, so we are making copies to make changes
    378     dft = copy.deepcopy(dft)

File ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:59, in ensure_hvplot_imported()
     56 global hv, opts, pn, pnw, INLINE, classify_columns
     57 try:
     58     # Import main modules
---> 59     import hvplot.pandas
     60     import holoviews as hv
     61     import panel as pn

File ~\Python\venvs\eda311\Lib\site-packages\hvplot\__init__.py:12
      8 import holoviews as _hv
     10 from holoviews import Store
---> 12 from .converter import HoloViewsConverter
     13 from .util import get_ipy
     14 from .utilities import save, show # noqa

File ~\Python\venvs\eda311\Lib\site-packages\hvplot\converter.py:25
     18 from holoviews.core.util import max_range, basestring
     19 from holoviews.element import (
     20     Curve, Scatter, Area, Bars, BoxWhisker, Dataset, Distribution,
     21     Table, HeatMap, Image, HexTiles, QuadMesh, Bivariate, Histogram,
     22     Violin, Contours, Polygons, Points, Path, Labels, RGB, ErrorBars,
     23     VectorField, Rectangles, Segments
     24 )
---> 25 from holoviews.plotting.bokeh import OverlayPlot, colormap_generator
     26 from holoviews.plotting.util import process_cmap
     27 from holoviews.operation import histogram

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\plotting\bokeh\__init__.py:40
     38 from .graphs import GraphPlot, NodePlot, TriMeshPlot, ChordPlot
     39 from .heatmap import HeatMapPlot, RadialHeatMapPlot
---> 40 from .hex_tiles import HexTilesPlot
     41 from .path import PathPlot, PolygonPlot, ContourPlot
     42 from .plot import GridPlot, LayoutPlot, AdjointLayoutPlot

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\plotting\bokeh\hex_tiles.py:22
     18 from .selection import BokehOverlaySelectionDisplay
     19 from .styles import base_properties, line_properties, fill_properties
---> 22 class hex_binning(Operation):
     23     """
     24     Applies hex binning by computing aggregates on a hexagonal grid.
     25 
     26     Should not be user facing as the returned element is not directly
     27     useable.
     28     """
     30     aggregator = param.ClassSelector(
     31         default=np.size, class_=(types.FunctionType, tuple), doc="""
     32       Aggregation function or dimension transform used to compute bin
     33       values. Defaults to np.size to count the number of values
     34       in each bin.""")

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\plotting\bokeh\hex_tiles.py:30, in hex_binning()
     22 class hex_binning(Operation):
     23     """
     24     Applies hex binning by computing aggregates on a hexagonal grid.
     25 
     26     Should not be user facing as the returned element is not directly
     27     useable.
     28     """
---> 30     aggregator = param.ClassSelector(
     31         default=np.size, class_=(types.FunctionType, tuple), doc="""
     32       Aggregation function or dimension transform used to compute bin
     33       values. Defaults to np.size to count the number of values
     34       in each bin.""")
     36     gridsize = param.ClassSelector(default=50, class_=(int, tuple))
     38     invert_axes = param.Boolean(default=False)

File ~\Python\venvs\eda311\Lib\site-packages\param\__init__.py:1367, in ClassSelector.__init__(self, class_, default, instantiate, is_instance, **params)
   1365 self.is_instance = is_instance
   1366 super(ClassSelector,self).__init__(default=default,instantiate=instantiate,**params)
-> 1367 self._validate(default)

File ~\Python\venvs\eda311\Lib\site-packages\param\__init__.py:1371, in ClassSelector._validate(self, val)
   1369 def _validate(self, val):
   1370     super(ClassSelector, self)._validate(val)
-> 1371     self._validate_class_(val, self.class_, self.is_instance)

File ~\Python\venvs\eda311\Lib\site-packages\param\__init__.py:1383, in ClassSelector._validate_class_(self, val, class_, is_instance)
   1381 if is_instance:
   1382     if not (isinstance(val, class_)):
-> 1383         raise ValueError(
   1384             "%s parameter %r value must be an instance of %s, not %r." %
   1385             (param_cls, self.name, class_name, val))
   1386 else:
   1387     if not (issubclass(val, class_)):

ValueError: ClassSelector parameter None value must be an instance of (function, tuple), not <function size at 0x000001E943902730>.

Hope this helps.

Hi @RNarayan73 : As I have said this before, this is a problem between hvplot.pandas and Python version 3.11. Can you instead try installing and importing hvplot.pandas separately in your Oython 3,11 environment? That should take care of this problem!

As far I am concerned, this is a not a problem with AutoViz. I suggest you take it up in their forums.
Thanks
Auto Vimal

@AutoViML
I have created an issue #1239 in the hvplot repository. From reading another issue #1187, it seems to do with the use of older versions of hvplot, holoviews and bokeh.

I'll update any comments from those issues here for your action if it helps.

Hi all, I'm writing with respect to holoviz/hvplot#1239. This issue was fixed in holoviz/holoviews#5636 and released in HoloViews 1.16.0. It turns out this was all due to a change in Numpy itself, see numpy/numpy#23307.

AutoViz is pinning hvPlot and HoloViews to older versions but has no pin on Numpy:

AutoViz/setup.py

Lines 30 to 32 in ba75e53

"holoviews~=1.14.9",
"bokeh~=2.4.2",
"hvplot~=0.7.3",

In my opinion your solutions include:

  • using an older version of Numpy that is compatible with HoloViews <1.16.0
  • update AutoViz to be compatible with HoloViews >= 1.16.0 (maybe it's already compatible and it's just about lifting the pin, but I don't really know)

As far as hvPlot is concerned, there isn't much we can do. In an ideal world we could backport this kind of bug fixes to older versions, but we really don't have the bandwith to do so, i.e. packages dependents on HoloViews have to use the latest version to benefit from the bug fixes.

@AutoViML, as suggested in the comment from the hvplot repository to the issues I posted there, this seems to be a problem with the incompatible, older versions of the dependencies used by autoviz.

Hope you will be able to fix it.

Hi @RNarayan73, @maximlt ๐Ÿ‘
thank you all for the persistence and your helpful analysis.

I am going to pin the older version of numpy in this case numpy < 1.25.0

I feel that the later versions cannot be guaranteed to work with the rest of AutoViz and I would need to test extensively. I hope this works for your needs. Please upgrade to the latest version of autoviz and let me know.
Thanks

Auto Vimal

@AutoViML, the earlier error in issue #98 has re-emerged with version 0.1.804 on Python 3.11. Error log below:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[19], line 7
      4 np.bool = bool
      6 AV = AutoViz_Class()
----> 7 av = AV.AutoViz(filename='', sep=',', header=0, 
      8                 depVar='result', #'MedHouseVal', #
      9                 dfte=DATA1, #test, #
     10                 lowess=False,
     11                 max_rows_analyzed=150000, max_cols_analyzed=100, 
     12                 verbose=1, chart_format='bokeh', #'html', #
     13                 #verbose=2, chart_format='html', # creates separate and very large files
     14                 save_plot_dir=None
     15                )

File ~\Python\venvs\eda311\Lib\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 ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:210, in AutoViz_Holo(filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    207         drawobj2 = draw_pair_scatters_hv(dfin, nums, problem_type, chart_format, dep,
    208                        classes, lowess, mk_dir, verbose)
    209         ls_objects.append(drawobj2)
--> 210 drawobj3 = draw_distplot_hv(dfin, cats, nums, chart_format, problem_type, dep, classes, mk_dir, verbose)
    211 ls_objects.append(drawobj3)
    212 ### kdeplot is the only time you send in ls_objects since it has to be returned with 2 objects ###

File ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:784, in draw_distplot_hv(dft, cats, conti, chart_format, problem_type, dep, classes, mk_dir, verbose)
    782     return plot
    783 #######  This is where you call the widget and pass it the select_variable to draw a Chart #######
--> 784 dmap = hv.DynamicMap(select_widget,  kdims=['Select_categorical_var']).redim.values(
    785                                     Select_categorical_var=cats)
    786 ###########  This is where you put the Panel Together ############
    787 hv_panel = pn.panel(dmap)

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\core\spaces.py:923, in DynamicMap.__init__(self, callback, initial_items, streams, **params)
    919     raise TypeError(msg.format(objs = ', '.join('%r' % el for el in invalid)))
    921 super(DynamicMap, self).__init__(initial_items, callback=callback, streams=valid, **params)
--> 923 if self.callback.noargs:
    924     prefix = 'DynamicMaps using generators (or callables without arguments)'
    925     if self.kdims:

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\core\spaces.py:640, in Callable.noargs(self)
    637 @property
    638 def noargs(self):
    639     "Returns True if the callable takes no arguments"
--> 640     noargs = inspect.ArgSpec(args=[], varargs=None, keywords=None, defaults=None)
    641     return self.argspec == noargs

AttributeError: module 'inspect' has no attribute 'ArgSpec'

Support for Python 3.11 was fixed in holoviz/holoviews#5513 and released in HoloViews 1.15.3 https://holoviews.org/releases.html#version-1-15-3.

@AutoViML Can you please reopen #98 which as I mentioned in my previous post has re-emerged?

@RNarayan73 : I have re-opened issue #98 please provide a solution that I can implement. Better yet if you know the answer, just submit a pull request or post your changes here and I will update it. I am not able to understand all the complications happening here.