Experiment 6.2
Experiment 6.2
nltk
nl tk , OC-,IOCl<l('•t...,..or4• ")
df • pd.l"ead_uw(' / content / ~ O..taut . uw' ,d.-llalter• ' •' ,enc,,.,in1• •lat1n·l ')
<If . II.ad()
G Onecflhe-=·-tiasmenlionedlhat Jl()SitiYe
Z llhoughtthis-sawonderfulwayl>spe,Klti Jl()SitiYe
Basicaltylhere'salamitywtlerealitdeboy negative
S_--.:1 • s t - , l s . .....-.ts("ef11lhh")
Mfclun(•l'
wonclerfullittle
posiwe product""' br br ftlming
tec:11 ...
s ns.countplot(df.slfflli-t)
plt.dabel("sentl.,.t " )
pit.title(",.._ of i.. - •P• • ssa1n")
/u sr/ local / llb/ python3.7/ dlst -pa< ka1n /su born/_Oecor1tor s .py
futurftlarnln1
Tut(8.S, I.I, •...-r of h• and sp• ••ncn")
_..,.cf~-sp¥t'I-~
l-
• CrHttinputandoutpulvttt~
• Pl"ocessthtlabels.
le • tabeltn<odff()
V• le .flt_tran sfono(ctf[ ' •entl.,.t"J)
V•V.rnh-( · l ,l)
Splilinlotrainingandtestdata.
N•_wor-d1 • l -
N•_len • lst
tok • Tol<enlre.-(-_.....-.t,-n_.....-.ts)
tok.flt _on_tuts ( X_traln)
sequences •tol<.tuU_to_sequen<es(X_traln)
sequences_aatrh • pad_•-ces(sequences,.aden•lSI)
print(tol<)
.. RNN
DefinelheRNNstructure
.S.f!UIN() :
Inputs• Input(I\Ne• "inputs',shape•[ N•_ len])
!ayes • f-i"C(N• _wrds,st,lnput_ len1th-a•. len)(lnput 1 )
!ayes• 1STM(6-l)(la.,er)
layer•DenH ( 2S6,I\Ne• "fCl')(layer)
layer •Ac:tivatlon("r-elu")(laytr)
layer•Dropout(8,S)(la.,er )
layer•DenH( l ,I\Ne• ' out_ laytr ' )(layer)
layer• Ac:tivatlon( "slpoid")(layer)
- 1 • -l{lnputs•lnl"JU,outputs•byer)
,..turn-I
Call the fune1iOl'I and compile the model
-el•IIIIN()
-el.s.-..-y()
96,ll7
FitOl'ltheUalningdatt
.___._,__.~ ...
LPIOt • -.1.flt(1eq... ncu_aatrlx,Y_ tr"ain,batch_si u • Ul,tpochs- ll, va lldatlon_,pllt•l.l)
- • l . f l t ( , _ . , U_Ntl"h,Y_tl"a ln,batch_dlt• lll,tpoch•• ll,
I
l pochl/11
lr.6/266 1- - - - -- - 1 SJ• 29911• / step accuracy: 9.78SJ v a l _ lou: 1.3462 val_accuracy·
l pochl/11
2&6/266 1- - - - -- - 1 76• accuracy: 9.8-4S4 v a l _ lou: l.32et val_accuracy·
lpochJ / 11
266/266 [ - - - - -- - ) 10 27. .•/step - • accuracy: 9.ISJ6 - val_lou: 1.3127 - val_accuracy:
1-------1-
Epoch. / 11
n, • accuracy: 9.1614 • v a l _ lou: I.JIIS • val_accuracy:
1-------1-
266/266 21911, / stei, -
EpochS /11
n, • accuracy: 0.161S - nl_lou: I .JIIS - Yal_accuracy:
1-------1-7••
266/266 2-•/stei, -
£poch6/ 11
266/266 2 - • /step · accuracy: 0.11•1 - Vll_ lou: e.Je79 - val_ acc uracy:
£poch7 /11
:~!6:A,----- - -1- 1,. 2...,,nei,. accuracy: 0.1791 - Yll_ lou: e.J21t - val_ acc uracy:
The model pe,rfOfms well Ol'I the validation set and this conf1!1Ufalion is chosen as Ille final model
THl HI
Lou: I.HI
A.ccuracy:1.167