MulaiMulai sekarang secara gratis

Saving and loading a model

With the Model API, models can be shared between developers who may not have access to the same MLflow Tracking server by using a local filesystem.

In this exercise, you will train a new LinearRegression model from an existing one using the Unicorn dataset. First, you will load an existing model from the local filesystem. Then you will train a new model from the existing model and save it back to the local filesystem.

The existing model has been saved to the local filesystem in a directory called "lr_local_v1". The mlflow module will be imported.

Latihan ini adalah bagian dari kursus

Introduction to MLflow

Lihat Kursus

Petunjuk latihan

  • Load the model from the local filesystem directory "lr_local_v1" using scikit-learn library from the MLflow module.
  • Using the scikit-learn library from the mlflow module, save the model locally to a directory called "lr_local_v2".

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Load model from local filesystem
model = ____.____.____("____")

# Training Data
X = df[["R&D Spend", "Administration", "Marketing Spend", "State"]]
y = df[["Profit"]]
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.7,random_state=0)
# Train Model
model.fit(X_train, y_train)

# Save model to local filesystem
____.____.____(____, "____")
Edit dan Jalankan Kode