热线电话:13121318867

登录
2018-11-30 阅读量: 936
模型持久化

可以通过使用 Python 的内置持久化模块(即 pickle )将模型保存:

>>>>>> from sklearn import svm 
>>> from sklearn import datasets
>>> clf = svm.SVC()
>>> iris = datasets.load_iris()
>>> X, y = iris.data, iris.target
>>> clf.fit(X, y) SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape='ovr', degree=3, gamma='auto', kernel='rbf', max_iter=-1, probability=False, random_state=None, shrinking=True, tol=0.001, verbose=False)
>>> import pickle
>>> s = pickle.dumps(clf)
>>> clf2 = pickle.loads(s)
>>> clf2.predict(X[0:1]) array([0])
>>> y[0] 0
0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子