Adding parameters to MLproject
Defining parameters in MLflow Projects allows you to make your ML code reproducible. Parameters also simplify running training experiments with different settings without having to change code.
In this exercise, you are going to add parameters to your MLproject
file for the main entry point. This entry point is used to run the train_model.py
script which trains a Logistic Regression model from Insurance data.
The script accepts two parameters, n_jobs
and fit_intercept
, which are hyperparameters used to train the model. You will begin by adding the n_jobs
parameter in the MLproject
file. You will then add the fit_intercept
parameter. Finally, you will add the parameters to the command executed in the main entry point.
This exercise is part of the course
Introduction to MLflow
Exercise instructions
- Create a parameter called
n_jobs
as a typeint
and a default value of1
. - Create a second parameter called
fit_intercept
as a typebool
with a default value set toTrue
. - Pass both parameters into the command ensuring that
n_jobs
is the first followed byfit_intercept
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
"""
name: insurance_model
python_env: python_env.yaml
entry_points:
main:
parameters:
# Create parameter for number of jobs as n_jobs
____:
____: ____
____: ____
# Create parameter for fit_intercept
____:
____: ____
____: ____
# Add parameters to be passed into the command
command: "python3.9 train_model.py {____} {____}"
"""