如何为LSTM模型编写预测函数

时间:2019-09-20 03:37:57

标签: keras

https://www.kaggle.com/anunnikrishnan/keras-classifier-based-spam-classification

基于此笔记本,预测功能的外观如何,将一条短信作为测试输入?

sms = " You won a free giftcard "

max_words = 1000
max_len = 150
tok = Tokenizer(num_words=max_words)
tok.fit_on_texts(sms)
sequences = tok.texts_to_sequences(text)
sms_matrix = sequence.pad_sequences(sequences,maxlen=max_len)
prediction = model.predict(sms_matrix)

结果看起来像这样

array([[0.00395709],
       [0.00090399],
       [0.00528631],
       [0.00549346],
       [0.00347543],
       [0.00090399],
       [0.00751105],
       [0.00549346],
       [0.00736764],
       [0.00549346],
       [0.00568002],
       [0.00696304],
       [0.00551164],
       [0.00551164],
       [0.00549346],
       [0.0014942 ],
       [0.00137451],
       [0.00568   ],
       [0.01121344],
       [0.01121931],
       [0.00736762],
       [0.00696306],
       [0.00619166]], dtype=float32)

我在以二进制方式解释这些结果时遇到了麻烦。

0 个答案:

没有答案