Skip to content

Commit fec039c

Browse files
committed
make style.
1 parent 580a35b commit fec039c

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

comet/comet_callback.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
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-
201
import comet_ml
21-
from comet_ml import login
222
import optuna
233
from optuna_integration.comet import CometCallback
244

@@ -30,11 +10,12 @@
3010
from 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
3614
experiment = comet_ml.start(online=False)
3715

16+
# Then set the name
17+
experiment.set_name("comet-optuna-example")
18+
3819
# Load dataset
3920
random_state = 42
4021
cancer = load_breast_cancer()

0 commit comments

Comments
 (0)