Saving & Loading Models
Often times you may find yourself going back to a previous model to see what assumptions or settings were used when diagnosing where your prediction errors were coming from. Perhaps there was something wrong with the data? Maybe you need to incorporate a new feature to capture an unusual event that occurred?
In this example, you will practice saving and loading a model.
This exercise is part of the course
Feature Engineering with PySpark
Exercise instructions
- Import
RandomForestRegressionModel
frompyspark.ml.regression
. - Using the model in memory called
model
call thesave()
method on it and name the modelrfr_no_listprice
. - Reload the saved model file
rfr_no_listprice
by callingload()
onRandomForestRegressionModel
and storing it intoloaded_model
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
from ____ import ____
# Save model
model.____(____)
# Load model
loaded_model = ____.____(____)