-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XGBRegressor fit method numpy type error #96
Comments
Hi @PrestonBlackburn - I'd be happy to help you. In an attempt to reproduce, I made a script that loads sample sklearn data, does a similar snowflake casting, and runs the grid search fit. I was unable to reproduce your error with the script I made below, so there may be an interaction with your particular data. Two questions:
In an attempt to find the deprecated attributes, I did a search for My repro: From pip freeze:
Script:
|
Hey, thanks for following up. I tested the same code with the same Python 3.8.3 version and requirements in a separate conda env, but when I did that, it worked. I guess it must have been some sort of issue with that particular environment. Here is the full error, but since I can't reproduce it in another environment, I think this can probably be closed. Traceback (most recent call last):
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\_internal\telemetry.py", line 367, in wrap
res = func(*args, **kwargs)
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\modeling\model_selection\grid_search_cv.py", line 331, in fit
self._sklearn_object = model_trainer.train()
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\modeling\_internal\snowpark_implementations\snowpark_trainer.py", line 433, in train
fit_wrapper_sproc = self._get_fit_wrapper_sproc(statement_params=statement_params)
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\modeling\_internal\snowpark_implementations\snowpark_trainer.py", line 253, in _get_fit_wrapper_sproc
model_spec = ModelSpecificationsBuilder.build(model=self.estimator)
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\modeling\_internal\model_specifications.py", line 132, in build
return SklearnModelSelectionModelSpecifications()
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\modeling\_internal\model_specifications.py", line 97, in __init__
import lightgbm
File "C:\Users\Preston\anaconda3\lib\site-packages\lightgbm\__init__.py", line 8, in <module>
from .basic import Booster, Dataset, register_logger
File "C:\Users\Preston\anaconda3\lib\site-packages\lightgbm\basic.py", line 17, in <module>
from .compat import PANDAS_INSTALLED, concat, dt_DataTable, is_dtype_sparse, pd_DataFrame, pd_Series
File "C:\Users\Preston\anaconda3\lib\site-packages\lightgbm\compat.py", line 114, in <module>
from dask.array import Array as dask_Array
File "C:\Users\Preston\anaconda3\lib\site-packages\dask\array\__init__.py", line 3, in <module>
from .core import (
File "C:\Users\Preston\anaconda3\lib\site-packages\dask\array\core.py", line 22, in <module>
from . import chunk
File "C:\Users\Preston\anaconda3\lib\site-packages\dask\array\chunk.py", line 7, in <module>
from . import numpy_compat as npcompat
File "C:\Users\Preston\anaconda3\lib\site-packages\dask\array\numpy_compat.py", line 21, in <module>
np.divide(0.4, 1, casting="unsafe", dtype=np.float),
File "C:\Users\Preston\anaconda3\lib\site-packages\numpy\__init__.py", line 305, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "issue_test.py", line 65, in <module>
grid_search.fit(df_typed)
File "C:\Users\Preston\anaconda3\lib\site-packages\snowflake\ml\_internal\telemetry.py", line 389, in wrap
raise me.original_exception from e
AttributeError: (0000) module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations |
@PrestonBlackburn Thanks for sharing the full error. This provides many more clues as to what happened. This error is actually being raised when calling You may be wondering, why are we importing lightgbm at all since you're running an xgboost model? When we execute the |
@PrestonBlackburn Marking as closed because this seems to be an incompatibility in your local python environment; if you are able to reproduce with a version of lightgbm we support please do update us |
Hey, I was having an issue with running the XGBRegressor fit method throwing a numpy type error. Snowpark ml installs numpy version 1.24, but when I run the .fit() method I get an error related to the numpy version (float type depreciation)
Original Code (simplified, but still errors)
Error
environment
python version: 3.8.3
If I change my numpy version to <1.20 then GridSearchCV throws an error when trying to import:
The text was updated successfully, but these errors were encountered: