This commit is contained in:
Mario Bourgoin 2018-09-18 20:34:15 +00:00
Родитель a20a6941f0
Коммит 7692cf82f2
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -95,10 +95,12 @@
"\n",
" \n",
"def score_rank(scores):\n",
" \"\"\"Compute the ranks of the scores.\"\"\"\n",
" return pd.Series(scores).rank(ascending=False)\n",
"\n",
"\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",
" if loc.shape[0] == 0:\n",
" return None\n",
@ -106,6 +108,7 @@
"\n",
"\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",
" if loc is None:\n",
" return len(scores) + 1\n",