Jan-29-2023, 08:17 PM
(This post was last modified: Jan-29-2023, 10:39 PM by Yoriz.
Edit Reason: Added code tags
)
The following code generates an error as shown:
sure what is causing the error.
# random search logistic regression model on the sonar dataset from scipy.stats import loguniform from pandas import read_csv from sklearn.linear_model import LogisticRegression from sklearn.model_selection import RepeatedStratifiedKFold from sklearn.model_selection import RandomizedSearchCV # load dataset url = 'https://raw.githubusercontent.com/jbrownlee/Datasets/master/sonar.csv' dataframe = read_csv(url, header=None) # split into input and output elements data = dataframe.values X, y = data[:, :-1], data[:, -1] # define model model = LogisticRegression() # define evaluation cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1) # define search space space = dict() space['solver'] = ['newton-cg', 'lbfgs', 'liblinear'] space['penalty'] = ['none', 'l1', 'l2', 'elasticnet'] space['C'] = loguniform(1e-5, 100) # define search search = RandomizedSearchCV(model, space, n_iter=500, scoring='accuracy', n_jobs=-1, cv=cv, random_st=1) # execute search result = search.fit(X, y) # summarize result print('Best Score: %s' % result.best_score_) print('Best Hyperparameters: %s' % result.best_params_)The error is: now shown:
Error:TypeError Traceback (most recent call last)
Input In [1], in <cell line: 23>()
21 space['C'] = loguniform(1e-5, 100)
22 # define search
---> 23 search = RandomizedSearchCV(model, space, n_iter=500, scoring='accuracy', n_jobs=-1, cv=cv, random_st=1)
24 # execute search
25 result = search.fit(X, y)
TypeError: RandomizedSearchCV.__init__() got an unexpected keyword argument 'random_st'
I am attaching a captured printout of my install modules. I know it has something to do with scikit-learn, but I am notsure what is causing the error.