Skip to content

Commit

Permalink
exposes distfunc argument for full_word_similarity_evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
cgpotts committed Apr 8, 2019
1 parent 1d5950a commit c264cc4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hw1_wordsim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1103,14 +1103,18 @@
"metadata": {},
"outputs": [],
"source": [
"def full_word_similarity_evaluation(df, readers=READERS):\n",
"def full_word_similarity_evaluation(df, readers=READERS, distfunc=vsm.cosine):\n",
" \"\"\"Evaluate a VSM against all datasets in `readers`.\n",
" \n",
" Parameters\n",
" ----------\n",
" df : pd.DataFrame\n",
" readers : tuple \n",
" The similarity dataset readers on which to evaluate.\n",
" distfunc : function mapping vector pairs to floats.\n",
" The measure of distance between vectors. Can also be \n",
" `vsm.euclidean`, `vsm.matching`, `vsm.jaccard`, as well as \n",
" any other distance measure between 1d vectors. \n",
" \n",
" Returns\n",
" -------\n",
Expand All @@ -1120,7 +1124,7 @@
" \"\"\" \n",
" scores = {} \n",
" for reader in readers:\n",
" score, data_df = word_similarity_evaluation(reader, df)\n",
" score, data_df = word_similarity_evaluation(reader, df, distfunc=distfunc)\n",
" scores[get_reader_name(reader)] = score\n",
" series = pd.Series(scores, name='Spearman r')\n",
" series['Macro-average'] = series.mean()\n",
Expand Down Expand Up @@ -1150,7 +1154,7 @@
}
],
"source": [
"full_word_similarity_evaluation(giga5)"
"full_word_similarity_evaluation(giga5, distfunc=vsm.cosine)"
]
},
{
Expand Down Expand Up @@ -1363,7 +1367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
},
"widgets": {
"state": {},
Expand Down

0 comments on commit c264cc4

Please sign in to comment.