Skip to content

Development version

You are reading the latest (dev) docs. For the stable version, see 0.13.

MLflow API

python
from sklearn_genetic.mlflow_log import MLflowConfig

Requires MLflow: pip install sklearn-genetic-opt[mlflow].

MLflowConfig

Configures MLflow logging for a GASearchCV or GAFeatureSelectionCV run. Pass an instance to the log_config parameter of the search estimator.

Each call to fit creates:

  • One parent run for the full search (with run_name and tags)
  • One child run per evaluated candidate (with parameters and CV score)
python
MLflowConfig(
    tracking_uri,
    experiment,
    run_name,
    save_models=False,
    registry_uri=None,
    tags=None,
)

Parameters

ParameterTypeDefaultDescription
tracking_uristrAddress of the MLflow tracking server (e.g., "http://localhost:5000")
experimentstrName of the MLflow experiment. Created if it doesn't exist
run_namestrName for the parent run (stored as a mlflow.runName tag)
save_modelsboolFalseLog the fitted estimator as an artifact for each candidate run
registry_uristrNoneAddress of the MLflow model registry server
tagsdictNoneDictionary of tag name → value applied to the parent run

Usage

python
from sklearn_genetic.mlflow_log import MLflowConfig

mlflow_config = MLflowConfig(
    tracking_uri="http://localhost:5000",
    experiment="my-experiment",
    run_name="RF hyperparameter search",
    save_models=True,
    tags={"team": "ml", "dataset": "breast_cancer"},
)

search = GASearchCV(
    estimator=your_estimator,
    param_grid=your_param_grid,
    cv=your_cv,
    scoring="roc_auc",
    evolution_config=...,
    log_config=mlflow_config,  # <-- pass here
)

search.fit(X_train, y_train)

See Also

Released under the MIT License.