Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

NameError: name 'functools' is not defined

$
0
0

Have googled and found this but unrelated.

Trying to run a simple Elastic Net demo and getting the referenced error with the below code.

Using Python 3.9 with sklearn version:

scikit-learn==1.4.1.post1scikit-learn-intelex==2021.20221004.171807

Any ideas what could be causing this? X and y vars are an Array and Series respectively.

from sklearn.model_selection import GridSearchCVfrom sklearn.linear_model import ElasticNetbase_EN = ElasticNet()params = {'alpha': [0.1,1,5,10,50,100],'l1_ratio': [.1,.2,.25,.5,.75,.8,.9,.95,.99,1]        }grid = GridSearchCV(estimator = base_EN,                    param_grid = params)grid.fit(scaled_X_train, y_train)

Traceback (most recent call last):

File"/home/chris/anaconda3/lib/python3.9/site-packages/joblib/parallel.py",line 822, in dispatch_one_batchthis_batch_duration)

File "/home/chris/anaconda3/lib/python3.9/queue.py", line 168, ingetraise Empty

Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/tmp/ipykernel_108025/877226095.py", line 10, in grid.fit(scaled_X_train, y_train)

File"/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py",line 891, in fitreturn_n_test_samples=True,

File"/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py",line 1392, in _run_search

File"/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py",line 838, in evaluate_candidates)

File"/home/chris/anaconda3/lib/python3.9/site-packages/joblib/parallel.py",line 1043, in callThreshold on the size of arrays passed to the workers that

File"/home/chris/anaconda3/lib/python3.9/site-packages/joblib/parallel.py",line 833, in dispatch_one_batch

File"/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py",line 839, in def fit(self, X, y=None, **params):

File"/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/utils/fixes.py",line 199, in delayedif axis == 0:

NameError: name 'functools' is not defined


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>