From feb5e7d20152e7af914838273c3beba517aa05f7 Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Sat, 8 Oct 2022 13:37:51 +0530 Subject: [PATCH] predict function --- FakeNewsClassifierUsingBidirectionalLSTM.ipynb | 13 ++++++++----- FakeNewsClassifierUsingLSTM.ipynb | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/FakeNewsClassifierUsingBidirectionalLSTM.ipynb b/FakeNewsClassifierUsingBidirectionalLSTM.ipynb index d9fb73f..cf3b8aa 100644 --- a/FakeNewsClassifierUsingBidirectionalLSTM.ipynb +++ b/FakeNewsClassifierUsingBidirectionalLSTM.ipynb @@ -21527,8 +21527,8 @@ "metadata": {}, "outputs": [], "source": [ - "\n", - "y_pred1=model1.predict_classes(X_test)" + "#y_pred=model.predict_classes(X_test)\n", + "y_pred=model.predict(X_test)" ] }, { @@ -21536,7 +21536,10 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# We get the probablity,so using 0.5 as threshold\n", + "y_pred = np.where(y_pred > 0.5, 1,0)" + ] }, { "cell_type": "code", @@ -21625,7 +21628,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -21639,7 +21642,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "version": "3.10.5" } }, "nbformat": 4, diff --git a/FakeNewsClassifierUsingLSTM.ipynb b/FakeNewsClassifierUsingLSTM.ipynb index eb0b69f..a87e9d7 100644 --- a/FakeNewsClassifierUsingLSTM.ipynb +++ b/FakeNewsClassifierUsingLSTM.ipynb @@ -21480,7 +21480,18 @@ "metadata": {}, "outputs": [], "source": [ - "y_pred=model.predict_classes(X_test)" + "#y_pred=model.predict_classes(X_test)\n", + "y_pred=model.predict(X_test)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# We get the probablity,so using 0.5 as threshold\n", + "y_pred = np.where(y_pred > 0.5, 1,0)" ] }, { @@ -21544,7 +21555,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -21558,7 +21569,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.10.5" } }, "nbformat": 4,