我正在嘗試使用Textblob做一些文本分類。我首先使用pickle來訓練模型並序列化它,如下所示。Python pickle error:UnicodeDecodeError
import pickle
from textblob.classifiers import NaiveBayesClassifier
with open('sample.csv', 'r') as fp:
cl = NaiveBayesClassifier(fp, format="csv")
f = open('sample_classifier.pickle', 'wb')
pickle.dump(cl, f)
f.close()
,當我嘗試運行此文件:
import pickle
f = open('sample_classifier.pickle', encoding="utf8")
cl = pickle.load(f)
f.close()
我得到這個錯誤:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
以下是我sample.csv的內容:
My SQL is not working correctly at all. This was a wrong choice, SQL
I've issues. Please respond immediately, Support
我在哪裏錯了?請幫忙。
非常感謝!完全合作! – 90abyss