0

## 請問LSTM的predict問題

``````import sklearn
from sklearn.metrics import precision_recall_fscore_support as score
# prediction on test data

predicted_blstm=model.predict(test_data)
predicted_blstm

# model evaluation

from sklearn.metrics import precision_recall_fscore_support as score

precision, recall, fscore, support = score(labels_test, predicted_blstm.round())

print('precision: {}'.format(precision))
print('recall: {}'.format(recall))
print('fscore: {}'.format(fscore))
print('support: {}'.format(support))

print("############################")

print(sklearn.metrics.classification_report(labels_test, predicted_blstm.round()))
``````

### 1 個回答

1
I code so I am
iT邦研究生 3 級 ‧ 2020-06-10 10:06:14

``````new_data=[['dfsdfjdjhfj']]
model.predict(new_data)
``````

Huiicat iT邦新手 5 級 ‧ 2020-06-10 10:16:45 檢舉

``````array([[9.9973804e-01, 2.6198191e-04],
[9.9988401e-01, 1.1600493e-04],
[9.9996233e-01, 3.7628190e-05],
[9.9998081e-01, 1.9162568e-05],
[9.9998498e-01, 1.5043216e-05],
[9.9907982e-01, 9.2014833e-04],
...
[9.9996233e-01, 3.7628190e-05],
[9.9996233e-01, 3.7628190e-05]], dtype=float32)
``````

Huiicat iT邦新手 5 級 ‧ 2020-06-10 15:30:16 檢舉

``````input_text = 'Go until jurong point, crazy.. Available only in bugis n great world la e buffet... Cine there got amore wat...'
input_sent = tokenizer.texts_to_sequences(input_text)
``````print(input_data.shape)