美文网首页
保存/读取特征、模型tricks

保存/读取特征、模型tricks

作者: SimonLiu000 | 来源:发表于2018-09-15 16:34 被阅读6次

    1、特征保存

    import pickle

    data = (x_train, y_train, x_test)

    fp = open('./data_tfidf.pkl', 'wb')

    pickle.dump(data, fp)

    fp.close()

    2、特征读取

    import pickle

    features_path = '*****.pkl'

    fp = open(features_path, 'rb')

    x_train, y_train, x_test = pickle.load(fp)

    fp.close()

    3、模型保存

    from sklearn.externals import joblib

    joblib.dump(lin_clf, "linearsvm_model_Tfid_1.m")

    4、模型读取

    from sklearn.externals import joblib

    svm = joblib.load("linearsvm_model_Tfid_1.m")

    相关文章

      网友评论

          本文标题:保存/读取特征、模型tricks

          本文链接:https://www.haomeiwen.com/subject/yshtnftx.html