File tree Expand file tree Collapse file tree 1 file changed +4
-23
lines changed Expand file tree Collapse file tree 1 file changed +4
-23
lines changed Original file line number Diff line number Diff line change 1- """
2- This script integrates Comet ML and Optuna to optimize a Random Forest Classifier
3- on the scikit-learn Breast Cancer dataset. It performs the following steps:
4-
5- 1. Initializes a Comet ML experiment for logging.
6- 2. Loads the Breast Cancer dataset and splits it into training and testing sets.
7- 3. Defines an evaluation function using F1-score, precision, and recall.
8- 4. Implements an Optuna objective function to optimize hyperparameters
9- (n_estimators and max_depth) for the Random Forest model.
10- 5. Uses Optuna to run multiple trials and identify the best hyperparameters.
11- 6. Trains the final Random Forest model using the best-found hyperparameters.
12- 7. Logs training and testing metrics to Comet ML.
13-
14- You can run this example as follows:
15- $ python comet_callback.py
16- """
17-
18- import os
19-
201import comet_ml
21- from comet_ml import login
222import optuna
233from optuna_integration .comet import CometCallback
244
3010from sklearn .model_selection import train_test_split
3111
3212
33- # Log the project name
34- experiment .set_name ("comet-optuna-example" )
35-
13+ # Create the experiment first
3614experiment = comet_ml .start (online = False )
3715
16+ # Then set the name
17+ experiment .set_name ("comet-optuna-example" )
18+
3819# Load dataset
3920random_state = 42
4021cancer = load_breast_cancer ()
You can’t perform that action at this time.
0 commit comments