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

ValueError: Callable parameter 'callable' only takes a callable object, not objects of type . #85

Closed senovr closed 1 year ago

senovr commented 1 year ago

Hi, I am trying to use autoviz to find "corellation" between dataframe that contains only categorical variables (both as features and as target) When calling autoviz, it falls with the error in description. Can you please advice what is the reason for such traceback? Probably, I should change dtypes from ints to something else (pandas categorical for example )

simple "toy" dataframe to reproduce such behavior:

feat1=np.random.randint(2, size=100)
feat2=np.random.randint(6,size=100)
feat3=np.random.randint(2, size=100)
target=np.random.randint(2, size=100)
df_tmp=pd.DataFrame({"feat1":feat1,"feat2":feat2,"feat3":feat3,"target":target})
#calling the autoviz
filename = ""
sep = ","
dft = AV.AutoViz(
    filename,
    sep=",",
    depVar="target",
    dfte=df_tmp,
    header=0,
    verbose=0,
    lowess=False,
    chart_format="html",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
    save_plot_dir=None
)

Output and traceback:

Shape of your Data Set loaded: (100, 4)
#######################################################################################
######################## 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 =  1
    Number of String-Categorical Columns =  0
    Number of Factor-Categorical Columns =  0
    Number of String-Boolean Columns =  0
    Number of Numeric-Boolean Columns =  2
    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
    3 Predictors classified...
        No variables removed since no ID or low-information variables found in data set

################ Binary_Classification problem #####################
Saving scatterplots in HTML format

