ValueError:无法将字符串转换为Python的朴素贝叶斯浮点数

时间:2019-12-18 13:30:09

标签: python naivebayes

import pandas as pd
df = pd.read_excel('spam.xlsx', names = ['label', 'sms_message']) #Spam file includes lots of texts
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(df['sms_message'], 
                                                    df['label'], 
                                                    random_state=1)
from sklearn.naive_bayes import MultinomialNB
naive_bayes = MultinomialNB()
naive_bayes.fit(X_train,y_train)

我遇到错误: ValueError:无法将字符串转换为浮点型

那是为什么?我能做什么? 谢谢。

enter image description here

0 个答案:

没有答案