Recipe 6-3. Next Word Prediction

本节将建立一个LSTM模型,从电子邮件数据中学习单词序列,用于预测下一个单词。通过处理数据,包括去除不需要的行并转为小写,分词,创建单词索引,决定句子长度,生成模型数据,建立LSTM模型,加载权重,并生成随机序列进行预测。
摘要由CSDN通过智能技术生成

in this section, we will build an LSTM model to learn sequences of words
from email data. We will use this model to predict the next word.

file_content = pd.read_csv(‘spam.csv’, encoding = “ISO-8859-1”)
#Just selecting emails and connverting it into list
Email_Data = file_content[[ ‘v2’]]
list_data = Email_Data.values.tolist()
list_data
#output
[[ ‘Go until jurong point, crazy… Available only in bugis n
great world la e buffet… Cine there got amore wat…’],
[‘Ok lar… Joking wif u oni…’],
[ “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”],
[‘U dun say so early hor… U c already then say…’],
[“Nah I don’t think he goes to usf, he lives around here though”],
[" 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"],
[’ Even my brother is not like to speak with me. They treat me
like aids patent.’],
[" 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"],
Chapter 6 Deep Learning for nLp
221
[ ‘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.’] ,
[ ‘Had your mobile 11 months or more? U R entitled to Update
to the latest colour mobiles with camera

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值