[go: nahoru, domu]

Skip to content

Commit

Permalink
Change pract
Browse files Browse the repository at this point in the history
  • Loading branch information
Всеволод Викулин authored and Всеволод Викулин committed Nov 16, 2018
1 parent fa09597 commit 0fe58cf
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions 2018-09/lecture_08_em/lecture_em-pract.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand Down Expand Up @@ -258,17 +260,7 @@
" return -- словарь {кластер : метка для данного кластера} \n",
" \"\"\"\n",
" cluster_predicts = {}\n",
" for new_cluster in set(clusters):\n",
" cluster_data = clusters[clusters == new_cluster]\n",
" labels_data = labels[clusters == new_cluster]\n",
" best_label = None\n",
" best_count = -1\n",
" for new_label in set(labels):\n",
" new_count = sum( labels_data == new_label )\n",
" if new_count > best_count:\n",
" best_count = new_count\n",
" best_label = new_label\n",
" cluster_predicts[new_cluster] = best_label\n",
"\n",
" return cluster_predicts\n",
"\n",
"\n",
Expand All @@ -286,7 +278,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Проименовываем кластера\n",
Expand Down

0 comments on commit 0fe58cf

Please sign in to comment.