Skip to content

Commit

Permalink
Merge pull request #532 from dwvisser/some-small-notebook-improvements
Browse files Browse the repository at this point in the history
document similarity notebook: Remove unneeded imports, fix set_option call, remove unneeded list construction
  • Loading branch information
amaiya authored Jul 9, 2024
2 parents 59c876a + 329a2bb commit fdbeda6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions examples/text/20newsgroups-document_similarity_scorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fdbeda6

Please sign in to comment.