Python保存模型并对其进行加载
保存模型的具体操作
import cPickle as pickle
output_model_file = 'saved_modle.pkl'
with open(output_model_file, 'w') as f:
pickle.dump(linear_regressor, f)
加载使用模型具体方法
with open(output_model_file, 'r') as f:
model_linregr = pickle.load(f)
y_predict = model_linregr.predict(x_test)