From 329a2bb707d30e460f2aebd52a618b7d59ccc198 Mon Sep 17 00:00:00 2001 From: Dale Visser Date: Thu, 20 Jun 2024 12:02:32 -0400 Subject: [PATCH] document similarity notebook: Remove unneeded imports, fix set_option call, remove unneeded list construction --- .../text/20newsgroups-document_similarity_scorer.ipynb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/text/20newsgroups-document_similarity_scorer.ipynb b/examples/text/20newsgroups-document_similarity_scorer.ipynb index d62dccde9..6e539939d 100644 --- a/examples/text/20newsgroups-document_similarity_scorer.ipynb +++ b/examples/text/20newsgroups-document_similarity_scorer.ipynb @@ -9,10 +9,8 @@ "%reload_ext autoreload\n", "%autoreload 2\n", "%matplotlib inline\n", - "import os\n", - "import numpy as np\n", "import pandas as pd\n", - "pd.set_option('display.max_colwidth', -1)" + "pd.set_option('display.max_colwidth', None)" ] }, { @@ -402,7 +400,7 @@ "source": [ "# display results in Pandas dataframe\n", "other_preds = [int(score > 0) for score in other_scores]\n", - "data = sorted(list(zip(other_preds, other_scores, other_texts)), key=lambda item:item[1], reverse=True)\n", + "data = sorted(zip(other_preds, other_scores, other_texts), key=lambda item:item[1], reverse=True)\n", "print('Top Inliers (or Most Similar to Our Technology-Related Topics')\n", "print('\\t\\tNumber of Predicted Inliners: %s' % sum(other_preds))\n", "df = pd.DataFrame(data, columns=['Prediction', 'Score', 'Text'])\n", @@ -841,7 +839,7 @@ "\n", "# display results in Pandas dataframe\n", "other_preds = [int(score > 0) for score in other_scores]\n", - "data = sorted(list(zip(other_preds, other_scores, other_texts)), key=lambda item:item[1], reverse=True)\n", + "data = sorted(zip(other_preds, other_scores, other_texts), key=lambda item:item[1], reverse=True)\n", "print('Top Inliers (or Most Similar to Our Technology-Related Topics')\n", "print('\\t\\tNumber of Predicted Inliners: %s' % sum(other_preds))\n", "df = pd.DataFrame(data, columns=['Prediction', 'Score', 'Text'])\n",