IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Introduction to MLflow

Visualizza il corso

Istruzioni dell'esercizio

  • Create a parameter called n_jobs as a type int and a default value of 1.
  • Create a second parameter called fit_intercept as a type bool with a default value set to True.
  • Pass both parameters into the command ensuring that n_jobs is the first followed by fit_intercept.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

"""
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 {____} {____}"
"""
Modifica ed esegui il codice