1model.fit(X_train, Y_train)
2# save the model to disk
3filename = 'finalized_model.sav'
4pickle.dump(model, open(filename, 'wb'))
5
6# load the model from disk
7loaded_model = pickle.load(open(filename, 'rb'))
8result = loaded_model.score(X_test, Y_test)
1# save as object
2import pickle
3
4s = pickle.dumps(clf)
5clf2 = pickle.loads(s)
6
7# save to file
8from joblib import dump
9
10dump(clf, 'filename.joblib')
11
12# load from file
13from joblib import load
14
15clf = load('filename.joblib')