from sklearn.linear_model import LogisticRegression
import numpy as np
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
df= pd.read_csv('SMSSpamCollection.txt',delimiter='\t',header=None)
y,x_train = df[0],df[1]
vectorize = TfidfVectorizer()#向量化
x = vectorize.fit_transform(x_train)# print(x)
lr = LogisticRegression()
lr.fit(x,y)test= vectorize.fit_transform(['I am a good boy.','Yes'])
predict = lr.predict(test)
print(predict)# print(x_train," ",y)