`param_grid={'select__k':randint(1,16),
'svc__C':loguniform(1e-4,1e4),
'svc__kernel':['linear','poly','rbf','sigmoid'],
'svc__degree':randint(1,10),
'svc__tol':loguniform(1e-5,1e-1),
'svc__class_weight':[None,'balanced'],
'svc__max_iter':randint(5000,10000),
'svc__decision_function_shape':['ovr','ovo']}
pipeline=Pipeline([('select',SelectKBest()),
('svc',SVC())])
search_svc=RandomizedSearchCV(pipeline,
param_grid,
n_iter=100,
cv=5,
scoring='accuracy',
return_train_score=True,
random_state=32)
search_svc.fit(x_resample, y_resample)
best_estimator = search_svc.best_estimator_
svc_results = cross_val_score(best_estimator, x_resample, y_resample, cv=5, return_train_score=True) print('Train score =', svc_results.mean())`
result:
/usr/local/lib/python3.10/dist-packages/sklearn/svm/_base.py:299: ConvergenceWarning: Solver terminated early (max_iter=9660). Consider pre-processing your data with StandardScaler or MinMaxScaler.
warnings.warn(
hypertuned solver to be runned successfully
New contributor