Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Bayesian Optimization with skopt | Hyperparameter Optimization
Introduction to AutoML

bookBayesian Optimization with skopt

Stryg for at vise menuen

Bayesian optimization is a powerful approach for hyperparameter tuning in AutoML. Unlike grid search and random search, which explore hyperparameter spaces without considering past results, Bayesian optimization builds a probabilistic model of the objective function. This model predicts how different hyperparameter combinations will perform and uses that information to select the most promising parameters to try next. By focusing the search on areas likely to yield better results, Bayesian optimization often finds optimal settings with fewer experiments, saving both time and computational resources. This is especially valuable when training models is expensive or time-consuming.

123456789101112131415161718192021222324252627282930
from skopt import BayesSearchCV from sklearn.datasets import load_iris from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split # Load data X, y = load_iris(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) # Define the search space for DecisionTreeClassifier search_space = { 'max_depth': (1, 10), 'min_samples_split': (2, 20), } # Set up Bayesian optimization with BayesSearchCV opt = BayesSearchCV( DecisionTreeClassifier(), search_spaces=search_space, n_iter=20, cv=3, random_state=42 ) # Run optimization opt.fit(X_train, y_train) # Print best parameters print("Best parameters:", opt.best_params_) print("Best cross-validation score: {:.3f}".format(opt.best_score_))
copy
Note
Note

Use bayesian optimization when training your models is computationally expensive or time-consuming. It is more efficient than grid or random search in such scenarios.

question mark

What information does Bayesian optimization use to choose the next set of hyperparameters?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 3

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Sektion 2. Kapitel 3
some-alt