我是靠谱客的博主 迅速蛋挞,这篇文章主要介绍逻辑回归:垃圾短信分类,现在分享给大家,希望可以做个参考。

一、垃圾短信

ham Go until jurong point, crazy… Available only in bugis n great world la e buffet… Cine there got amore wat… ham Ok lar… Joking wif u oni…
spam Free entry in 2 a wkly comp to win FA Cup final tkts 21st May 2005. Text FA to 87121 to receive entry question(std txt rate)T&C’s apply 08452810075over18’s
ham U dun say so early hor… U c already then say…
ham Nah I don’t think he goes to usf, he lives around here though
spam FreeMsg Hey there darling it’s been 3 week’s now and no word back! I’d like some fun you up for it still? Tb ok!XxX std chgs to send, £1.50 to rcv
ham Even my brother is not like to speak with me. They treat me like aids patent.
ham As per your request ‘Melle Melle (Oru Minnaminunginte Nurungu Vettam)’ has been set as your callertune for all Callers. Press *9 to copy your friends Callertune
spam WINNER!! As a valued network customer you have been selected to receivea £900 prize reward! To claim call 09061701461. Claim code KL341. Valid 12 hours only.
spam Had your mobile 11 months or more? U R entitled to Update to the latest colour mobiles with camera for Free! Call The Mobile Update Co FREE on 08002986030
ham I’m gonna be home soon and i don’t want to talk about this stuff anymore tonight, k? I’ve cried enough today.
spam SIX chances to win CASH! From 100 to 20,000 pounds txt> CSH11 and send to 87575. Cost 150p/day, 6days, 16+ TsandCs apply Reply HL 4 info
spam URGENT! You have won a 1 week FREE membership in our £100,000 Prize Jackpot! Txt the word: CLAIM to No: 81010 T&C www.dbuk.net LCCLTD POBOX 4403LDNW1A7RW18

二、垃圾短信分类

import pandas as pd
from sklearn import linear_model
from sklearn.feature_extraction.text import TfidfVectorizer

df = pd.read_csv("SMS.txt", delimiter='t', header=None)
y, X_train = df[0], df[1]

vectorizer = TfidVectorizer()
X = vectorizer.fit_transform(X_train)

lr_reg = linear_model.LogisticRegression()
lr_reg.fit(X)

test_X = vectorizer.fit_transform(["URGENT! Your mobile No.1234 was awarded a Prized","Hey honey, whats up?"])

predictions = lr_reg.predict(test_X)
print (predictions)

最后

以上就是迅速蛋挞最近收集整理的关于逻辑回归:垃圾短信分类的全部内容,更多相关逻辑回归内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部