<commit_before><commit_msg>Updated pgmpy notebook<commit_after>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting pgmpy\n",
      "  Downloading pgmpy-0.1.2.tar.gz (147kB)\n",
      "\u001b[K    100% |████████████████████████████████| 153kB 5.9MB/s \n",
      "\u001b[?25hRequirement already satisfied (use --upgrade to upgrade): networkx>=1.8.1 in /opt/conda/lib/python3.5/site-packages (from pgmpy)\n",
      "Requirement already satisfied (use --upgrade to upgrade): scipy>=0.12.1 in /opt/conda/lib/python3.5/site-packages (from pgmpy)\n",
      "Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /opt/conda/lib/python3.5/site-packages (from pgmpy)\n",
      "Requirement already satisfied (use --upgrade to upgrade): nose>=1.3.0 in /opt/conda/lib/python3.5/site-packages (from pgmpy)\n",
      "Collecting coveralls>=0.4 (from pgmpy)\n",
      "  Downloading coveralls-1.1-py2.py3-none-any.whl\n",
      "Requirement already satisfied (use --upgrade to upgrade): decorator>=3.4.0 in /opt/conda/lib/python3.5/site-packages (from networkx>=1.8.1->pgmpy)\n",
      "Collecting docopt>=0.6.1 (from coveralls>=0.4->pgmpy)\n",
      "  Downloading docopt-0.6.2.tar.gz\n",
      "Collecting coverage>=3.6 (from coveralls>=0.4->pgmpy)\n",
      "  Downloading coverage-4.3.4-cp35-cp35m-manylinux1_x86_64.whl (191kB)\n",
      "\u001b[K    100% |████████████████████████████████| 194kB 4.7MB/s \n",
      "\u001b[?25hRequirement already satisfied (use --upgrade to upgrade): requests>=1.0.0 in /opt/conda/lib/python3.5/site-packages (from coveralls>=0.4->pgmpy)\n",
      "Building wheels for collected packages: pgmpy, docopt\n",
      "  Running setup.py bdist_wheel for pgmpy ... \u001b[?25l-\b \b\\\b \b|\b \bdone\n",
      "\u001b[?25h  Stored in directory: /home/jovyan/.cache/pip/wheels/d3/21/0f/5b1fc282ee2ab16b693c1a0ed9cb8fde44dbaa28d907c90ff4\n",
      "  Running setup.py bdist_wheel for docopt ... \u001b[?25l-\b \b\\\b \bdone\n",
      "\u001b[?25h  Stored in directory: /home/jovyan/.cache/pip/wheels/b2/16/5f/c33a2bb5f2dce71205f8e65cbfd05647d79d441282be31fd82\n",
      "Successfully built pgmpy docopt\n",
      "Installing collected packages: docopt, coverage, coveralls, pgmpy\n",
      "Successfully installed coverage-4.3.4 coveralls-1.1 docopt-0.6.2 pgmpy-0.1.2\n",
      "\u001b[33mYou are using pip version 8.1.2, however version 9.0.1 is available.\n",
      "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install pgmpy\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from pgmpy.factors import TabularCPD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><caption>TabularCPD for <b>G</b></caption><tr><td><b>D</b></td><td colspan=2>D_0</td><td colspan=2>D_1</td></tr><tr><td><b>I</b></td><td colspan=1>I_0</td><td colspan=1>I_1</td><td colspan=1>I_0</td><td colspan=1>I_1</td></tr><tr><td><b>G_0</b></td><td>0.3000</td><td>0.0500</td><td>0.9000</td><td>0.5000</td></tr><tr><td><b>G_1</b></td><td>0.4000</td><td>0.2500</td><td>0.0800</td><td>0.3000</td></tr><tr><td><b>G_2</b></td><td>0.3000</td><td>0.7000</td><td>0.0200</td><td>0.2000</td></tr></table>"
      ],
      "text/plain": [
       "<TabularCPD representing P(G:3 | I:2, D:2) at 0x7f46064bf4e0>"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Declare a CPD \n",
    "grade_cpd = TabularCPD(variable=\"G\",\n",
    "    variable_card=3,\n",
    "    values=[[0.3, 0.05, 0.9, 0.5],\n",
    "    [0.4, 0.25, 0.08, 0.3],\n",
    "    [0.3, 0.7, 0.02, 0.2]],\n",
    "    evidence=[\"I\", \"D\"],\n",
    "    evidence_card=[2, 2])\n",
    "grade_cpd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><caption>TabularCPD for <b>G</b></caption><tr><td><b>D</b></td><td colspan=2>D_0</td><td colspan=2>D_1</td></tr><tr><td><b>I</b></td><td colspan=1>I_0</td><td colspan=1>I_1</td><td colspan=1>I_0</td><td colspan=1>I_1</td></tr><tr><td><b>G_0</b></td><td>0.3000</td><td>0.0500</td><td>0.9000</td><td>0.5000</td></tr><tr><td><b>G_1</b></td><td>0.4000</td><td>0.2500</td><td>0.0800</td><td>0.3000</td></tr><tr><td><b>G_2</b></td><td>0.3000</td><td>0.7000</td><td>0.0200</td><td>0.2000</td></tr></table>"
      ],
      "text/plain": [
       "<TabularCPD representing P(G:3 | I:2, D:2) at 0x7f4634125eb8>"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Declare the sudent model in pgmpy\n",
    "\n",
    "from pgmpy.models import BayesianModel\n",
    "from pgmpy.factors import TabularCPD\n",
    "\n",
    "# Define nodes and edges\n",
    "student_model = BayesianModel([(\"D\", \"G\"),\n",
    "(\"I\", \"G\"),\n",
    "(\"G\", \"L\"),\n",
    "(\"I\", \"S\")])\n",
    "\n",
    "#Define CPDs\n",
    "\n",
    "grade_cpd = TabularCPD(\n",
    "variable=\"G\",\n",
    "variable_card=3,\n",
    "values=[[0.3, 0.05, 0.9, 0.5],\n",
    "[0.4, 0.25, 0.08, 0.3],\n",
    "[0.3, 0.7, 0.02, 0.2]],\n",
    "evidence=[\"I\", \"D\"],\n",
    "evidence_card=[2, 2])\n",
    "\n",
    "difficulty_cpd = TabularCPD(\n",
    "variable=\"D\",\n",
    "variable_card=2,\n",
    "values=[[0.6, 0.4]])\n",
    "\n",
    "intel_cpd = TabularCPD(\n",
    "variable=\"I\",\n",
    "variable_card=2,\n",
    "values=[[0.7, 0.3]])\n",
    "\n",
    "letter_cpd = TabularCPD(\n",
    "variable=\"L\",\n",
    "variable_card=2,\n",
    "values=[[0.1, 0.4, 0.99],\n",
    "[0.9, 0.6, 0.01]],\n",
    "evidence=[\"G\"],\n",
    "evidence_card=[3])\n",
    "\n",
    "sat_cpd = TabularCPD(\n",
    "variable=\"S\",\n",
    "variable_card=2,\n",
    "values=[[0.95, 0.2],\n",
    "[0.05, 0.8]],\n",
    "evidence=[\"I\"],\n",
    "evidence_card=[2])\n",
    "\n",
    "\n",
    "#Add CPDs to nodes and edges\n",
    "student_model.add_cpds(grade_cpd, difficulty_cpd,\n",
    "intel_cpd, letter_cpd,\n",
    "sat_cpd)\n",
    "\n",
    "grade_cpd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><caption>TabularCPD for <b>G</b></caption><tr><td><b>D</b></td><td colspan=2>D_0</td><td colspan=2>D_1</td></tr><tr><td><b>I</b></td><td colspan=1>I_0</td><td colspan=1>I_1</td><td colspan=1>I_0</td><td colspan=1>I_1</td></tr><tr><td><b>G_0</b></td><td>0.3000</td><td>0.0500</td><td>0.9000</td><td>0.5000</td></tr><tr><td><b>G_1</b></td><td>0.4000</td><td>0.2500</td><td>0.0800</td><td>0.3000</td></tr><tr><td><b>G_2</b></td><td>0.3000</td><td>0.7000</td><td>0.0200</td><td>0.2000</td></tr></table>"
      ],
      "text/plain": [
       "<TabularCPD representing P(G:3 | I:2, D:2) at 0x7f4634125eb8>"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "student_model.get_cpds('G')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['D', 'I']"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "student_model.get_parents('G')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "╒═════╤══════════╕\n",
      "│ G   │   phi(G) │\n",
      "╞═════╪══════════╡\n",
      "│ G_0 │   0.4470 │\n",
      "├─────┼──────────┤\n",
      "│ G_1 │   0.2714 │\n",
      "├─────┼──────────┤\n",
      "│ G_2 │   0.2816 │\n",
      "╘═════╧══════════╛\n"
     ]
    }
   ],
   "source": [
    "from pgmpy.inference import VariableElimination\n",
    "\n",
    "student_infer = VariableElimination(student_model)\n",
    "\n",
    "prob_G = student_infer.query(variables='G')\n",
    "\n",
    "print(prob_G['G'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "╒═════╤══════════╕\n",
      "│ G   │   phi(G) │\n",
      "╞═════╪══════════╡\n",
      "│ G_0 │   0.0500 │\n",
      "├─────┼──────────┤\n",
      "│ G_1 │   0.2500 │\n",
      "├─────┼──────────┤\n",
      "│ G_2 │   0.7000 │\n",
      "╘═════╧══════════╛\n"
     ]
    }
   ],
   "source": [
    "prob_G = student_infer.query(variables='G', evidence={'I': 1, 'D' : 0})\n",
    "\n",
    "print(prob_G['G'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "╒═════╤══════════╕\n",
      "│ G   │   phi(G) │\n",
      "╞═════╪══════════╡\n",
      "│ G_0 │   0.9000 │\n",
      "├─────┼──────────┤\n",
      "│ G_1 │   0.0800 │\n",
      "├─────┼──────────┤\n",
      "│ G_2 │   0.0200 │\n",
      "╘═════╧══════════╛\n"
     ]
    }
   ],
   "source": [
    "prob_G = student_infer.query(variables='G', evidence={'I': 0, 'D' : 1})\n",
    "\n",
    "print(prob_G['G'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     D  I  G  L  S\n",
      "0    0  1  1  1  1\n",
      "1    0  0  0  0  1\n",
      "2    0  1  1  0  0\n",
      "3    0  0  0  0  1\n",
      "4    1  1  0  1  1\n",
      "5    1  0  0  0  0\n",
      "6    1  1  0  1  1\n",
      "7    1  0  0  0  1\n",
      "8    1  1  0  0  1\n",
      "9    1  0  0  0  0\n",
      "10   1  1  1  1  0\n",
      "11   1  1  0  0  0\n",
      "12   1  1  1  1  0\n",
      "13   1  0  0  1  1\n",
      "14   0  1  1  1  1\n",
      "15   1  0  0  1  1\n",
      "16   1  1  0  1  1\n",
      "17   0  0  0  1  0\n",
      "18   0  0  0  0  0\n",
      "19   1  1  1  1  1\n",
      "20   0  0  0  1  1\n",
      "21   0  0  0  0  0\n",
      "22   0  0  1  0  0\n",
      "23   0  0  0  1  0\n",
      "24   0  0  1  1  1\n",
      "25   1  0  1  1  1\n",
      "26   0  1  1  1  0\n",
      "27   0  1  0  0  1\n",
      "28   1  1  0  0  1\n",
      "29   1  0  0  0  0\n",
      "..  .. .. .. .. ..\n",
      "720  1  1  1  0  1\n",
      "721  0  0  1  1  1\n",
      "722  1  1  1  0  1\n",
      "723  1  0  0  0  0\n",
      "724  1  0  0  1  1\n",
      "725  0  0  1  1  1\n",
      "726  0  0  1  0  1\n",
      "727  0  0  1  0  0\n",
      "728  1  1  1  0  0\n",
      "729  1  1  0  0  0\n",
      "730  0  0  0  0  0\n",
      "731  1  1  1  0  0\n",
      "732  0  0  1  0  1\n",
      "733  1  1  0  1  0\n",
      "734  0  1  0  1  1\n",
      "735  0  1  1  1  0\n",
      "736  1  0  1  0  0\n",
      "737  1  1  1  1  0\n",
      "738  1  1  1  1  1\n",
      "739  0  1  1  0  0\n",
      "740  1  1  1  1  1\n",
      "741  1  0  1  1  0\n",
      "742  0  1  1  0  1\n",
      "743  1  0  1  1  0\n",
      "744  0  1  1  1  1\n",
      "745  1  0  0  0  1\n",
      "746  1  0  0  1  0\n",
      "747  0  1  1  0  1\n",
      "748  1  0  0  1  1\n",
      "749  0  0  1  1  1\n",
      "\n",
      "[750 rows x 5 columns]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table><caption>TabularCPD for <b>D</b></caption><tr><td><b>D_0</b></td><td>0.4400</td></tr><tr><td><b>D_1</b></td><td>0.5600</td></tr></table>"
      ],
      "text/plain": [
       "<TabularCPD representing P(D:2) at 0x7f46064bf2b0>"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Train Model from Data\n",
    "\n",
    "from pgmpy.models import BayesianModel\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "# Considering that each variable have only 2 states,\n",
    "# we can generate some random data.\n",
    "\n",
    "raw_data = np.random.randint(low=0,high=2,size=(1000, 5))\n",
    "\n",
    "\n",
    "data = pd.DataFrame(raw_data,columns=[\"D\", \"I\", \"G\",\"L\", \"S\"])\n",
    "\n",
    "print(data[: int(data.shape[0]*0.75)])\n",
    "\n",
    "data_train = data[: int(data.shape[0] * 0.75)]\n",
    "\n",
    "student_model = BayesianModel([(\"D\", \"G\"),(\"I\", \"G\"),(\"I\", \"S\"),(\"G\", \"L\")])\n",
    "student_model.fit(data_train)\n",
    "student_model.get_cpds('D')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><caption>TabularCPD for <b>L</b></caption><tr><td><b>G</b></td><td colspan=1>G_0</td><td colspan=1>G_1</td></tr><tr><td><b>L_0</b></td><td>0.4545</td><td>0.5000</td></tr><tr><td><b>L_1</b></td><td>0.5455</td><td>0.5000</td></tr></table>"
      ],
      "text/plain": [
       "<TabularCPD representing P(L:2 | G:2) at 0x7f4606513080>"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "student_model.get_cpds('L')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'D', 'G', 'L'}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "student_model.active_trail_nodes('D')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(G _|_ S | D, I)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "student_model.local_independencies('G')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(G _|_ L, I, S | D)\n",
       "(G _|_ L, I, D | S)\n",
       "(G _|_ I, S, D | L)\n",
       "(G _|_ L, D | I)\n",
       "(D _|_ I, S | G)\n",
       "(D _|_ G, L | S)\n",
       "(D _|_ G, I, S | L)\n",
       "(D _|_ G, L | I)\n",
       "(S _|_ I, D | G)\n",
       "(S _|_ G, I, L | D)\n",
       "(S _|_ G, I, D | L)\n",
       "(L _|_ G, I, S | D)\n",
       "(L _|_ G, I, D | S)\n",
       "(L _|_ G, D | I)\n",
       "(I _|_ D, S | G)\n",
       "(I _|_ G, S, L | D)\n",
       "(I _|_ G, L | S)\n",
       "(I _|_ G, D, S | L)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "student_model.get_independencies()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.5/site-packages/ipykernel/__main__.py:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  app.launch_new_instance()\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>G</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>750</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>751</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>753</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>754</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>755</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>756</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>757</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>758</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>759</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>760</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>761</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>762</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>763</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>764</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>765</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>766</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>767</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>768</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>769</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>770</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>771</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>772</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>773</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>774</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>775</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>776</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>777</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>778</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>779</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>970</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>971</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>972</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>973</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>974</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>975</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>976</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>977</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>978</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>979</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>980</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>981</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>982</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>983</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>984</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>985</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>986</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>987</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>988</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>989</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>990</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>991</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>992</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>993</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>994</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>250 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     G\n",
       "750  1\n",
       "751  0\n",
       "752  0\n",
       "753  0\n",
       "754  0\n",
       "755  0\n",
       "756  0\n",
       "757  1\n",
       "758  0\n",
       "759  1\n",
       "760  0\n",
       "761  0\n",
       "762  1\n",
       "763  1\n",
       "764  0\n",
       "765  1\n",
       "766  1\n",
       "767  0\n",
       "768  0\n",
       "769  1\n",
       "770  1\n",
       "771  1\n",
       "772  0\n",
       "773  1\n",
       "774  1\n",
       "775  0\n",
       "776  1\n",
       "777  1\n",
       "778  0\n",
       "779  0\n",
       "..  ..\n",
       "970  1\n",
       "971  0\n",
       "972  1\n",
       "973  1\n",
       "974  1\n",
       "975  0\n",
       "976  1\n",
       "977  0\n",
       "978  1\n",
       "979  1\n",
       "980  1\n",
       "981  1\n",
       "982  1\n",
       "983  0\n",
       "984  1\n",
       "985  1\n",
       "986  1\n",
       "987  0\n",
       "988  0\n",
       "989  1\n",
       "990  0\n",
       "991  0\n",
       "992  0\n",
       "993  0\n",
       "994  0\n",
       "995  1\n",
       "996  1\n",
       "997  1\n",
       "998  0\n",
       "999  0\n",
       "\n",
       "[250 rows x 1 columns]"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_test = data[int(0.75 * data.shape[0]) : data.shape[0]]\n",
    "\n",
    "data_test.drop('G', axis=1, inplace=True)\n",
    "\n",
    "student_model.predict(data_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
{'fraction_non_alphanumeric': 0.26284301212507977, 'fraction_numerical': 0.06840299936183791, 'mean_word_length': 1.4876475840857228, 'pattern_counts': {'":': 200, '<': 664, '<?xml version=': 0, '>': 681, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6053002', 'n_tokens_mistral': 11917, 'n_tokens_neox': 11073, 'n_words': 1750}