WARNING:bokeh.core.validation.check:W-1005 (FIXED_SIZING_MODE): 'fixed' sizing mode requires width and height to be set: Row(id='190593', ...)
Saving distplots_cats in HTML format
Saving distplots_nums in HTML format

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

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\autoviz\AutoViz_Class.py:270, in AutoViz_Class.AutoViz(self, filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    268 ####################################################################################
    269 if chart_format.lower() in ['bokeh','server','bokeh_server','bokeh-server', 'html']:
--> 270     dft = AutoViz_Holo(filename, sep, depVar, dfte, header, verbose,
    271                 lowess,chart_format,max_rows_analyzed,
    272                     max_cols_analyzed, save_plot_dir)
    273 else:
    274     dft = self.AutoViz_Main(filename, sep, depVar, dfte, header, verbose,
    275                 lowess,chart_format,max_rows_analyzed,
    276                     max_cols_analyzed, save_plot_dir)

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\autoviz\AutoViz_Holo.py:183, in AutoViz_Holo(filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    181 ls_objects.append(drawobj3)
    182 ### kdeplot is the only time you send in ls_objects since it has to be returned with 2 objects ###
--> 183 drawobj4 = draw_kdeplot_hv(dfin, cats, nums, chart_format, problem_type, dep, ls_objects, mk_dir, verbose)
    184 if not drawobj4:
    185     ### if it is not blank, then treat it as ls_objects ###
    186     ls_objects = copy.deepcopy(drawobj4)

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\autoviz\AutoViz_Holo.py:295, in draw_kdeplot_hv(dfin, cats, nums, chart_format, problem_type, dep, ls_objects, mk_dir, verbose)
    291 drawobj41 = pdf1.hvplot(kind='bar', color='r', title='Distribution of Target variable').opts(
    292                 height=height_size, width=width_size,xrotation=70)
    293 drawobj42 = pdf2.hvplot(kind='bar', color='g', title='Percent Distribution of Target variable').opts(
    294                 )
--> 295 dmap = hv.DynamicMap((drawobj41+drawobj42).opts(shared_axes=False).opts(title='Histogram and KDE of Target = %s' %dep)).opts(
    296                     height=height_size, width=width_size)
    297 dmap.opts(framewise=True,axiswise=True) ## both must be True for your charts to have dynamically varying axes!
    298 hv_all = pn.pane.HoloViews(dmap)#, sizing_mode="stretch_both")

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\holoviews\core\spaces.py:783, in DynamicMap.__init__(self, callback, initial_items, streams, **params)
    781     callback = Generator(callback)
    782 elif not isinstance(callback, Callable):
--> 783     callback = Callable(callback)
    785 valid, invalid = Stream._process_streams(streams)
    786 if invalid:

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\holoviews\core\spaces.py:498, in Callable.__init__(self, callable, **params)
    497 def __init__(self, callable, **params):
--> 498     super().__init__(callable=callable,
    499                      **dict(params, name=util.callable_name(callable)))
    500     self._memoized = {}
    501     self._is_overlay = False

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\parameterized.py:3173, in Parameterized.__init__(self, **params)
   3170 self._dynamic_watchers = defaultdict(list)
   3172 self.param._generate_name()
-> 3173 self.param._setup_params(**params)
   3174 object_count += 1
   3176 self.param._update_deps(init=True)

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\parameterized.py:1387, in as_uninitialized..override_initialization(self_, *args, **kw)
   1385 original_initialized = parameterized_instance.initialized
   1386 parameterized_instance.initialized = False
-> 1387 fn(parameterized_instance, *args, **kw)
   1388 parameterized_instance.initialized = original_initialized

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\parameterized.py:1641, in Parameters._setup_params(self_, **params)
   1639     self.param.warning("Setting non-parameter attribute %s=%s using a mechanism intended only for parameters", name, val)
   1640 # i.e. if not desc it's setting an attribute in __dict__, not a Parameter
-> 1641 setattr(self, name, val)

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\parameterized.py:369, in instance_descriptor.._f(self, obj, val)
    367     instance_param.__set__(obj, val)
    368     return
--> 369 return f(self, obj, val)

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\parameterized.py:1201, in Parameter.__set__(self, obj, val)
   1198 if hasattr(self, 'set_hook'):
   1199     val = self.set_hook(obj,val)
-> 1201 self._validate(val)
   1203 _old = NotImplemented
   1204 # obj can be None if __set__ is called for a Parameterized class

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\parameterized.py:1261, in Parameter._validate(self, val)
   1259 def _validate(self, val):
   1260     """Implements validation for the parameter value and attributes"""
-> 1261     self._validate_value(val, self.allow_None)

File c:\Users\User\repos\myrepos\.venv_py310\lib\site-packages\param\__init__.py:1106, in Callable._validate_value(self, val, allow_None)
   1103 if (allow_None and val is None) or callable(val):
   1104     return
-> 1106 raise ValueError("Callable parameter %r only takes a callable object, "
   1107                  "not objects of type %r." % (self.name, type(val)))

ValueError: Callable parameter 'callable' only takes a callable object, not objects of type .
ZackTack commented 1 year ago

I met the same problem and my temp solution was to downgrade autoviz version to 0.1.58 pip install autoviz==0.1.58

AutoViML commented 1 year ago

@senovr @ZackTack : Thank you both for trying our AutoViz 👍 I tested your dataset on the latest version of AutoViz Imported v0.1.601 and it works fine.

There must be a minor bug that has been fixed. Sorry for the inconvenience. Please confirm by closing this issue. Auto Vimal

senovr commented 1 year ago

@AutoViML Unfortunately, I can not confirm this. My autoviz is already 601, and above-mentioned behavior happened with this most up-to-date package.

pip list
Package                       Version     Editable project location
----------------------------- ----------- -------------------------------------------
...
autoviz                       0.1.601
AutoViML commented 1 year ago

Hi @senovr That means nothing. It only means that the problem is not in AutoViz and in perhaps the config of your machine. I am using holoviz underneath AutoViz which is what this function call hv.DynamicMap() calls.

So if you are erroring there in your machine while it is not erroring in my machine, it only means that some version of hvplot is causing this issue. You need to try a few things and see.

Thanks for trying out AutoViz👍 Auto Vimal

senovr commented 1 year ago

@AutoViML I don' think that approach "if it works on my machine than it is fine" is a good reason to mark this issue as resolved.

Let me try few more things, create blank .venv from scratch move to linux, play with the pandas dtypes (ints, floats, categorical, etc.).

I will come back to you with the results.

Yard1 commented 1 year ago

Most likely seems to be related to a new version of param released in March. I'd assume AutoViz requires an update to conform to whatever API changes have been made, or at the very least a pin in its requirements. It could also be a problem that needs to be fixed in holoviz.

Yard1 commented 1 year ago

It seems that installing holoviews<=1.14.9 fixes this, which means AutoViz needs an update. I believe this is due to the fact that the draw_kdeplot_hv function passes hvplot objects directly to hv.DynamicMap instead of passing a callable that returns them. This is already done in other AutoViz functions.

AutoViML commented 1 year ago

Yes I have changed the requirements.txt and setup.py file to  holoviews~=1.14.9 Please check the latest version and let me know.Auto Vimal On Sunday, April 30, 2023 at 08:02:38 PM EDT, Antoni Baum @.***> wrote:

It seems that installing holoviews<=1.14.9 fixes this, which means AutoViz needs an update. I believe this is due to the fact that the draw_kdeplot_hv function passes hvplot objects directly to hv.DynamicMap instead of passing a callable that returns them. This is already done in other AutoViz functions.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>