模型的dump與load

xuxiatian發表於2017-07-24

1. sklearn 參照: http://scikit-learn.org/stable/tutorial/basic/tutorial.html

from sklearn.externals import joblib
joblib.dump(clf, 'filename.pkl') 
clf = joblib.load('filename.pkl') 

以上適合所有sklearn相關的模型,如scaler模型,imputer,以及分類器模型等等。


2. xgboost 參照: http://blog.csdn.net/zc02051126/article/details/46771793

# dump model

bst.dump_model('dump.raw.txt')

# dump model with feature map

bst.dump_model('dump.raw.txt','featmap.txt')

#init model

bst = xgb.Booster({'nthread':4})

#load data

bst.load_model("model.bin")

相關文章