Я построил модель и обучил ее.
Код: Выделить всё
def output_lable(n):
if n == 0:
return "Fake News"
elif n == 1:
return "Real News"
def manual_testing(news):
testing_news = {"text":[news]}
new_def_test = pd.DataFrame(testing_news)
new_def_test["text"] = new_def_test["text"].apply(wordopt)
new_x_test = new_def_test["text"]
new_xv_test = vectorization.transform(new_x_test)
pred_LR = LR.predict(new_xv_test)
pred_DT = DT.predict(new_xv_test)
pred_GBC = GBC.predict(new_xv_test)
pred_RFC = RFC.predict(new_xv_test)
return print("\n\nLR Prediction: {} \nDT Prediction: {} \nGBC Prediction: {} \nRFC Prediction: {}".format(output_lable(pred_LR[0]),
output_lable(pred_DT[0]),
output_lable(pred_GBC[0]),
output_lable(pred_RFC[0])))
Код: Выделить всё
news = str(input())
manual_testing(news)
Код: Выделить всё
pickle.dump(manual_testing,open("model.pkl","wb"))
Код: Выделить всё
model = pickle.load(open("model.pkl","rb"))
print(model.predict(["this is a fake news"])
Код: Выделить всё
AttributeError Traceback (most recent call last)
``` in
1 model = pickle.load(open("model.pkl","rb"))
2 news ="this is a fake"
----> 3 print(model.predict([news]))
AttributeError: 'function' object has no attribute 'predict'