Add comment strings.
This commit is contained in:
Родитель
a20a6941f0
Коммит
7692cf82f2
|
@ -95,10 +95,12 @@
|
||||||
"\n",
|
"\n",
|
||||||
" \n",
|
" \n",
|
||||||
"def score_rank(scores):\n",
|
"def score_rank(scores):\n",
|
||||||
|
" \"\"\"Compute the ranks of the scores.\"\"\"\n",
|
||||||
" return pd.Series(scores).rank(ascending=False)\n",
|
" return pd.Series(scores).rank(ascending=False)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def label_index(label, label_order):\n",
|
"def label_index(label, label_order):\n",
|
||||||
|
" \"\"\"Compute the index of label in label_order.\"\"\"\n",
|
||||||
" loc = np.where(label == label_order)[0]\n",
|
" loc = np.where(label == label_order)[0]\n",
|
||||||
" if loc.shape[0] == 0:\n",
|
" if loc.shape[0] == 0:\n",
|
||||||
" return None\n",
|
" return None\n",
|
||||||
|
@ -106,6 +108,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def label_rank(label, scores, label_order):\n",
|
"def label_rank(label, scores, label_order):\n",
|
||||||
|
" \"\"\"Compute the rank of label using the scores.\"\"\"\n",
|
||||||
" loc = label_index(label, label_order)\n",
|
" loc = label_index(label, label_order)\n",
|
||||||
" if loc is None:\n",
|
" if loc is None:\n",
|
||||||
" return len(scores) + 1\n",
|
" return len(scores) + 1\n",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче