Scikit-learn flavor and evaluation
In this exercise you will train a classification model and evaluates its performance. The model uses your Insurance Charges
dataset in order to classify if the charges were for a female or male.
We will start by logging our model to MLflow Tracking using the scikit-learn flavor and finish by evaluating your model using an eval_data
dataset.
Your evaluation dataset is created as eval_data
and our model trained with the name lr_class
. The eval_data
will consist of X_test
and y_test
as the training data was split using train_test_split()
function from sklearn.
# Model
lr_class = LogisticRegression()
lr_class.fit(X_train, y_train)
The mlflow
module is imported.
This exercise is part of the course
Introduction to MLflow
Exercise instructions
- Log the
lr_class
model using scikit-learn "built-in" flavor. - Call the
evaluate()
function frommlflow
module. - Evaluate the
eval_data
dataset and target the"sex"
column.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Eval Data
eval_data = X_test
eval_data["sex"] = y_test
# Log the lr_class model using Scikit-Learn Flavor
___.___.___(____, "model")
# Get run id
run = mlflow.last_active_run()
run_id = run.info.run_id
# Evaluate the logged model with eval_data data
___.___(f"runs:/{run_id}/model",
____=____,
____="____",
model_type="classifier"
)