def main(s):
with open('pipe.dat', 'rb') as fp:
pipe = pickle.load(fp)
这个python代码出错
{
"errorMessage": "Can't get attribute 'tokenize' on <module '__main__' from '/var/runtime/bootstrap'>",
"errorType": "AttributeError",
"stackTrace": [
" File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n",
" File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n module = _load(spec)\n",
" File \"<frozen importlib._bootstrap>\", line 702, in _load\n",
" File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap_external>\", line 783, in exec_module\n",
" File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
" File \"/var/task/hand.py\", line 2, in <module>\n import SentimentModeling\n",
" File \"/var/task/SentimentModeling.py\", line 72, in <module>\n event = main(s)\n",
" File \"/var/task/SentimentModeling.py\", line 37, in main\n pipe = pickle.load(fp)\n"
]
}
我无法处理这些错误。
我制作了关于模块的层:sklearn numpy joblib 使用辣和 numpy(由 lambda 提供)lambda python 和模块的版本是 3.8
并使 pipe.dat 为
pipe = Pipeline([('vect', tfidf), ('cif', logistic)])
pipe.fit(train_x, train_y)
predict_y = pipe.predict(test_x)
print(accuracy_score(test_y, predict_y)*100)
print(classification_report(test_y, predict_y))
with open('pipe.dat', 'wb') as fp:
pickle.dump(pipe, fp)