Commits

szp...@gmail.com  committed f9d318c

...

  • Participants
  • Parent commits 1185365

Comments (0)

Files changed (1)

File ca2/Intro_3.ipynb

      "language": "python",
      "metadata": {},
      "outputs": [],
-     "prompt_number": 1
+     "prompt_number": 2
     },
     {
      "cell_type": "code",
      "language": "python",
      "metadata": {},
      "outputs": [],
-     "prompt_number": 2
+     "prompt_number": 3
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "kfold = cross_validation.StratifiedKFold(target, 7)"
+      "cross_validation.StratifiedKFold"
      ],
      "language": "python",
      "metadata": {},
      "outputs": [],
-     "prompt_number": 3
+     "prompt_number": 5
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "kfold = cross_validation.StratifiedKFold(target, 5)"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [],
+     "prompt_number": 4
     },
     {
      "cell_type": "code",
       "    clf = neighbors.KNeighborsClassifier(n_neighbors=3)\n",
       "    clf.fit(Xij_train, Y_train)\n",
       "    S = metrics.precision_score(Y_test, clf.predict(Xij_test))\n",
-      "    info = ((i,j), (Xij_train, Y_train), (Xij_test, Y_test), clf, S)\n",
+      "    info = ((i,j), clf, S)\n",
       "    info_list.append(info)\n",
       "    print S\n",
       "    \n",
        "output_type": "stream",
        "stream": "stdout",
        "text": [
-        "0.909090909091\n",
         "1.0\n",
-        "0.909090909091\n",
-        "0.958333333333\n",
         "1.0\n",
-        "0.958333333333\n",
-        "0.925925925926\n"
+        "0.875\n",
+        "0.969696969697\n",
+        "0.933333333333\n"
        ]
       },
       {
        "output_type": "stream",
        "stream": "stderr",
        "text": [
-        "D:\\Python27\\lib\\site-packages\\scikit_learn-0.12.1-py2.7-win32.egg\\sklearn\\neighbors\\classification.py:131: NeighborsWarning: kneighbors: neighbor k+1 and neighbor k have the same distance: results will be dependent on data order.\n",
+        "c:\\Users\\\u0441\u0442\u0443\u0434\u0435\u043d\u0442\\Python27\\lib\\site-packages\\scikit_learn-0.12.1-py2.7-win32.egg\\sklearn\\neighbors\\classification.py:131: NeighborsWarning: kneighbors: neighbor k+1 and neighbor k have the same distance: results will be dependent on data order.\n",
         "  neigh_dist, neigh_ind = self.kneighbors(X)\n"
        ]
       }
      ],
-     "prompt_number": 4
+     "prompt_number": 6
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
       "def find_best_clf(i, j):\n",
-      "    kfold = cross_validation.StratifiedKFold(target, 7)    \n",
+      "    kfold = cross_validation.StratifiedKFold(target, 5)    \n",
       "    info_list = []\n",
       "    for train, test in kfold:\n",
       "        X_train = data[train]\n",
       "        Xij_train = np.c_[X_train[:, i], X_train[:, j]]\n",
       "        Xij_test = np.c_[data[:, i], data[:, j]]\n",
       "        Y_test = target\n",
-      "        clf = neighbors.KNeighborsClassifier(n_neighbors=5, weights='distance')\n",
+      "        clf = neighbors.KNeighborsClassifier(n_neighbors=3, weights='distance')\n",
       "        clf.fit(Xij_train, Y_train)\n",
       "        S = metrics.precision_score(Y_test, clf.predict(Xij_test))\n",
       "        info = (S, clf)\n",
      "language": "python",
      "metadata": {},
      "outputs": [],
-     "prompt_number": 23
+     "prompt_number": 8
     },
     {
      "cell_type": "code",
      "language": "python",
      "metadata": {},
      "outputs": [],
-     "prompt_number": 24
+     "prompt_number": 9
     },
     {
      "cell_type": "code",
        "output_type": "stream",
        "stream": "stdout",
        "text": [
-        "[0.92159294474300679, 0.92708333333333337, 0.99346405228758161, 0.99346405228758161, 0.97530864197530864, 0.97530864197530864, 0.98113207547169812, 0.98666666666666669, 0.98113207547169812, 0.98113207547169812, 0.98717948717948734, 0.98717948717948734]\n",
+        "[0.9078131459280695, 0.92040598290598308, 0.99346405228758161, 0.99346405228758161, 0.97382478632478642, 0.97530864197530864, 0.98113207547169812, 0.98113207547169812, 0.98012538348672795, 0.98113207547169812, 0.98666666666666669, 0.98717948717948734]\n",
         "[(0, 1), (0, 1), (0, 2), (0, 2), (0, 3), (0, 3), (1, 2), (1, 2), (1, 3), (1, 3), (2, 3), (2, 3)]\n"
        ]
       }
      ],
-     "prompt_number": 25
+     "prompt_number": 10
     },
     {
      "cell_type": "code",