我试图通过Heroku打开Flask应用,但出现此错误:
AttributeError :模块'pickle'没有属性_' Pickler'
我在一个单独的文件中创建了model.pkl
:
model1 = Pipeline([
('CountVectorizer', CountVectorizer()),
('TfidfTransformer', TfidfTransformer()),
('KNeighborsClassifier', KNeighborsClassifier()),
])
model1.fit(traindata_data, traindata_label)
import pickle
pickle.dump(model1, open("model.pkl","wb"))
并从app.py
加载pickle文件:
model = pickle.load(open("./model.pkl","rb"))