I am getting a type error if I run this code twice or multiple times. That means if I run it once, it won’t show any error but if i run it multiple times it will an show error.
Some parts of the code;
param_g= {'alpha':[0.001,0.01,0.1,2.0,4.0,16.0,100]} Gridsearch=GridSearchCV(estimator=Ridge(),param_grid=param_g,scoring="r2") Gridsearch.fit(X,y) Gridsearch.best_params_
`
#the code below is the one generating the error
ridge=Ridge(alpha=2) cross_val_score=cross_val_score(ridge,X.values,y.values,scoring="r2", cv=kf,n_jobs=-1)
#this is the error the code is generating,
`TypeError Traceback (most recent call last)
Cell In[20], line 2
1 ridge=Ridge(alpha=2)
—-> 2 cross_val_score=cross_val_score(ridge,X.values,y.values,scoring=”r2″, cv=kf,n_jobs=-1)
TypeError: ‘numpy.ndarray’ object is not callable`
#please I need help
i am not expecting any error. I use similar codes in another project and it works smooth . I use cross_val_score to get better result
David is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.