![](/img/trans.png)
[英]Best practice to create a live running model from a trained neural network
[英]Best practice to “transport” trained model from sklearn
import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model
# Create linear regression object
regr = linear_model.LinearRegression()
# Train the model using the training sets
regr.fit(X_train, y_train)
# how save ?????
# save here
保存 經過訓練的模型並在其他地方使用的最佳實踐是什么?
sklearn
具有一個joblib
模塊,用於持久保存模型和/或保存到文件:
from sklearn.externals import joblib
joblib.dump(regr, 'file_name.pkl')
# load pickled model later
regr = joblib.load('file_name.pkl')
您還可以使用Python的內置pickle
但是文檔建議使用joblib
來有效地對具有大型numpy
數組的對象進行酸洗。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.