shankarpandala / lazypredict

Lazy Predict help build a lot of basic models without much code and helps understand which models works better without any parameter tuning
MIT License
2.86k stars 329 forks source link

ImportError: cannot import name 'values_from_object' from 'pandas._libs.lib' #337

Open rushiai opened 3 years ago

rushiai commented 3 years ago

Description

Im running libeary on google colab

What I Did

clf = LazyClassifier(verbose=0, ignore_warnings=True, custom_metric=None) models, predictions = clf.fit(X_train, X_test, y_train, y_test) models

Output =>
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pyforest/__init__.py in <module>()
      1 clf = LazyClassifier(verbose=0, ignore_warnings=True, custom_metric=None)
----> 2 models, predictions = clf.fit(X_train, X_test, y_train, y_test)
      3 models

6 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/computation/expressions.py in <module>()
     13 from pandas._config import get_option
     14 
---> 15 from pandas._libs.lib import values_from_object
     16 
     17 from pandas.core.dtypes.generic import ABCDataFrame

ImportError: cannot import name 'values_from_object' from 'pandas._libs.lib' (/usr/local/lib/python3.7/dist-packages/pandas/_libs/lib.cpython-37m-x86_64-linux-gnu.so)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
ManuFU commented 3 years ago

I had the same problem. Following helped:

pip uninstall pandas pip install pandas

ArvindReddyC commented 3 years ago

I had the same problem. Following helped:

pip uninstall pandas pip install pandas

doing so gave raise to this

image

abhijitpanda890 commented 3 years ago

I too am getting the same issue. Please help me if anyone got it resolved!

abhijitpanda890 commented 3 years ago

No improvement even after uninstall and install

mpaloni commented 3 years ago

Faced the same issue, tried reinstalling pandas - got another problem

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-43151a3c765d> in <module>
      2 
      3 reg = LazyRegressor(verbose=0, ignore_warnings=True, custom_metric=None)
----> 4 models, predictions = reg.fit(X_train, X_valid, y_train, y_valid)
      5 
      6 print(models)

/opt/conda/lib/python3.8/site-packages/lazypredict/Supervised.py in fit(self, X_train, X_test, y_train, y_test)
    572         categorical_features = X_train.select_dtypes(include=["object"]).columns
    573 
--> 574         categorical_low, categorical_high = get_card_split(
    575             X_train, categorical_features
    576         )

/opt/conda/lib/python3.8/site-packages/lazypredict/Supervised.py in get_card_split(df, cols, n)
    142         Columns with cardinality >= n
    143     """
--> 144     cond = df[cols].nunique() > n
    145     card_high = cols[cond]
    146     card_low = cols[~cond]

/opt/conda/lib/python3.8/site-packages/pandas/core/ops/common.py in new_method(self, other)
     63                     break
     64                 if isinstance(other, cls):
---> 65                     return NotImplemented
     66 
     67         other = item_from_zerodim(other)

/opt/conda/lib/python3.8/site-packages/pandas/core/ops/__init__.py in wrapper(self, other)
    368     #  to avoid constructing two potentially large/sparse DataFrames
    369     join_columns, _, _ = left.columns.join(
--> 370         right.columns, how="outer", level=None, return_indexers=True
    371     )
    372 

/opt/conda/lib/python3.8/site-packages/pandas/core/ops/array_ops.py in comparison_op(left, right, op)
    249     rvalues = ensure_wrapped_if_datetimelike(right)
    250 
--> 251     rvalues = lib.item_from_zerodim(rvalues)
    252     if isinstance(rvalues, list):
    253         # TODO: same for tuples?

/opt/conda/lib/python3.8/site-packages/pandas/core/ops/array_ops.py in na_arithmetic_op(left, right, op, is_cmp)
    138 def _na_arithmetic_op(left, right, op, is_cmp: bool = False):
    139     """
--> 140     Return the result of evaluating op on the passed in values.
    141 
    142     If native types are not compatible, try coercion to object dtype.

/opt/conda/lib/python3.8/site-packages/pandas/core/computation/expressions.py in <module>
     17 from pandas._typing import FuncType
     18 
---> 19 from pandas.core.computation.check import NUMEXPR_INSTALLED
     20 from pandas.core.ops import roperator
     21 

/opt/conda/lib/python3.8/site-packages/pandas/core/computation/check.py in <module>
      1 from pandas.compat._optional import import_optional_dependency
      2 
----> 3 ne = import_optional_dependency("numexpr", errors="warn")
      4 NUMEXPR_INSTALLED = ne is not None
      5 if NUMEXPR_INSTALLED:

TypeError: import_optional_dependency() got an unexpected keyword argument 'errors'¸¸¸

Then i found a suggestion to align numpy and pandas versions with

!pip uninstall numpy -y
!pip install numpy==1.20.1

!pip uninstall pandas -y
!pip install pandas==1.2.2

And LazyPredict is running now! :)

Edit: The script ran successfully after that!

anhnt-mageplaza commented 2 years ago

Re-installing pandas to 1.1.5 works for me even though some incompatible warning messages from lazy predict. I think the version for pandas 1.0.5 should be updated to 1.1.5.

zanjibar commented 2 years ago

Under windows 11 environment, I get the same error after reinstalling.

ImportError: cannot import name 'NoDefault' from 'pandas._libs.lib' (z:\etc\pythons\p37\lib\site-packages\pandas\_libs\lib.cp37-win_amd64.pyd)