Computer scienceData scienceInstrumentsScikit-learnMachine Learning with scikit-learn

Hyperparameter search in scikit-learn

Theory

The custom score

Report a typo

Note that this task assumes scikit-learn version 1.4.2

You have the following starter code:

from scipy.stats import loguniform
from sklearn.datasets import load_breast_cancer
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import RandomizedSearchCV
from sklearn.svm import SVC

X, y = load_breast_cancer(return_X_y=True)
scaler = StandardScaler()
X = scaler.fit_transform(X)
kernel = ['linear', 'rbf', 'poly']

Perform randomized hyperparameter search on SVC (read more about SVC), with random_state = 42 (important for reproducing the results), and scoring as the top-k accuracy classification score. Pass loguniform(0.01, 1) to C and gamma (without calling .rvs() on the distribution), and the kernel values from the list to kernel as the parameter distribution of RandomizedSearchCV.

What is the optimal value of gamma, rounded up to the first decimal?

Enter a number
___

Create a free account to access the full topic