joblib保存模型

# from pickle import dumps
#
# from sklearn import svm
# from sklearn.datasets import load_iris
from sklearn.datasets import load_iris
from sklearn.externals import joblib
# from sklearn.linear_model import LinearRegression
# from sklearn.model_selection import train_test_split
#
from sklearn.model_selection import train_test_split

data = load_iris()
data.target[[10, 25, 50]]

print(list(data.target_names))
X= data.data
y=data.target
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.33, random_state=42)
# svc = svm.SVC()
# # svc =  LinearRegression()
# svc.fit(X_train, y_train)
# predict = svc.predict(X_test)
# joblib.dump(svc, 'filename.pkl')

clf = joblib.load('filename.pkl')
print(clf)
predict = clf.predict(X_test)
print(predict)

你可能感兴趣的:(机器学习)