├── Naive bayes ├── Naive Bayes in scikit learn.ipynb ├── Naive Bayes in scratch and also in scikit learn.ipynb ├── images │ ├── bay1.png │ ├── bayes.PNG │ ├── coef.PNG │ ├── coeff.PNG │ ├── cov.PNG │ ├── euc.PNG │ ├── eucc.PNG │ ├── g.PNG │ ├── gd.PNG │ ├── gdd.PNG │ ├── gg.PNG │ ├── h.PNG │ ├── lin.PNG │ ├── linn.PNG │ ├── log1.png │ ├── mul.PNG │ ├── mult.PNG │ ├── outcome0.PNG │ ├── outcome1.PNG │ └── ss.PNG └── pima-indians-diabetes.data.csv └── README.md /Naive bayes/Naive Bayes in scikit learn.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# implementing Naive bayes using Scikit learn" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### now there are three types of naive bayes in scikit learn\n", 15 | "\n", 16 | " - Multinomial. \n", 17 | " http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.MultinomialNB.html\n", 18 | " \n", 19 | " - Bernoulli. \n", 20 | " http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.BernoulliNB.html\n", 21 | " \n", 22 | " - and finally Gaussian.\n", 23 | " http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html\n", 24 | " \n", 25 | " ## a quick reminder, we hve implemented gaussian naive bayesian in the above code\n" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 1, 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "# import dependencies\n", 35 | "import numpy as np\n", 36 | "import pandas as pd\n", 37 | "\n", 38 | "# other dependencies that you might not need\n", 39 | "# just for publishing image in notebook\n", 40 | "from IPython.display import Image\n", 41 | "from IPython.core.display import HTML \n", 42 | "%matplotlib inline" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 2, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "# column has all the name of column name \n", 52 | "# our data is stored in dataframe: data\n", 53 | "\n", 54 | "column = [\"Pregnancies\",\"Glucose\",\"BloodPressure\",\"SkinThickness\",\"Insulin\",\"BMI\",\"DiabetesPedigreeFunction\",\"Age\",\"Outcome\"]\n", 55 | "data = pd.read_csv('pima-indians-diabetes.data.csv',names=column)" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 3, 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "data": { 65 | "text/html": [ 66 | "
\n", 67 | "\n", 80 | "\n", 81 | " \n", 82 | " \n", 83 | " \n", 84 | " \n", 85 | " \n", 86 | " \n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " \n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | " \n", 101 | " \n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAgeOutcome
061487235033.60.627501
11856629026.60.351310
28183640023.30.672321
318966239428.10.167210
40137403516843.12.288331
\n", 158 | "
" 159 | ], 160 | "text/plain": [ 161 | " Pregnancies Glucose BloodPressure SkinThickness Insulin BMI \\\n", 162 | "0 6 148 72 35 0 33.6 \n", 163 | "1 1 85 66 29 0 26.6 \n", 164 | "2 8 183 64 0 0 23.3 \n", 165 | "3 1 89 66 23 94 28.1 \n", 166 | "4 0 137 40 35 168 43.1 \n", 167 | "\n", 168 | " DiabetesPedigreeFunction Age Outcome \n", 169 | "0 0.627 50 1 \n", 170 | "1 0.351 31 0 \n", 171 | "2 0.672 32 1 \n", 172 | "3 0.167 21 0 \n", 173 | "4 2.288 33 1 " 174 | ] 175 | }, 176 | "execution_count": 3, 177 | "metadata": {}, 178 | "output_type": "execute_result" 179 | } 180 | ], 181 | "source": [ 182 | "data.head()" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": 4, 188 | "metadata": {}, 189 | "outputs": [ 190 | { 191 | "data": { 192 | "text/html": [ 193 | "" 194 | ], 195 | "text/plain": [ 196 | "" 197 | ] 198 | }, 199 | "execution_count": 4, 200 | "metadata": {}, 201 | "output_type": "execute_result" 202 | } 203 | ], 204 | "source": [ 205 | "# to recollect, this is our bayesian formula\n", 206 | "Image(url= \"images/bayes.PNG\")" 207 | ] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "metadata": {}, 212 | "source": [ 213 | "Where,\n", 214 | " - P(c|x) is the posterior probability of class c given predictor ( features).\n", 215 | " - P(c) is the probability of class.\n", 216 | " - P(x|c) is the likelihood which is the probability of predictor given class.\n", 217 | " - P(x) is the prior probability of predictor." 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": 5, 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [ 226 | "\n", 227 | "X = data.iloc[:,0:-1] # X is the features in our dataset\n", 228 | "y = data.iloc[:,-1] # y is the Labels in our dataset" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 6, 234 | "metadata": {}, 235 | "outputs": [], 236 | "source": [ 237 | "# divide the dataset in train test using scikit learn\n", 238 | "# now the model will train in training dataset and then we will use test dataset to predict its accuracy\n", 239 | "\n", 240 | "from sklearn.model_selection import train_test_split\n", 241 | "\n", 242 | "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) " 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": 7, 248 | "metadata": {}, 249 | "outputs": [], 250 | "source": [ 251 | "# now preparing our model as per Gaussian Naive Bayesian\n", 252 | "\n", 253 | "from sklearn.naive_bayes import GaussianNB\n", 254 | "\n", 255 | "model = GaussianNB().fit(X_train, y_train) #fitting our model" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 8, 261 | "metadata": {}, 262 | "outputs": [], 263 | "source": [ 264 | "predicted_y = model.predict(X_test) #now predicting our model to our test dataset" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": 9, 270 | "metadata": {}, 271 | "outputs": [ 272 | { 273 | "name": "stdout", 274 | "output_type": "stream", 275 | "text": [ 276 | "0.7362204724409449\n" 277 | ] 278 | } 279 | ], 280 | "source": [ 281 | "from sklearn.metrics import accuracy_score\n", 282 | "\n", 283 | "# now calculating that how much accurate our model is with comparing our predicted values and y_test values\n", 284 | "accuracy_score = accuracy_score(y_test, predicted_y) \n", 285 | "print (accuracy_score)" 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "metadata": {}, 291 | "source": [ 292 | "## wow!! \n", 293 | "\n", 294 | "### we got 73% accuracy. It means it is accurate about the result 73%" 295 | ] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": 10, 300 | "metadata": {}, 301 | "outputs": [], 302 | "source": [ 303 | "# Lets test our model with random input" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": 11, 309 | "metadata": {}, 310 | "outputs": [ 311 | { 312 | "data": { 313 | "text/html": [ 314 | "
\n", 315 | "\n", 328 | "\n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAge
071308634033.50.56450
\n", 356 | "
" 357 | ], 358 | "text/plain": [ 359 | " Pregnancies Glucose BloodPressure SkinThickness Insulin BMI \\\n", 360 | "0 7 130 86 34 0 33.5 \n", 361 | "\n", 362 | " DiabetesPedigreeFunction Age \n", 363 | "0 0.564 50 " 364 | ] 365 | }, 366 | "execution_count": 11, 367 | "metadata": {}, 368 | "output_type": "execute_result" 369 | } 370 | ], 371 | "source": [ 372 | "# Create an empty dataframe that we have to predict \n", 373 | "person = pd.DataFrame()\n", 374 | "\n", 375 | "# Create some feature values for this single row\n", 376 | "person['Pregnancies'] = [7]\n", 377 | "person['Glucose'] = [130]\n", 378 | "person['BloodPressure'] = [86]\n", 379 | "person['SkinThickness'] = [34]\n", 380 | "person['Insulin'] = [0]\n", 381 | "person['BMI'] = [33.5]\n", 382 | "person['DiabetesPedigreeFunction'] = [0.564]\n", 383 | "person['Age'] = [50]\n", 384 | "# View the data \n", 385 | "person" 386 | ] 387 | }, 388 | { 389 | "cell_type": "code", 390 | "execution_count": 12, 391 | "metadata": {}, 392 | "outputs": [], 393 | "source": [ 394 | "# the data is stored in Datadrame person\n", 395 | "predicted_y = model.predict(person)" 396 | ] 397 | }, 398 | { 399 | "cell_type": "code", 400 | "execution_count": 13, 401 | "metadata": {}, 402 | "outputs": [ 403 | { 404 | "name": "stdout", 405 | "output_type": "stream", 406 | "text": [ 407 | "[1]\n" 408 | ] 409 | } 410 | ], 411 | "source": [ 412 | "print (predicted_y)" 413 | ] 414 | }, 415 | { 416 | "cell_type": "code", 417 | "execution_count": null, 418 | "metadata": {}, 419 | "outputs": [], 420 | "source": [] 421 | } 422 | ], 423 | "metadata": { 424 | "kernelspec": { 425 | "display_name": "Python 3", 426 | "language": "python", 427 | "name": "python3" 428 | }, 429 | "language_info": { 430 | "codemirror_mode": { 431 | "name": "ipython", 432 | "version": 3 433 | }, 434 | "file_extension": ".py", 435 | "mimetype": "text/x-python", 436 | "name": "python", 437 | "nbconvert_exporter": "python", 438 | "pygments_lexer": "ipython3", 439 | "version": "3.6.5" 440 | } 441 | }, 442 | "nbformat": 4, 443 | "nbformat_minor": 2 444 | } 445 | -------------------------------------------------------------------------------- /Naive bayes/Naive Bayes in scratch and also in scikit learn.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## This is Basic explination of Naive Bayes for Machine Learning. The Dataset i have used is called pima-indian-diabetes dataset" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### you can download the dataset from : https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv" 15 | ] 16 | }, 17 | { 18 | "cell_type": "markdown", 19 | "metadata": {}, 20 | "source": [ 21 | "#### The datasets consists of several medical predictor variables and one target variable, Outcome. Predictor variables includes the number of pregnancies the patient has had, their BMI, insulin level, age, and so on.\n", 22 | "\n", 23 | " - Pregnancies: Number of times pregnant
\n", 24 | " - Glucose: Plasma glucose concentration a 2 hours in an oral glucose tolerance test
\n", 25 | " - BloodPressure: Diastolic blood pressure (mm Hg)
\n", 26 | " - SkinThickness: Triceps skin fold thickness (mm)
\n", 27 | " - Insulin: 2-Hour serum insulin (mu U/ml)
\n", 28 | " - BMI: Body mass index (weight in kg/(height in m)^2)
\n", 29 | " - DiabetesPedigreeFunction: Diabetes pedigree function
\n", 30 | " - Age: Age (years)
\n", 31 | " - Outcome: Class variable (0 or 1)
" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 1, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# import dependencies\n", 41 | "import numpy as np\n", 42 | "import pandas as pd\n", 43 | "\n", 44 | "# other dependencies that you might not need\n", 45 | "# just for publishing image in notebook\n", 46 | "from IPython.display import Image\n", 47 | "from IPython.core.display import HTML \n", 48 | "%matplotlib inline" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 2, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "# column has all the name of column name \n", 58 | "# our data is stored in dataframe: data\n", 59 | "\n", 60 | "column = [\"Pregnancies\",\"Glucose\",\"BloodPressure\",\"SkinThickness\",\"Insulin\",\"BMI\",\"DiabetesPedigreeFunction\",\"Age\",\"Outcome\"]\n", 61 | "data = pd.read_csv('pima-indians-diabetes.data.csv',names=column)" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 3, 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "data": { 71 | "text/html": [ 72 | "
\n", 73 | "\n", 86 | "\n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " \n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | " \n", 101 | " \n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAgeOutcome
061487235033.60.627501
11856629026.60.351310
28183640023.30.672321
318966239428.10.167210
40137403516843.12.288331
\n", 164 | "
" 165 | ], 166 | "text/plain": [ 167 | " Pregnancies Glucose BloodPressure SkinThickness Insulin BMI \\\n", 168 | "0 6 148 72 35 0 33.6 \n", 169 | "1 1 85 66 29 0 26.6 \n", 170 | "2 8 183 64 0 0 23.3 \n", 171 | "3 1 89 66 23 94 28.1 \n", 172 | "4 0 137 40 35 168 43.1 \n", 173 | "\n", 174 | " DiabetesPedigreeFunction Age Outcome \n", 175 | "0 0.627 50 1 \n", 176 | "1 0.351 31 0 \n", 177 | "2 0.672 32 1 \n", 178 | "3 0.167 21 0 \n", 179 | "4 2.288 33 1 " 180 | ] 181 | }, 182 | "execution_count": 3, 183 | "metadata": {}, 184 | "output_type": "execute_result" 185 | } 186 | ], 187 | "source": [ 188 | "data.head()" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 4, 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "data": { 198 | "text/html": [ 199 | "" 200 | ], 201 | "text/plain": [ 202 | "" 203 | ] 204 | }, 205 | "execution_count": 4, 206 | "metadata": {}, 207 | "output_type": "execute_result" 208 | } 209 | ], 210 | "source": [ 211 | "# to recollect, this is our bayesian formula\n", 212 | "Image(url= \"images/bayes.PNG\")" 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "Where,\n", 220 | " - P(c|x) is the posterior probability of class c given predictor ( features).\n", 221 | " - P(c) is the probability of class.\n", 222 | " - P(x|c) is the likelihood which is the probability of predictor given class.\n", 223 | " - P(x) is the prior probability of predictor." 224 | ] 225 | }, 226 | { 227 | "cell_type": "code", 228 | "execution_count": null, 229 | "metadata": {}, 230 | "outputs": [], 231 | "source": [] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": {}, 236 | "source": [ 237 | "### In a bayes classifier, we calculate the posterior for every class for each observation. Then, classify the observation based on the class with the largest posterior value. we have two classes of outcome So we will calculate two posteriors: one for Outcome 1 and one for Outcome 0." 238 | ] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "metadata": {}, 243 | "source": [ 244 | "# specifically we will be using Gaussian Naive Bayes Classifier" 245 | ] 246 | }, 247 | { 248 | "cell_type": "code", 249 | "execution_count": 5, 250 | "metadata": {}, 251 | "outputs": [ 252 | { 253 | "data": { 254 | "text/html": [ 255 | "" 256 | ], 257 | "text/plain": [ 258 | "" 259 | ] 260 | }, 261 | "execution_count": 5, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "# now in data we have target data in Outcome column\n", 268 | "# outcome column has two sets namely Outcome 1 and outcome 0\n", 269 | "# now to calculate naive bayesian of outcome1 the formula will be\n", 270 | "\n", 271 | "Image(url= \"images/outcome1.PNG\")" 272 | ] 273 | }, 274 | { 275 | "cell_type": "code", 276 | "execution_count": 6, 277 | "metadata": {}, 278 | "outputs": [ 279 | { 280 | "data": { 281 | "text/html": [ 282 | "" 283 | ], 284 | "text/plain": [ 285 | "" 286 | ] 287 | }, 288 | "execution_count": 6, 289 | "metadata": {}, 290 | "output_type": "execute_result" 291 | } 292 | ], 293 | "source": [ 294 | "# for outcome0 the formula will be\n", 295 | "Image(url= \"images/outcome0.PNG\")" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "## Now let us unpack the top equation a bit:\n", 303 | "\n", 304 | " - P(Outcome1)is the prior probabilities. It is, as you can see, simply the probability an observation is \"1\" . This is just the number of person of outcome1 in the dataset divided by the total number of people in the dataset.

\n", 305 | "\n", 306 | " - p(pregnancies∣outcome1) * p(Glucose∣Outcome1) * p(Blood Pressure∣Outcome1)... is the likelihood. Notice that we have unpacked person’s data. so it is now every feature in the dataset. The “gaussian” and “naive” come from two assumptions present in this likelihood:

\n", 307 | " \n", 308 | " - If you look each term in the likelihood you will notice that we assume each feature is uncorrelated from each other. That is, Pregnancies is independent of Glucose or BMI etc.. This is obviously not true, and is a “naive” assumption - hence the name “naive bayes.”

\n" 309 | ] 310 | }, 311 | { 312 | "cell_type": "markdown", 313 | "metadata": {}, 314 | "source": [ 315 | " ##### ------------------------------------------------------------------------------------------------------------------------------------------------------------------\n", 316 | " \n", 317 | "## as the formula our goal is divided into 5 types\n", 318 | "\n", 319 | "1. Calculate Priors\n", 320 | "2. Calculate Likelihood\n", 321 | "3. Calculate Marginal Probability\n", 322 | "4. Apply Bayes Classifier To New Data Point\n", 323 | "5. understand what has just happen" 324 | ] 325 | }, 326 | { 327 | "cell_type": "markdown", 328 | "metadata": {}, 329 | "source": [ 330 | "### 1.Calculate Priors" 331 | ] 332 | }, 333 | { 334 | "cell_type": "markdown", 335 | "metadata": {}, 336 | "source": [ 337 | "#### Priors can be either constants or probability distributions. In our example, this is simply the probability of outcome of patients. " 338 | ] 339 | }, 340 | { 341 | "cell_type": "code", 342 | "execution_count": 7, 343 | "metadata": {}, 344 | "outputs": [], 345 | "source": [ 346 | "# Number of patients of outcome 1\n", 347 | "n_outcome1 = data['Outcome'][data['Outcome'] == 1].count()\n", 348 | "\n", 349 | "# Number of patients of outcome 0\n", 350 | "n_outcome0 = data['Outcome'][data['Outcome'] == 0].count()\n", 351 | "\n", 352 | "# Total people\n", 353 | "total_ppl = data['Outcome'].count()" 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 8, 359 | "metadata": {}, 360 | "outputs": [], 361 | "source": [ 362 | "# Number of people of outcome1 divided by the total people\n", 363 | "P_outcome1 = n_outcome1/total_ppl\n", 364 | "\n", 365 | "# Number of people of outcome0 divided by the total people\n", 366 | "P_outcome0 = n_outcome0/total_ppl" 367 | ] 368 | }, 369 | { 370 | "cell_type": "markdown", 371 | "metadata": {}, 372 | "source": [ 373 | "### 2.Calculate Likelihood" 374 | ] 375 | }, 376 | { 377 | "cell_type": "markdown", 378 | "metadata": {}, 379 | "source": [ 380 | " - We assume have that the value of the features (e.g. the Pregnancy of Outcome1, the Glucose of Outcome1) are normally (gaussian) distributed.

\n", 381 | " - This means that p (Pregnancy∣Outcome1) is calculated by inputing the required parameters into the probability density function of the normal distribution:

\n", 382 | " - Now as per the formula for probability density function, our likelihood will be" 383 | ] 384 | }, 385 | { 386 | "cell_type": "code", 387 | "execution_count": 9, 388 | "metadata": {}, 389 | "outputs": [ 390 | { 391 | "data": { 392 | "text/html": [ 393 | "" 394 | ], 395 | "text/plain": [ 396 | "" 397 | ] 398 | }, 399 | "execution_count": 9, 400 | "metadata": {}, 401 | "output_type": "execute_result" 402 | } 403 | ], 404 | "source": [ 405 | "Image(url= \"images/bay1.PNG\")" 406 | ] 407 | }, 408 | { 409 | "cell_type": "markdown", 410 | "metadata": {}, 411 | "source": [ 412 | " #### - Note: If you dont know or cant recollect the formula, refer this: https://en.wikipedia.org/wiki/Normal_distribution" 413 | ] 414 | }, 415 | { 416 | "cell_type": "code", 417 | "execution_count": 10, 418 | "metadata": {}, 419 | "outputs": [ 420 | { 421 | "data": { 422 | "text/html": [ 423 | "
\n", 424 | "\n", 437 | "\n", 438 | " \n", 439 | " \n", 440 | " \n", 441 | " \n", 442 | " \n", 443 | " \n", 444 | " \n", 445 | " \n", 446 | " \n", 447 | " \n", 448 | " \n", 449 | " \n", 450 | " \n", 451 | " \n", 452 | " \n", 453 | " \n", 454 | " \n", 455 | " \n", 456 | " \n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAge
Outcome
03.298000109.98000068.18400019.66400068.79200030.3042000.42973431.190000
14.865672141.25746370.82462722.164179100.33582135.1425370.55050037.067164
\n", 487 | "
" 488 | ], 489 | "text/plain": [ 490 | " Pregnancies Glucose BloodPressure SkinThickness Insulin \\\n", 491 | "Outcome \n", 492 | "0 3.298000 109.980000 68.184000 19.664000 68.792000 \n", 493 | "1 4.865672 141.257463 70.824627 22.164179 100.335821 \n", 494 | "\n", 495 | " BMI DiabetesPedigreeFunction Age \n", 496 | "Outcome \n", 497 | "0 30.304200 0.429734 31.190000 \n", 498 | "1 35.142537 0.550500 37.067164 " 499 | ] 500 | }, 501 | "execution_count": 10, 502 | "metadata": {}, 503 | "output_type": "execute_result" 504 | } 505 | ], 506 | "source": [ 507 | "# Now first calculate the means of the data according to outcome\n", 508 | "\n", 509 | "# Group the data by gender and calculate the means of each feature\n", 510 | "data_means = data.groupby('Outcome').mean()\n", 511 | "\n", 512 | "# View the values\n", 513 | "data_means" 514 | ] 515 | }, 516 | { 517 | "cell_type": "code", 518 | "execution_count": 11, 519 | "metadata": {}, 520 | "outputs": [ 521 | { 522 | "data": { 523 | "text/html": [ 524 | "
\n", 525 | "\n", 538 | "\n", 539 | " \n", 540 | " \n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | " \n", 547 | " \n", 548 | " \n", 549 | " \n", 550 | " \n", 551 | " \n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAge
Outcome
09.103403683.362325326.274693221.7105259774.34542759.1338700.089452136.134168
113.9968701020.139457461.897968312.57219519234.67331952.7506930.138648120.302588
\n", 588 | "
" 589 | ], 590 | "text/plain": [ 591 | " Pregnancies Glucose BloodPressure SkinThickness Insulin \\\n", 592 | "Outcome \n", 593 | "0 9.103403 683.362325 326.274693 221.710525 9774.345427 \n", 594 | "1 13.996870 1020.139457 461.897968 312.572195 19234.673319 \n", 595 | "\n", 596 | " BMI DiabetesPedigreeFunction Age \n", 597 | "Outcome \n", 598 | "0 59.133870 0.089452 136.134168 \n", 599 | "1 52.750693 0.138648 120.302588 " 600 | ] 601 | }, 602 | "execution_count": 11, 603 | "metadata": {}, 604 | "output_type": "execute_result" 605 | } 606 | ], 607 | "source": [ 608 | "# Second calculate the variance of the data according to outcome\n", 609 | "\n", 610 | "# Group the data by gender and calculate the variance of each feature\n", 611 | "data_variance = data.groupby('Outcome').var()\n", 612 | "\n", 613 | "# View the values\n", 614 | "data_variance" 615 | ] 616 | }, 617 | { 618 | "cell_type": "markdown", 619 | "metadata": {}, 620 | "source": [ 621 | " #### so you have got the means and variance of the data.\n", 622 | " now just as this formula is for one feature:" 623 | ] 624 | }, 625 | { 626 | "cell_type": "code", 627 | "execution_count": 12, 628 | "metadata": {}, 629 | "outputs": [ 630 | { 631 | "data": { 632 | "text/html": [ 633 | "" 634 | ], 635 | "text/plain": [ 636 | "" 637 | ] 638 | }, 639 | "execution_count": 12, 640 | "metadata": {}, 641 | "output_type": "execute_result" 642 | } 643 | ], 644 | "source": [ 645 | "Image(url= \"images/bay1.PNG\")" 646 | ] 647 | }, 648 | { 649 | "cell_type": "markdown", 650 | "metadata": {}, 651 | "source": [ 652 | "##### we have to find the values of all the features and to find it, we have to calculate the mean and variance of all the features." 653 | ] 654 | }, 655 | { 656 | "cell_type": "code", 657 | "execution_count": 13, 658 | "metadata": {}, 659 | "outputs": [], 660 | "source": [ 661 | "# Means for outcome1 for all features\n", 662 | "outcome1_Pregnancies_mean = data_means['Pregnancies'][data_variance.index == 1].values[0]\n", 663 | "outcome1_Glucose_mean = data_means['Glucose'][data_variance.index == 1].values[0]\n", 664 | "outcome1_BloodPressure_mean = data_means['BloodPressure'][data_variance.index == 1].values[0]\n", 665 | "outcome1_SkinThickness_mean = data_means['SkinThickness'][data_variance.index == 1].values[0]\n", 666 | "outcome1_Insulin_mean = data_means['Insulin'][data_variance.index == 1].values[0]\n", 667 | "outcome1_BMI_mean = data_means['BMI'][data_variance.index == 1].values[0]\n", 668 | "outcome1_DiabetesPedigreeFunction_mean = data_means['DiabetesPedigreeFunction'][data_variance.index == 1].values[0]\n", 669 | "outcome1_Age_mean = data_means['Age'][data_variance.index == 1].values[0]\n", 670 | "\n", 671 | "\n", 672 | "# Variance for outcome1 for all features\n", 673 | "outcome1_Pregnancies_variance = data_variance['Pregnancies'][data_variance.index == 1].values[0]\n", 674 | "outcome1_Glucose_variance= data_variance['Glucose'][data_variance.index == 1].values[0]\n", 675 | "outcome1_BloodPressure_variance = data_variance['BloodPressure'][data_variance.index == 1].values[0]\n", 676 | "outcome1_SkinThickness_variance = data_variance['SkinThickness'][data_variance.index == 1].values[0]\n", 677 | "outcome1_Insulin_variance = data_variance['Insulin'][data_variance.index == 1].values[0]\n", 678 | "outcome1_BMI_variance = data_variance['BMI'][data_variance.index == 1].values[0]\n", 679 | "outcome1_DiabetesPedigreeFunction_variance = data_variance['DiabetesPedigreeFunction'][data_variance.index == 1].values[0]\n", 680 | "outcome1_Age_variance = data_variance['Age'][data_variance.index == 1].values[0]\n", 681 | "\n", 682 | "# Means for outcome0 for all features\n", 683 | "outcome0_Pregnancies_mean = data_means['Pregnancies'][data_variance.index == 0].values[0]\n", 684 | "outcome0_Glucose_mean = data_means['Glucose'][data_variance.index == 0].values[0]\n", 685 | "outcome0_BloodPressure_mean = data_means['BloodPressure'][data_variance.index == 0].values[0]\n", 686 | "outcome0_SkinThickness_mean = data_means['SkinThickness'][data_variance.index == 0].values[0]\n", 687 | "outcome0_Insulin_mean = data_means['Insulin'][data_variance.index == 0].values[0]\n", 688 | "outcome0_BMI_mean = data_means['BMI'][data_variance.index == 0].values[0]\n", 689 | "outcome0_DiabetesPedigreeFunction_mean = data_means['DiabetesPedigreeFunction'][data_variance.index == 0].values[0]\n", 690 | "outcome0_Age_mean = data_means['Age'][data_variance.index == 0].values[0]\n", 691 | "\n", 692 | "# Variance for outcomeo for all features\n", 693 | "outcome0_Pregnancies_variance = data_variance['Pregnancies'][data_variance.index == 0].values[0]\n", 694 | "outcome0_Glucose_variance = data_variance['Glucose'][data_variance.index == 0].values[0]\n", 695 | "outcome0_BloodPressure_variance = data_variance['BloodPressure'][data_variance.index == 0].values[0]\n", 696 | "outcome0_SkinThickness_variance = data_variance['SkinThickness'][data_variance.index == 0].values[0]\n", 697 | "outcome0_Insulin_variance = data_variance['Insulin'][data_variance.index == 0].values[0]\n", 698 | "outcome0_BMI_variance = data_variance['BMI'][data_variance.index == 0].values[0]\n", 699 | "outcome0_DiabetesPedigreeFunction_variance = data_variance['DiabetesPedigreeFunction'][data_variance.index == 0].values[0]\n", 700 | "outcome0_Age_variance = data_variance['Age'][data_variance.index == 0].values[0]" 701 | ] 702 | }, 703 | { 704 | "cell_type": "markdown", 705 | "metadata": {}, 706 | "source": [ 707 | "### 3.Marginal probability" 708 | ] 709 | }, 710 | { 711 | "cell_type": "markdown", 712 | "metadata": {}, 713 | "source": [ 714 | "##### It is probably one of the most confusing parts of bayesian approaches. In some examples it is completely possible to calculate the marginal probability. \n", 715 | "##### However, in many real-world cases, it is either extremely difficult or impossible to find the value of the marginal probability (explaining why is beyond the scope of this tutorial). \n", 716 | "##### This is not as much of a problem for our classifier as you might think. Why? Because we don’t care what the true posterior value is, we only care which class has a the highest posterior value.\n", 717 | "##### And because the marginal probability is the same for all classes \n", 718 | "1) we can ignore the denominator

\n", 719 | "2) calculate only the posterior’s numerator for each class

\n", 720 | "3) pick the largest numerator. That is, we can ignore the posterior’s denominator and make a prediction solely on the relative values of the posterior’s numerator.

" 721 | ] 722 | }, 723 | { 724 | "cell_type": "markdown", 725 | "metadata": {}, 726 | "source": [ 727 | "### 4. Apply Bayes Classifier To New Data Point" 728 | ] 729 | }, 730 | { 731 | "cell_type": "code", 732 | "execution_count": 14, 733 | "metadata": {}, 734 | "outputs": [ 735 | { 736 | "data": { 737 | "text/html": [ 738 | "
\n", 739 | "\n", 752 | "\n", 753 | " \n", 754 | " \n", 755 | " \n", 756 | " \n", 757 | " \n", 758 | " \n", 759 | " \n", 760 | " \n", 761 | " \n", 762 | " \n", 763 | " \n", 764 | " \n", 765 | " \n", 766 | " \n", 767 | " \n", 768 | " \n", 769 | " \n", 770 | " \n", 771 | " \n", 772 | " \n", 773 | " \n", 774 | " \n", 775 | " \n", 776 | " \n", 777 | " \n", 778 | " \n", 779 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAge
071308634033.50.56450
\n", 780 | "
" 781 | ], 782 | "text/plain": [ 783 | " Pregnancies Glucose BloodPressure SkinThickness Insulin BMI \\\n", 784 | "0 7 130 86 34 0 33.5 \n", 785 | "\n", 786 | " DiabetesPedigreeFunction Age \n", 787 | "0 0.564 50 " 788 | ] 789 | }, 790 | "execution_count": 14, 791 | "metadata": {}, 792 | "output_type": "execute_result" 793 | } 794 | ], 795 | "source": [ 796 | "# Create an empty dataframe that we have to predict \n", 797 | "person = pd.DataFrame()\n", 798 | "\n", 799 | "# Create some feature values for this single row\n", 800 | "person['Pregnancies'] = [7]\n", 801 | "person['Glucose'] = [130]\n", 802 | "person['BloodPressure'] = [86]\n", 803 | "person['SkinThickness'] = [34]\n", 804 | "person['Insulin'] = [0]\n", 805 | "person['BMI'] = [33.5]\n", 806 | "person['DiabetesPedigreeFunction'] = [0.564]\n", 807 | "person['Age'] = [50]\n", 808 | "# View the data \n", 809 | "person\n", 810 | "\n" 811 | ] 812 | }, 813 | { 814 | "cell_type": "code", 815 | "execution_count": 15, 816 | "metadata": {}, 817 | "outputs": [], 818 | "source": [ 819 | "# Create a function that calculates p(x | y):\n", 820 | "def p_x_given_y(x, mean_y, variance_y):\n", 821 | "\n", 822 | " # Input the arguments into a probability density function\n", 823 | " p = 1/(np.sqrt(2*np.pi*variance_y)) * np.exp((-(x-mean_y)**2)/(2*variance_y))\n", 824 | " \n", 825 | " # return p\n", 826 | " return p" 827 | ] 828 | }, 829 | { 830 | "cell_type": "markdown", 831 | "metadata": {}, 832 | "source": [ 833 | "### for now we are ignoring the marginal property aka prior probability" 834 | ] 835 | }, 836 | { 837 | "cell_type": "code", 838 | "execution_count": 16, 839 | "metadata": {}, 840 | "outputs": [ 841 | { 842 | "data": { 843 | "text/html": [ 844 | "" 845 | ], 846 | "text/plain": [ 847 | "" 848 | ] 849 | }, 850 | "execution_count": 16, 851 | "metadata": {}, 852 | "output_type": "execute_result" 853 | } 854 | ], 855 | "source": [ 856 | "#formula again for reference\n", 857 | "Image(url= \"images/bayes.PNG\")\n", 858 | "\n", 859 | "# Where,\n", 860 | "# P(c|x) is the posterior probability of class c given predictor ( features).\n", 861 | "# P(c) is the probability of class.\n", 862 | "# P(x|c) is the likelihood which is the probability of predictor given class.\n", 863 | "# P(x) is the prior probability of predictor." 864 | ] 865 | }, 866 | { 867 | "cell_type": "code", 868 | "execution_count": 17, 869 | "metadata": {}, 870 | "outputs": [ 871 | { 872 | "data": { 873 | "text/html": [ 874 | "" 875 | ], 876 | "text/plain": [ 877 | "" 878 | ] 879 | }, 880 | "execution_count": 17, 881 | "metadata": {}, 882 | "output_type": "execute_result" 883 | } 884 | ], 885 | "source": [ 886 | "Image(url= \"images/outcome1.PNG\")" 887 | ] 888 | }, 889 | { 890 | "cell_type": "code", 891 | "execution_count": 18, 892 | "metadata": {}, 893 | "outputs": [], 894 | "source": [ 895 | "# So for now we will only calculate the numerator of the data and will predict based on numerator only\n", 896 | "\n", 897 | "# Numerator of the posterior probability if the unclassified observation is a Outcome1\n", 898 | "d_out1 = P_outcome1 * \\\n", 899 | "p_x_given_y(person['Pregnancies'][0], outcome1_Pregnancies_mean, outcome1_Pregnancies_variance) * \\\n", 900 | "p_x_given_y(person['Glucose'][0], outcome1_Glucose_mean, outcome1_Glucose_variance) * \\\n", 901 | "p_x_given_y(person['BloodPressure'][0], outcome1_BloodPressure_mean, outcome1_BloodPressure_variance) * \\\n", 902 | "p_x_given_y(person['SkinThickness'][0], outcome1_SkinThickness_mean, outcome1_SkinThickness_variance) * \\\n", 903 | "p_x_given_y(person['Insulin'][0], outcome1_Insulin_mean, outcome1_Insulin_variance) * \\\n", 904 | "p_x_given_y(person['BMI'][0], outcome1_BMI_mean, outcome1_BMI_variance) * \\\n", 905 | "p_x_given_y(person['DiabetesPedigreeFunction'][0], outcome1_DiabetesPedigreeFunction_mean, outcome1_DiabetesPedigreeFunction_variance) *\\\n", 906 | "p_x_given_y(person['Age'][0], outcome1_Age_mean, outcome1_Age_variance) " 907 | ] 908 | }, 909 | { 910 | "cell_type": "code", 911 | "execution_count": 19, 912 | "metadata": {}, 913 | "outputs": [ 914 | { 915 | "data": { 916 | "text/plain": [ 917 | "2.2311606712297407e-13" 918 | ] 919 | }, 920 | "execution_count": 19, 921 | "metadata": {}, 922 | "output_type": "execute_result" 923 | } 924 | ], 925 | "source": [ 926 | "d_out1" 927 | ] 928 | }, 929 | { 930 | "cell_type": "code", 931 | "execution_count": 20, 932 | "metadata": {}, 933 | "outputs": [ 934 | { 935 | "data": { 936 | "text/html": [ 937 | "" 938 | ], 939 | "text/plain": [ 940 | "" 941 | ] 942 | }, 943 | "execution_count": 20, 944 | "metadata": {}, 945 | "output_type": "execute_result" 946 | } 947 | ], 948 | "source": [ 949 | "Image(url= \"images/outcome0.PNG\")" 950 | ] 951 | }, 952 | { 953 | "cell_type": "code", 954 | "execution_count": 21, 955 | "metadata": {}, 956 | "outputs": [], 957 | "source": [ 958 | "# Numerator of the posterior probability if the unclassified observation is a Outcome0\n", 959 | "d_out2 = P_outcome0 * \\\n", 960 | "p_x_given_y(person['Pregnancies'][0], outcome0_Pregnancies_mean, outcome0_Pregnancies_variance) * \\\n", 961 | "p_x_given_y(person['Glucose'][0], outcome0_Glucose_mean, outcome0_Glucose_variance) * \\\n", 962 | "p_x_given_y(person['BloodPressure'][0], outcome0_BloodPressure_mean, outcome0_BloodPressure_variance) * \\\n", 963 | "p_x_given_y(person['SkinThickness'][0], outcome0_SkinThickness_mean, outcome0_SkinThickness_variance) * \\\n", 964 | "p_x_given_y(person['Insulin'][0], outcome0_Insulin_mean, outcome0_Insulin_variance) * \\\n", 965 | "p_x_given_y(person['BMI'][0], outcome0_BMI_mean, outcome0_BMI_variance) * \\\n", 966 | "p_x_given_y(person['DiabetesPedigreeFunction'][0], outcome0_DiabetesPedigreeFunction_mean, outcome0_DiabetesPedigreeFunction_variance) *\\\n", 967 | "p_x_given_y(person['Age'][0], outcome0_Age_mean, outcome0_Age_variance) " 968 | ] 969 | }, 970 | { 971 | "cell_type": "code", 972 | "execution_count": 22, 973 | "metadata": {}, 974 | "outputs": [ 975 | { 976 | "data": { 977 | "text/plain": [ 978 | "1.7904471741735295e-13" 979 | ] 980 | }, 981 | "execution_count": 22, 982 | "metadata": {}, 983 | "output_type": "execute_result" 984 | } 985 | ], 986 | "source": [ 987 | "d_out2" 988 | ] 989 | }, 990 | { 991 | "cell_type": "markdown", 992 | "metadata": {}, 993 | "source": [ 994 | "## 5. understand what has just happen" 995 | ] 996 | }, 997 | { 998 | "cell_type": "markdown", 999 | "metadata": {}, 1000 | "source": [ 1001 | "### now as we compare this value with outcome1 and outcome0, we can definitely say that the given data that we inserted is infact of type outcome1" 1002 | ] 1003 | }, 1004 | { 1005 | "cell_type": "markdown", 1006 | "metadata": {}, 1007 | "source": [ 1008 | "



\n", 1009 | "This is just a very simple way of nderstanding the Naive bayes from scratch.\n", 1010 | "This technique was adapated from here.https://chrisalbon.com/machine_learning/naive_bayes/naive_bayes_classifier_from_scratch/\n", 1011 | "\n", 1012 | "#### Further i will implement this same technique in scikit learn,\n", 1013 | "#### This is easy and you should use this only when you understand the upper code" 1014 | ] 1015 | }, 1016 | { 1017 | "cell_type": "markdown", 1018 | "metadata": {}, 1019 | "source": [ 1020 | "# -------------------------------------------------------------------------------------------------------------\n", 1021 | "\n", 1022 | "\n", 1023 | "# implementing Naive bayes using Scikit learn" 1024 | ] 1025 | }, 1026 | { 1027 | "cell_type": "markdown", 1028 | "metadata": {}, 1029 | "source": [ 1030 | "### now there are three types of naive bayes in scikit learn\n", 1031 | "\n", 1032 | " - Multinomial. \n", 1033 | " http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.MultinomialNB.html\n", 1034 | " \n", 1035 | " - Bernoulli. \n", 1036 | " http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.BernoulliNB.html\n", 1037 | " \n", 1038 | " - and finally Gaussian.\n", 1039 | " http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html\n", 1040 | " \n", 1041 | " ## a quick reminder, we hve implemented gaussian naive bayesian in the above code\n" 1042 | ] 1043 | }, 1044 | { 1045 | "cell_type": "code", 1046 | "execution_count": 31, 1047 | "metadata": {}, 1048 | "outputs": [ 1049 | { 1050 | "data": { 1051 | "text/html": [ 1052 | "
\n", 1053 | "\n", 1066 | "\n", 1067 | " \n", 1068 | " \n", 1069 | " \n", 1070 | " \n", 1071 | " \n", 1072 | " \n", 1073 | " \n", 1074 | " \n", 1075 | " \n", 1076 | " \n", 1077 | " \n", 1078 | " \n", 1079 | " \n", 1080 | " \n", 1081 | " \n", 1082 | " \n", 1083 | " \n", 1084 | " \n", 1085 | " \n", 1086 | " \n", 1087 | " \n", 1088 | " \n", 1089 | " \n", 1090 | " \n", 1091 | " \n", 1092 | " \n", 1093 | " \n", 1094 | " \n", 1095 | " \n", 1096 | " \n", 1097 | " \n", 1098 | " \n", 1099 | " \n", 1100 | " \n", 1101 | " \n", 1102 | " \n", 1103 | " \n", 1104 | " \n", 1105 | " \n", 1106 | " \n", 1107 | " \n", 1108 | " \n", 1109 | " \n", 1110 | " \n", 1111 | " \n", 1112 | " \n", 1113 | " \n", 1114 | " \n", 1115 | " \n", 1116 | " \n", 1117 | " \n", 1118 | " \n", 1119 | " \n", 1120 | " \n", 1121 | " \n", 1122 | " \n", 1123 | " \n", 1124 | " \n", 1125 | " \n", 1126 | " \n", 1127 | " \n", 1128 | " \n", 1129 | " \n", 1130 | " \n", 1131 | " \n", 1132 | " \n", 1133 | " \n", 1134 | " \n", 1135 | " \n", 1136 | " \n", 1137 | " \n", 1138 | " \n", 1139 | " \n", 1140 | " \n", 1141 | " \n", 1142 | " \n", 1143 | "
PregnanciesGlucoseBloodPressureSkinThicknessInsulinBMIDiabetesPedigreeFunctionAgeOutcome
061487235033.60.627501
11856629026.60.351310
28183640023.30.672321
318966239428.10.167210
40137403516843.12.288331
\n", 1144 | "
" 1145 | ], 1146 | "text/plain": [ 1147 | " Pregnancies Glucose BloodPressure SkinThickness Insulin BMI \\\n", 1148 | "0 6 148 72 35 0 33.6 \n", 1149 | "1 1 85 66 29 0 26.6 \n", 1150 | "2 8 183 64 0 0 23.3 \n", 1151 | "3 1 89 66 23 94 28.1 \n", 1152 | "4 0 137 40 35 168 43.1 \n", 1153 | "\n", 1154 | " DiabetesPedigreeFunction Age Outcome \n", 1155 | "0 0.627 50 1 \n", 1156 | "1 0.351 31 0 \n", 1157 | "2 0.672 32 1 \n", 1158 | "3 0.167 21 0 \n", 1159 | "4 2.288 33 1 " 1160 | ] 1161 | }, 1162 | "execution_count": 31, 1163 | "metadata": {}, 1164 | "output_type": "execute_result" 1165 | } 1166 | ], 1167 | "source": [ 1168 | "#first visualise what we have in our hand\n", 1169 | "data.head()" 1170 | ] 1171 | }, 1172 | { 1173 | "cell_type": "code", 1174 | "execution_count": 24, 1175 | "metadata": {}, 1176 | "outputs": [], 1177 | "source": [ 1178 | "\n", 1179 | "X = data.iloc[:,0:-1] # X is the features in our dataset\n", 1180 | "y = data.iloc[:,-1] # y is the Labels in our dataset" 1181 | ] 1182 | }, 1183 | { 1184 | "cell_type": "code", 1185 | "execution_count": 25, 1186 | "metadata": {}, 1187 | "outputs": [], 1188 | "source": [ 1189 | "# divide the dataset in train test using scikit learn\n", 1190 | "# now the model will train in training dataset and then we will use test dataset to predict its accuracy\n", 1191 | "\n", 1192 | "from sklearn.model_selection import train_test_split\n", 1193 | "\n", 1194 | "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) " 1195 | ] 1196 | }, 1197 | { 1198 | "cell_type": "code", 1199 | "execution_count": 26, 1200 | "metadata": {}, 1201 | "outputs": [], 1202 | "source": [ 1203 | "# now preparing our model as per Gaussian Naive Bayesian\n", 1204 | "\n", 1205 | "from sklearn.naive_bayes import GaussianNB\n", 1206 | "\n", 1207 | "model = GaussianNB().fit(X_train, y_train) #fitting our model" 1208 | ] 1209 | }, 1210 | { 1211 | "cell_type": "code", 1212 | "execution_count": 27, 1213 | "metadata": {}, 1214 | "outputs": [], 1215 | "source": [ 1216 | "predicted_y = model.predict(X_test) #now predicting our model to our test dataset" 1217 | ] 1218 | }, 1219 | { 1220 | "cell_type": "code", 1221 | "execution_count": 28, 1222 | "metadata": {}, 1223 | "outputs": [ 1224 | { 1225 | "name": "stdout", 1226 | "output_type": "stream", 1227 | "text": [ 1228 | "0.7362204724409449\n" 1229 | ] 1230 | } 1231 | ], 1232 | "source": [ 1233 | "from sklearn.metrics import accuracy_score\n", 1234 | "\n", 1235 | "# now calculating that how much accurate our model is with comparing our predicted values and y_test values\n", 1236 | "accuracy_score = accuracy_score(y_test, predicted_y) \n", 1237 | "print (accuracy_score)" 1238 | ] 1239 | }, 1240 | { 1241 | "cell_type": "markdown", 1242 | "metadata": {}, 1243 | "source": [ 1244 | "## wow!! \n", 1245 | "\n", 1246 | "### we got 73% accuracy. It means it is accurate about the result 73%" 1247 | ] 1248 | }, 1249 | { 1250 | "cell_type": "markdown", 1251 | "metadata": {}, 1252 | "source": [ 1253 | "## now further i will test my model to the new data point. remember, from upper model we concluded that that new data point is of outcome1" 1254 | ] 1255 | }, 1256 | { 1257 | "cell_type": "code", 1258 | "execution_count": 29, 1259 | "metadata": {}, 1260 | "outputs": [], 1261 | "source": [ 1262 | "# the data is stored in Datadrame person\n", 1263 | "predicted_y = model.predict(person)" 1264 | ] 1265 | }, 1266 | { 1267 | "cell_type": "code", 1268 | "execution_count": 30, 1269 | "metadata": {}, 1270 | "outputs": [ 1271 | { 1272 | "name": "stdout", 1273 | "output_type": "stream", 1274 | "text": [ 1275 | "[1]\n" 1276 | ] 1277 | } 1278 | ], 1279 | "source": [ 1280 | "print (predicted_y)" 1281 | ] 1282 | }, 1283 | { 1284 | "cell_type": "markdown", 1285 | "metadata": {}, 1286 | "source": [ 1287 | "# we have got the same result from this model too... Awesome" 1288 | ] 1289 | }, 1290 | { 1291 | "cell_type": "code", 1292 | "execution_count": null, 1293 | "metadata": {}, 1294 | "outputs": [], 1295 | "source": [] 1296 | } 1297 | ], 1298 | "metadata": { 1299 | "kernelspec": { 1300 | "display_name": "Python 3", 1301 | "language": "python", 1302 | "name": "python3" 1303 | }, 1304 | "language_info": { 1305 | "codemirror_mode": { 1306 | "name": "ipython", 1307 | "version": 3 1308 | }, 1309 | "file_extension": ".py", 1310 | "mimetype": "text/x-python", 1311 | "name": "python", 1312 | "nbconvert_exporter": "python", 1313 | "pygments_lexer": "ipython3", 1314 | "version": "3.6.5" 1315 | } 1316 | }, 1317 | "nbformat": 4, 1318 | "nbformat_minor": 2 1319 | } 1320 | -------------------------------------------------------------------------------- /Naive bayes/images/bay1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/bay1.png -------------------------------------------------------------------------------- /Naive bayes/images/bayes.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/bayes.PNG -------------------------------------------------------------------------------- /Naive bayes/images/coef.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/coef.PNG -------------------------------------------------------------------------------- /Naive bayes/images/coeff.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/coeff.PNG -------------------------------------------------------------------------------- /Naive bayes/images/cov.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/cov.PNG -------------------------------------------------------------------------------- /Naive bayes/images/euc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/euc.PNG -------------------------------------------------------------------------------- /Naive bayes/images/eucc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/eucc.PNG -------------------------------------------------------------------------------- /Naive bayes/images/g.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/g.PNG -------------------------------------------------------------------------------- /Naive bayes/images/gd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/gd.PNG -------------------------------------------------------------------------------- /Naive bayes/images/gdd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/gdd.PNG -------------------------------------------------------------------------------- /Naive bayes/images/gg.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/gg.PNG -------------------------------------------------------------------------------- /Naive bayes/images/h.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/h.PNG -------------------------------------------------------------------------------- /Naive bayes/images/lin.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/lin.PNG -------------------------------------------------------------------------------- /Naive bayes/images/linn.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/linn.PNG -------------------------------------------------------------------------------- /Naive bayes/images/log1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/log1.png -------------------------------------------------------------------------------- /Naive bayes/images/mul.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/mul.PNG -------------------------------------------------------------------------------- /Naive bayes/images/mult.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/mult.PNG -------------------------------------------------------------------------------- /Naive bayes/images/outcome0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/outcome0.PNG -------------------------------------------------------------------------------- /Naive bayes/images/outcome1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/outcome1.PNG -------------------------------------------------------------------------------- /Naive bayes/images/ss.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2796gaurav/Naive-bayes-explained/68768e542d8d2dd1b8ca493619e0e37e7ee1a9f8/Naive bayes/images/ss.PNG -------------------------------------------------------------------------------- /Naive bayes/pima-indians-diabetes.data.csv: -------------------------------------------------------------------------------- 1 | 6,148,72,35,0,33.6,0.627,50,1 2 | 1,85,66,29,0,26.6,0.351,31,0 3 | 8,183,64,0,0,23.3,0.672,32,1 4 | 1,89,66,23,94,28.1,0.167,21,0 5 | 0,137,40,35,168,43.1,2.288,33,1 6 | 5,116,74,0,0,25.6,0.201,30,0 7 | 3,78,50,32,88,31.0,0.248,26,1 8 | 10,115,0,0,0,35.3,0.134,29,0 9 | 2,197,70,45,543,30.5,0.158,53,1 10 | 8,125,96,0,0,0.0,0.232,54,1 11 | 4,110,92,0,0,37.6,0.191,30,0 12 | 10,168,74,0,0,38.0,0.537,34,1 13 | 10,139,80,0,0,27.1,1.441,57,0 14 | 1,189,60,23,846,30.1,0.398,59,1 15 | 5,166,72,19,175,25.8,0.587,51,1 16 | 7,100,0,0,0,30.0,0.484,32,1 17 | 0,118,84,47,230,45.8,0.551,31,1 18 | 7,107,74,0,0,29.6,0.254,31,1 19 | 1,103,30,38,83,43.3,0.183,33,0 20 | 1,115,70,30,96,34.6,0.529,32,1 21 | 3,126,88,41,235,39.3,0.704,27,0 22 | 8,99,84,0,0,35.4,0.388,50,0 23 | 7,196,90,0,0,39.8,0.451,41,1 24 | 9,119,80,35,0,29.0,0.263,29,1 25 | 11,143,94,33,146,36.6,0.254,51,1 26 | 10,125,70,26,115,31.1,0.205,41,1 27 | 7,147,76,0,0,39.4,0.257,43,1 28 | 1,97,66,15,140,23.2,0.487,22,0 29 | 13,145,82,19,110,22.2,0.245,57,0 30 | 5,117,92,0,0,34.1,0.337,38,0 31 | 5,109,75,26,0,36.0,0.546,60,0 32 | 3,158,76,36,245,31.6,0.851,28,1 33 | 3,88,58,11,54,24.8,0.267,22,0 34 | 6,92,92,0,0,19.9,0.188,28,0 35 | 10,122,78,31,0,27.6,0.512,45,0 36 | 4,103,60,33,192,24.0,0.966,33,0 37 | 11,138,76,0,0,33.2,0.420,35,0 38 | 9,102,76,37,0,32.9,0.665,46,1 39 | 2,90,68,42,0,38.2,0.503,27,1 40 | 4,111,72,47,207,37.1,1.390,56,1 41 | 3,180,64,25,70,34.0,0.271,26,0 42 | 7,133,84,0,0,40.2,0.696,37,0 43 | 7,106,92,18,0,22.7,0.235,48,0 44 | 9,171,110,24,240,45.4,0.721,54,1 45 | 7,159,64,0,0,27.4,0.294,40,0 46 | 0,180,66,39,0,42.0,1.893,25,1 47 | 1,146,56,0,0,29.7,0.564,29,0 48 | 2,71,70,27,0,28.0,0.586,22,0 49 | 7,103,66,32,0,39.1,0.344,31,1 50 | 7,105,0,0,0,0.0,0.305,24,0 51 | 1,103,80,11,82,19.4,0.491,22,0 52 | 1,101,50,15,36,24.2,0.526,26,0 53 | 5,88,66,21,23,24.4,0.342,30,0 54 | 8,176,90,34,300,33.7,0.467,58,1 55 | 7,150,66,42,342,34.7,0.718,42,0 56 | 1,73,50,10,0,23.0,0.248,21,0 57 | 7,187,68,39,304,37.7,0.254,41,1 58 | 0,100,88,60,110,46.8,0.962,31,0 59 | 0,146,82,0,0,40.5,1.781,44,0 60 | 0,105,64,41,142,41.5,0.173,22,0 61 | 2,84,0,0,0,0.0,0.304,21,0 62 | 8,133,72,0,0,32.9,0.270,39,1 63 | 5,44,62,0,0,25.0,0.587,36,0 64 | 2,141,58,34,128,25.4,0.699,24,0 65 | 7,114,66,0,0,32.8,0.258,42,1 66 | 5,99,74,27,0,29.0,0.203,32,0 67 | 0,109,88,30,0,32.5,0.855,38,1 68 | 2,109,92,0,0,42.7,0.845,54,0 69 | 1,95,66,13,38,19.6,0.334,25,0 70 | 4,146,85,27,100,28.9,0.189,27,0 71 | 2,100,66,20,90,32.9,0.867,28,1 72 | 5,139,64,35,140,28.6,0.411,26,0 73 | 13,126,90,0,0,43.4,0.583,42,1 74 | 4,129,86,20,270,35.1,0.231,23,0 75 | 1,79,75,30,0,32.0,0.396,22,0 76 | 1,0,48,20,0,24.7,0.140,22,0 77 | 7,62,78,0,0,32.6,0.391,41,0 78 | 5,95,72,33,0,37.7,0.370,27,0 79 | 0,131,0,0,0,43.2,0.270,26,1 80 | 2,112,66,22,0,25.0,0.307,24,0 81 | 3,113,44,13,0,22.4,0.140,22,0 82 | 2,74,0,0,0,0.0,0.102,22,0 83 | 7,83,78,26,71,29.3,0.767,36,0 84 | 0,101,65,28,0,24.6,0.237,22,0 85 | 5,137,108,0,0,48.8,0.227,37,1 86 | 2,110,74,29,125,32.4,0.698,27,0 87 | 13,106,72,54,0,36.6,0.178,45,0 88 | 2,100,68,25,71,38.5,0.324,26,0 89 | 15,136,70,32,110,37.1,0.153,43,1 90 | 1,107,68,19,0,26.5,0.165,24,0 91 | 1,80,55,0,0,19.1,0.258,21,0 92 | 4,123,80,15,176,32.0,0.443,34,0 93 | 7,81,78,40,48,46.7,0.261,42,0 94 | 4,134,72,0,0,23.8,0.277,60,1 95 | 2,142,82,18,64,24.7,0.761,21,0 96 | 6,144,72,27,228,33.9,0.255,40,0 97 | 2,92,62,28,0,31.6,0.130,24,0 98 | 1,71,48,18,76,20.4,0.323,22,0 99 | 6,93,50,30,64,28.7,0.356,23,0 100 | 1,122,90,51,220,49.7,0.325,31,1 101 | 1,163,72,0,0,39.0,1.222,33,1 102 | 1,151,60,0,0,26.1,0.179,22,0 103 | 0,125,96,0,0,22.5,0.262,21,0 104 | 1,81,72,18,40,26.6,0.283,24,0 105 | 2,85,65,0,0,39.6,0.930,27,0 106 | 1,126,56,29,152,28.7,0.801,21,0 107 | 1,96,122,0,0,22.4,0.207,27,0 108 | 4,144,58,28,140,29.5,0.287,37,0 109 | 3,83,58,31,18,34.3,0.336,25,0 110 | 0,95,85,25,36,37.4,0.247,24,1 111 | 3,171,72,33,135,33.3,0.199,24,1 112 | 8,155,62,26,495,34.0,0.543,46,1 113 | 1,89,76,34,37,31.2,0.192,23,0 114 | 4,76,62,0,0,34.0,0.391,25,0 115 | 7,160,54,32,175,30.5,0.588,39,1 116 | 4,146,92,0,0,31.2,0.539,61,1 117 | 5,124,74,0,0,34.0,0.220,38,1 118 | 5,78,48,0,0,33.7,0.654,25,0 119 | 4,97,60,23,0,28.2,0.443,22,0 120 | 4,99,76,15,51,23.2,0.223,21,0 121 | 0,162,76,56,100,53.2,0.759,25,1 122 | 6,111,64,39,0,34.2,0.260,24,0 123 | 2,107,74,30,100,33.6,0.404,23,0 124 | 5,132,80,0,0,26.8,0.186,69,0 125 | 0,113,76,0,0,33.3,0.278,23,1 126 | 1,88,30,42,99,55.0,0.496,26,1 127 | 3,120,70,30,135,42.9,0.452,30,0 128 | 1,118,58,36,94,33.3,0.261,23,0 129 | 1,117,88,24,145,34.5,0.403,40,1 130 | 0,105,84,0,0,27.9,0.741,62,1 131 | 4,173,70,14,168,29.7,0.361,33,1 132 | 9,122,56,0,0,33.3,1.114,33,1 133 | 3,170,64,37,225,34.5,0.356,30,1 134 | 8,84,74,31,0,38.3,0.457,39,0 135 | 2,96,68,13,49,21.1,0.647,26,0 136 | 2,125,60,20,140,33.8,0.088,31,0 137 | 0,100,70,26,50,30.8,0.597,21,0 138 | 0,93,60,25,92,28.7,0.532,22,0 139 | 0,129,80,0,0,31.2,0.703,29,0 140 | 5,105,72,29,325,36.9,0.159,28,0 141 | 3,128,78,0,0,21.1,0.268,55,0 142 | 5,106,82,30,0,39.5,0.286,38,0 143 | 2,108,52,26,63,32.5,0.318,22,0 144 | 10,108,66,0,0,32.4,0.272,42,1 145 | 4,154,62,31,284,32.8,0.237,23,0 146 | 0,102,75,23,0,0.0,0.572,21,0 147 | 9,57,80,37,0,32.8,0.096,41,0 148 | 2,106,64,35,119,30.5,1.400,34,0 149 | 5,147,78,0,0,33.7,0.218,65,0 150 | 2,90,70,17,0,27.3,0.085,22,0 151 | 1,136,74,50,204,37.4,0.399,24,0 152 | 4,114,65,0,0,21.9,0.432,37,0 153 | 9,156,86,28,155,34.3,1.189,42,1 154 | 1,153,82,42,485,40.6,0.687,23,0 155 | 8,188,78,0,0,47.9,0.137,43,1 156 | 7,152,88,44,0,50.0,0.337,36,1 157 | 2,99,52,15,94,24.6,0.637,21,0 158 | 1,109,56,21,135,25.2,0.833,23,0 159 | 2,88,74,19,53,29.0,0.229,22,0 160 | 17,163,72,41,114,40.9,0.817,47,1 161 | 4,151,90,38,0,29.7,0.294,36,0 162 | 7,102,74,40,105,37.2,0.204,45,0 163 | 0,114,80,34,285,44.2,0.167,27,0 164 | 2,100,64,23,0,29.7,0.368,21,0 165 | 0,131,88,0,0,31.6,0.743,32,1 166 | 6,104,74,18,156,29.9,0.722,41,1 167 | 3,148,66,25,0,32.5,0.256,22,0 168 | 4,120,68,0,0,29.6,0.709,34,0 169 | 4,110,66,0,0,31.9,0.471,29,0 170 | 3,111,90,12,78,28.4,0.495,29,0 171 | 6,102,82,0,0,30.8,0.180,36,1 172 | 6,134,70,23,130,35.4,0.542,29,1 173 | 2,87,0,23,0,28.9,0.773,25,0 174 | 1,79,60,42,48,43.5,0.678,23,0 175 | 2,75,64,24,55,29.7,0.370,33,0 176 | 8,179,72,42,130,32.7,0.719,36,1 177 | 6,85,78,0,0,31.2,0.382,42,0 178 | 0,129,110,46,130,67.1,0.319,26,1 179 | 5,143,78,0,0,45.0,0.190,47,0 180 | 5,130,82,0,0,39.1,0.956,37,1 181 | 6,87,80,0,0,23.2,0.084,32,0 182 | 0,119,64,18,92,34.9,0.725,23,0 183 | 1,0,74,20,23,27.7,0.299,21,0 184 | 5,73,60,0,0,26.8,0.268,27,0 185 | 4,141,74,0,0,27.6,0.244,40,0 186 | 7,194,68,28,0,35.9,0.745,41,1 187 | 8,181,68,36,495,30.1,0.615,60,1 188 | 1,128,98,41,58,32.0,1.321,33,1 189 | 8,109,76,39,114,27.9,0.640,31,1 190 | 5,139,80,35,160,31.6,0.361,25,1 191 | 3,111,62,0,0,22.6,0.142,21,0 192 | 9,123,70,44,94,33.1,0.374,40,0 193 | 7,159,66,0,0,30.4,0.383,36,1 194 | 11,135,0,0,0,52.3,0.578,40,1 195 | 8,85,55,20,0,24.4,0.136,42,0 196 | 5,158,84,41,210,39.4,0.395,29,1 197 | 1,105,58,0,0,24.3,0.187,21,0 198 | 3,107,62,13,48,22.9,0.678,23,1 199 | 4,109,64,44,99,34.8,0.905,26,1 200 | 4,148,60,27,318,30.9,0.150,29,1 201 | 0,113,80,16,0,31.0,0.874,21,0 202 | 1,138,82,0,0,40.1,0.236,28,0 203 | 0,108,68,20,0,27.3,0.787,32,0 204 | 2,99,70,16,44,20.4,0.235,27,0 205 | 6,103,72,32,190,37.7,0.324,55,0 206 | 5,111,72,28,0,23.9,0.407,27,0 207 | 8,196,76,29,280,37.5,0.605,57,1 208 | 5,162,104,0,0,37.7,0.151,52,1 209 | 1,96,64,27,87,33.2,0.289,21,0 210 | 7,184,84,33,0,35.5,0.355,41,1 211 | 2,81,60,22,0,27.7,0.290,25,0 212 | 0,147,85,54,0,42.8,0.375,24,0 213 | 7,179,95,31,0,34.2,0.164,60,0 214 | 0,140,65,26,130,42.6,0.431,24,1 215 | 9,112,82,32,175,34.2,0.260,36,1 216 | 12,151,70,40,271,41.8,0.742,38,1 217 | 5,109,62,41,129,35.8,0.514,25,1 218 | 6,125,68,30,120,30.0,0.464,32,0 219 | 5,85,74,22,0,29.0,1.224,32,1 220 | 5,112,66,0,0,37.8,0.261,41,1 221 | 0,177,60,29,478,34.6,1.072,21,1 222 | 2,158,90,0,0,31.6,0.805,66,1 223 | 7,119,0,0,0,25.2,0.209,37,0 224 | 7,142,60,33,190,28.8,0.687,61,0 225 | 1,100,66,15,56,23.6,0.666,26,0 226 | 1,87,78,27,32,34.6,0.101,22,0 227 | 0,101,76,0,0,35.7,0.198,26,0 228 | 3,162,52,38,0,37.2,0.652,24,1 229 | 4,197,70,39,744,36.7,2.329,31,0 230 | 0,117,80,31,53,45.2,0.089,24,0 231 | 4,142,86,0,0,44.0,0.645,22,1 232 | 6,134,80,37,370,46.2,0.238,46,1 233 | 1,79,80,25,37,25.4,0.583,22,0 234 | 4,122,68,0,0,35.0,0.394,29,0 235 | 3,74,68,28,45,29.7,0.293,23,0 236 | 4,171,72,0,0,43.6,0.479,26,1 237 | 7,181,84,21,192,35.9,0.586,51,1 238 | 0,179,90,27,0,44.1,0.686,23,1 239 | 9,164,84,21,0,30.8,0.831,32,1 240 | 0,104,76,0,0,18.4,0.582,27,0 241 | 1,91,64,24,0,29.2,0.192,21,0 242 | 4,91,70,32,88,33.1,0.446,22,0 243 | 3,139,54,0,0,25.6,0.402,22,1 244 | 6,119,50,22,176,27.1,1.318,33,1 245 | 2,146,76,35,194,38.2,0.329,29,0 246 | 9,184,85,15,0,30.0,1.213,49,1 247 | 10,122,68,0,0,31.2,0.258,41,0 248 | 0,165,90,33,680,52.3,0.427,23,0 249 | 9,124,70,33,402,35.4,0.282,34,0 250 | 1,111,86,19,0,30.1,0.143,23,0 251 | 9,106,52,0,0,31.2,0.380,42,0 252 | 2,129,84,0,0,28.0,0.284,27,0 253 | 2,90,80,14,55,24.4,0.249,24,0 254 | 0,86,68,32,0,35.8,0.238,25,0 255 | 12,92,62,7,258,27.6,0.926,44,1 256 | 1,113,64,35,0,33.6,0.543,21,1 257 | 3,111,56,39,0,30.1,0.557,30,0 258 | 2,114,68,22,0,28.7,0.092,25,0 259 | 1,193,50,16,375,25.9,0.655,24,0 260 | 11,155,76,28,150,33.3,1.353,51,1 261 | 3,191,68,15,130,30.9,0.299,34,0 262 | 3,141,0,0,0,30.0,0.761,27,1 263 | 4,95,70,32,0,32.1,0.612,24,0 264 | 3,142,80,15,0,32.4,0.200,63,0 265 | 4,123,62,0,0,32.0,0.226,35,1 266 | 5,96,74,18,67,33.6,0.997,43,0 267 | 0,138,0,0,0,36.3,0.933,25,1 268 | 2,128,64,42,0,40.0,1.101,24,0 269 | 0,102,52,0,0,25.1,0.078,21,0 270 | 2,146,0,0,0,27.5,0.240,28,1 271 | 10,101,86,37,0,45.6,1.136,38,1 272 | 2,108,62,32,56,25.2,0.128,21,0 273 | 3,122,78,0,0,23.0,0.254,40,0 274 | 1,71,78,50,45,33.2,0.422,21,0 275 | 13,106,70,0,0,34.2,0.251,52,0 276 | 2,100,70,52,57,40.5,0.677,25,0 277 | 7,106,60,24,0,26.5,0.296,29,1 278 | 0,104,64,23,116,27.8,0.454,23,0 279 | 5,114,74,0,0,24.9,0.744,57,0 280 | 2,108,62,10,278,25.3,0.881,22,0 281 | 0,146,70,0,0,37.9,0.334,28,1 282 | 10,129,76,28,122,35.9,0.280,39,0 283 | 7,133,88,15,155,32.4,0.262,37,0 284 | 7,161,86,0,0,30.4,0.165,47,1 285 | 2,108,80,0,0,27.0,0.259,52,1 286 | 7,136,74,26,135,26.0,0.647,51,0 287 | 5,155,84,44,545,38.7,0.619,34,0 288 | 1,119,86,39,220,45.6,0.808,29,1 289 | 4,96,56,17,49,20.8,0.340,26,0 290 | 5,108,72,43,75,36.1,0.263,33,0 291 | 0,78,88,29,40,36.9,0.434,21,0 292 | 0,107,62,30,74,36.6,0.757,25,1 293 | 2,128,78,37,182,43.3,1.224,31,1 294 | 1,128,48,45,194,40.5,0.613,24,1 295 | 0,161,50,0,0,21.9,0.254,65,0 296 | 6,151,62,31,120,35.5,0.692,28,0 297 | 2,146,70,38,360,28.0,0.337,29,1 298 | 0,126,84,29,215,30.7,0.520,24,0 299 | 14,100,78,25,184,36.6,0.412,46,1 300 | 8,112,72,0,0,23.6,0.840,58,0 301 | 0,167,0,0,0,32.3,0.839,30,1 302 | 2,144,58,33,135,31.6,0.422,25,1 303 | 5,77,82,41,42,35.8,0.156,35,0 304 | 5,115,98,0,0,52.9,0.209,28,1 305 | 3,150,76,0,0,21.0,0.207,37,0 306 | 2,120,76,37,105,39.7,0.215,29,0 307 | 10,161,68,23,132,25.5,0.326,47,1 308 | 0,137,68,14,148,24.8,0.143,21,0 309 | 0,128,68,19,180,30.5,1.391,25,1 310 | 2,124,68,28,205,32.9,0.875,30,1 311 | 6,80,66,30,0,26.2,0.313,41,0 312 | 0,106,70,37,148,39.4,0.605,22,0 313 | 2,155,74,17,96,26.6,0.433,27,1 314 | 3,113,50,10,85,29.5,0.626,25,0 315 | 7,109,80,31,0,35.9,1.127,43,1 316 | 2,112,68,22,94,34.1,0.315,26,0 317 | 3,99,80,11,64,19.3,0.284,30,0 318 | 3,182,74,0,0,30.5,0.345,29,1 319 | 3,115,66,39,140,38.1,0.150,28,0 320 | 6,194,78,0,0,23.5,0.129,59,1 321 | 4,129,60,12,231,27.5,0.527,31,0 322 | 3,112,74,30,0,31.6,0.197,25,1 323 | 0,124,70,20,0,27.4,0.254,36,1 324 | 13,152,90,33,29,26.8,0.731,43,1 325 | 2,112,75,32,0,35.7,0.148,21,0 326 | 1,157,72,21,168,25.6,0.123,24,0 327 | 1,122,64,32,156,35.1,0.692,30,1 328 | 10,179,70,0,0,35.1,0.200,37,0 329 | 2,102,86,36,120,45.5,0.127,23,1 330 | 6,105,70,32,68,30.8,0.122,37,0 331 | 8,118,72,19,0,23.1,1.476,46,0 332 | 2,87,58,16,52,32.7,0.166,25,0 333 | 1,180,0,0,0,43.3,0.282,41,1 334 | 12,106,80,0,0,23.6,0.137,44,0 335 | 1,95,60,18,58,23.9,0.260,22,0 336 | 0,165,76,43,255,47.9,0.259,26,0 337 | 0,117,0,0,0,33.8,0.932,44,0 338 | 5,115,76,0,0,31.2,0.343,44,1 339 | 9,152,78,34,171,34.2,0.893,33,1 340 | 7,178,84,0,0,39.9,0.331,41,1 341 | 1,130,70,13,105,25.9,0.472,22,0 342 | 1,95,74,21,73,25.9,0.673,36,0 343 | 1,0,68,35,0,32.0,0.389,22,0 344 | 5,122,86,0,0,34.7,0.290,33,0 345 | 8,95,72,0,0,36.8,0.485,57,0 346 | 8,126,88,36,108,38.5,0.349,49,0 347 | 1,139,46,19,83,28.7,0.654,22,0 348 | 3,116,0,0,0,23.5,0.187,23,0 349 | 3,99,62,19,74,21.8,0.279,26,0 350 | 5,0,80,32,0,41.0,0.346,37,1 351 | 4,92,80,0,0,42.2,0.237,29,0 352 | 4,137,84,0,0,31.2,0.252,30,0 353 | 3,61,82,28,0,34.4,0.243,46,0 354 | 1,90,62,12,43,27.2,0.580,24,0 355 | 3,90,78,0,0,42.7,0.559,21,0 356 | 9,165,88,0,0,30.4,0.302,49,1 357 | 1,125,50,40,167,33.3,0.962,28,1 358 | 13,129,0,30,0,39.9,0.569,44,1 359 | 12,88,74,40,54,35.3,0.378,48,0 360 | 1,196,76,36,249,36.5,0.875,29,1 361 | 5,189,64,33,325,31.2,0.583,29,1 362 | 5,158,70,0,0,29.8,0.207,63,0 363 | 5,103,108,37,0,39.2,0.305,65,0 364 | 4,146,78,0,0,38.5,0.520,67,1 365 | 4,147,74,25,293,34.9,0.385,30,0 366 | 5,99,54,28,83,34.0,0.499,30,0 367 | 6,124,72,0,0,27.6,0.368,29,1 368 | 0,101,64,17,0,21.0,0.252,21,0 369 | 3,81,86,16,66,27.5,0.306,22,0 370 | 1,133,102,28,140,32.8,0.234,45,1 371 | 3,173,82,48,465,38.4,2.137,25,1 372 | 0,118,64,23,89,0.0,1.731,21,0 373 | 0,84,64,22,66,35.8,0.545,21,0 374 | 2,105,58,40,94,34.9,0.225,25,0 375 | 2,122,52,43,158,36.2,0.816,28,0 376 | 12,140,82,43,325,39.2,0.528,58,1 377 | 0,98,82,15,84,25.2,0.299,22,0 378 | 1,87,60,37,75,37.2,0.509,22,0 379 | 4,156,75,0,0,48.3,0.238,32,1 380 | 0,93,100,39,72,43.4,1.021,35,0 381 | 1,107,72,30,82,30.8,0.821,24,0 382 | 0,105,68,22,0,20.0,0.236,22,0 383 | 1,109,60,8,182,25.4,0.947,21,0 384 | 1,90,62,18,59,25.1,1.268,25,0 385 | 1,125,70,24,110,24.3,0.221,25,0 386 | 1,119,54,13,50,22.3,0.205,24,0 387 | 5,116,74,29,0,32.3,0.660,35,1 388 | 8,105,100,36,0,43.3,0.239,45,1 389 | 5,144,82,26,285,32.0,0.452,58,1 390 | 3,100,68,23,81,31.6,0.949,28,0 391 | 1,100,66,29,196,32.0,0.444,42,0 392 | 5,166,76,0,0,45.7,0.340,27,1 393 | 1,131,64,14,415,23.7,0.389,21,0 394 | 4,116,72,12,87,22.1,0.463,37,0 395 | 4,158,78,0,0,32.9,0.803,31,1 396 | 2,127,58,24,275,27.7,1.600,25,0 397 | 3,96,56,34,115,24.7,0.944,39,0 398 | 0,131,66,40,0,34.3,0.196,22,1 399 | 3,82,70,0,0,21.1,0.389,25,0 400 | 3,193,70,31,0,34.9,0.241,25,1 401 | 4,95,64,0,0,32.0,0.161,31,1 402 | 6,137,61,0,0,24.2,0.151,55,0 403 | 5,136,84,41,88,35.0,0.286,35,1 404 | 9,72,78,25,0,31.6,0.280,38,0 405 | 5,168,64,0,0,32.9,0.135,41,1 406 | 2,123,48,32,165,42.1,0.520,26,0 407 | 4,115,72,0,0,28.9,0.376,46,1 408 | 0,101,62,0,0,21.9,0.336,25,0 409 | 8,197,74,0,0,25.9,1.191,39,1 410 | 1,172,68,49,579,42.4,0.702,28,1 411 | 6,102,90,39,0,35.7,0.674,28,0 412 | 1,112,72,30,176,34.4,0.528,25,0 413 | 1,143,84,23,310,42.4,1.076,22,0 414 | 1,143,74,22,61,26.2,0.256,21,0 415 | 0,138,60,35,167,34.6,0.534,21,1 416 | 3,173,84,33,474,35.7,0.258,22,1 417 | 1,97,68,21,0,27.2,1.095,22,0 418 | 4,144,82,32,0,38.5,0.554,37,1 419 | 1,83,68,0,0,18.2,0.624,27,0 420 | 3,129,64,29,115,26.4,0.219,28,1 421 | 1,119,88,41,170,45.3,0.507,26,0 422 | 2,94,68,18,76,26.0,0.561,21,0 423 | 0,102,64,46,78,40.6,0.496,21,0 424 | 2,115,64,22,0,30.8,0.421,21,0 425 | 8,151,78,32,210,42.9,0.516,36,1 426 | 4,184,78,39,277,37.0,0.264,31,1 427 | 0,94,0,0,0,0.0,0.256,25,0 428 | 1,181,64,30,180,34.1,0.328,38,1 429 | 0,135,94,46,145,40.6,0.284,26,0 430 | 1,95,82,25,180,35.0,0.233,43,1 431 | 2,99,0,0,0,22.2,0.108,23,0 432 | 3,89,74,16,85,30.4,0.551,38,0 433 | 1,80,74,11,60,30.0,0.527,22,0 434 | 2,139,75,0,0,25.6,0.167,29,0 435 | 1,90,68,8,0,24.5,1.138,36,0 436 | 0,141,0,0,0,42.4,0.205,29,1 437 | 12,140,85,33,0,37.4,0.244,41,0 438 | 5,147,75,0,0,29.9,0.434,28,0 439 | 1,97,70,15,0,18.2,0.147,21,0 440 | 6,107,88,0,0,36.8,0.727,31,0 441 | 0,189,104,25,0,34.3,0.435,41,1 442 | 2,83,66,23,50,32.2,0.497,22,0 443 | 4,117,64,27,120,33.2,0.230,24,0 444 | 8,108,70,0,0,30.5,0.955,33,1 445 | 4,117,62,12,0,29.7,0.380,30,1 446 | 0,180,78,63,14,59.4,2.420,25,1 447 | 1,100,72,12,70,25.3,0.658,28,0 448 | 0,95,80,45,92,36.5,0.330,26,0 449 | 0,104,64,37,64,33.6,0.510,22,1 450 | 0,120,74,18,63,30.5,0.285,26,0 451 | 1,82,64,13,95,21.2,0.415,23,0 452 | 2,134,70,0,0,28.9,0.542,23,1 453 | 0,91,68,32,210,39.9,0.381,25,0 454 | 2,119,0,0,0,19.6,0.832,72,0 455 | 2,100,54,28,105,37.8,0.498,24,0 456 | 14,175,62,30,0,33.6,0.212,38,1 457 | 1,135,54,0,0,26.7,0.687,62,0 458 | 5,86,68,28,71,30.2,0.364,24,0 459 | 10,148,84,48,237,37.6,1.001,51,1 460 | 9,134,74,33,60,25.9,0.460,81,0 461 | 9,120,72,22,56,20.8,0.733,48,0 462 | 1,71,62,0,0,21.8,0.416,26,0 463 | 8,74,70,40,49,35.3,0.705,39,0 464 | 5,88,78,30,0,27.6,0.258,37,0 465 | 10,115,98,0,0,24.0,1.022,34,0 466 | 0,124,56,13,105,21.8,0.452,21,0 467 | 0,74,52,10,36,27.8,0.269,22,0 468 | 0,97,64,36,100,36.8,0.600,25,0 469 | 8,120,0,0,0,30.0,0.183,38,1 470 | 6,154,78,41,140,46.1,0.571,27,0 471 | 1,144,82,40,0,41.3,0.607,28,0 472 | 0,137,70,38,0,33.2,0.170,22,0 473 | 0,119,66,27,0,38.8,0.259,22,0 474 | 7,136,90,0,0,29.9,0.210,50,0 475 | 4,114,64,0,0,28.9,0.126,24,0 476 | 0,137,84,27,0,27.3,0.231,59,0 477 | 2,105,80,45,191,33.7,0.711,29,1 478 | 7,114,76,17,110,23.8,0.466,31,0 479 | 8,126,74,38,75,25.9,0.162,39,0 480 | 4,132,86,31,0,28.0,0.419,63,0 481 | 3,158,70,30,328,35.5,0.344,35,1 482 | 0,123,88,37,0,35.2,0.197,29,0 483 | 4,85,58,22,49,27.8,0.306,28,0 484 | 0,84,82,31,125,38.2,0.233,23,0 485 | 0,145,0,0,0,44.2,0.630,31,1 486 | 0,135,68,42,250,42.3,0.365,24,1 487 | 1,139,62,41,480,40.7,0.536,21,0 488 | 0,173,78,32,265,46.5,1.159,58,0 489 | 4,99,72,17,0,25.6,0.294,28,0 490 | 8,194,80,0,0,26.1,0.551,67,0 491 | 2,83,65,28,66,36.8,0.629,24,0 492 | 2,89,90,30,0,33.5,0.292,42,0 493 | 4,99,68,38,0,32.8,0.145,33,0 494 | 4,125,70,18,122,28.9,1.144,45,1 495 | 3,80,0,0,0,0.0,0.174,22,0 496 | 6,166,74,0,0,26.6,0.304,66,0 497 | 5,110,68,0,0,26.0,0.292,30,0 498 | 2,81,72,15,76,30.1,0.547,25,0 499 | 7,195,70,33,145,25.1,0.163,55,1 500 | 6,154,74,32,193,29.3,0.839,39,0 501 | 2,117,90,19,71,25.2,0.313,21,0 502 | 3,84,72,32,0,37.2,0.267,28,0 503 | 6,0,68,41,0,39.0,0.727,41,1 504 | 7,94,64,25,79,33.3,0.738,41,0 505 | 3,96,78,39,0,37.3,0.238,40,0 506 | 10,75,82,0,0,33.3,0.263,38,0 507 | 0,180,90,26,90,36.5,0.314,35,1 508 | 1,130,60,23,170,28.6,0.692,21,0 509 | 2,84,50,23,76,30.4,0.968,21,0 510 | 8,120,78,0,0,25.0,0.409,64,0 511 | 12,84,72,31,0,29.7,0.297,46,1 512 | 0,139,62,17,210,22.1,0.207,21,0 513 | 9,91,68,0,0,24.2,0.200,58,0 514 | 2,91,62,0,0,27.3,0.525,22,0 515 | 3,99,54,19,86,25.6,0.154,24,0 516 | 3,163,70,18,105,31.6,0.268,28,1 517 | 9,145,88,34,165,30.3,0.771,53,1 518 | 7,125,86,0,0,37.6,0.304,51,0 519 | 13,76,60,0,0,32.8,0.180,41,0 520 | 6,129,90,7,326,19.6,0.582,60,0 521 | 2,68,70,32,66,25.0,0.187,25,0 522 | 3,124,80,33,130,33.2,0.305,26,0 523 | 6,114,0,0,0,0.0,0.189,26,0 524 | 9,130,70,0,0,34.2,0.652,45,1 525 | 3,125,58,0,0,31.6,0.151,24,0 526 | 3,87,60,18,0,21.8,0.444,21,0 527 | 1,97,64,19,82,18.2,0.299,21,0 528 | 3,116,74,15,105,26.3,0.107,24,0 529 | 0,117,66,31,188,30.8,0.493,22,0 530 | 0,111,65,0,0,24.6,0.660,31,0 531 | 2,122,60,18,106,29.8,0.717,22,0 532 | 0,107,76,0,0,45.3,0.686,24,0 533 | 1,86,66,52,65,41.3,0.917,29,0 534 | 6,91,0,0,0,29.8,0.501,31,0 535 | 1,77,56,30,56,33.3,1.251,24,0 536 | 4,132,0,0,0,32.9,0.302,23,1 537 | 0,105,90,0,0,29.6,0.197,46,0 538 | 0,57,60,0,0,21.7,0.735,67,0 539 | 0,127,80,37,210,36.3,0.804,23,0 540 | 3,129,92,49,155,36.4,0.968,32,1 541 | 8,100,74,40,215,39.4,0.661,43,1 542 | 3,128,72,25,190,32.4,0.549,27,1 543 | 10,90,85,32,0,34.9,0.825,56,1 544 | 4,84,90,23,56,39.5,0.159,25,0 545 | 1,88,78,29,76,32.0,0.365,29,0 546 | 8,186,90,35,225,34.5,0.423,37,1 547 | 5,187,76,27,207,43.6,1.034,53,1 548 | 4,131,68,21,166,33.1,0.160,28,0 549 | 1,164,82,43,67,32.8,0.341,50,0 550 | 4,189,110,31,0,28.5,0.680,37,0 551 | 1,116,70,28,0,27.4,0.204,21,0 552 | 3,84,68,30,106,31.9,0.591,25,0 553 | 6,114,88,0,0,27.8,0.247,66,0 554 | 1,88,62,24,44,29.9,0.422,23,0 555 | 1,84,64,23,115,36.9,0.471,28,0 556 | 7,124,70,33,215,25.5,0.161,37,0 557 | 1,97,70,40,0,38.1,0.218,30,0 558 | 8,110,76,0,0,27.8,0.237,58,0 559 | 11,103,68,40,0,46.2,0.126,42,0 560 | 11,85,74,0,0,30.1,0.300,35,0 561 | 6,125,76,0,0,33.8,0.121,54,1 562 | 0,198,66,32,274,41.3,0.502,28,1 563 | 1,87,68,34,77,37.6,0.401,24,0 564 | 6,99,60,19,54,26.9,0.497,32,0 565 | 0,91,80,0,0,32.4,0.601,27,0 566 | 2,95,54,14,88,26.1,0.748,22,0 567 | 1,99,72,30,18,38.6,0.412,21,0 568 | 6,92,62,32,126,32.0,0.085,46,0 569 | 4,154,72,29,126,31.3,0.338,37,0 570 | 0,121,66,30,165,34.3,0.203,33,1 571 | 3,78,70,0,0,32.5,0.270,39,0 572 | 2,130,96,0,0,22.6,0.268,21,0 573 | 3,111,58,31,44,29.5,0.430,22,0 574 | 2,98,60,17,120,34.7,0.198,22,0 575 | 1,143,86,30,330,30.1,0.892,23,0 576 | 1,119,44,47,63,35.5,0.280,25,0 577 | 6,108,44,20,130,24.0,0.813,35,0 578 | 2,118,80,0,0,42.9,0.693,21,1 579 | 10,133,68,0,0,27.0,0.245,36,0 580 | 2,197,70,99,0,34.7,0.575,62,1 581 | 0,151,90,46,0,42.1,0.371,21,1 582 | 6,109,60,27,0,25.0,0.206,27,0 583 | 12,121,78,17,0,26.5,0.259,62,0 584 | 8,100,76,0,0,38.7,0.190,42,0 585 | 8,124,76,24,600,28.7,0.687,52,1 586 | 1,93,56,11,0,22.5,0.417,22,0 587 | 8,143,66,0,0,34.9,0.129,41,1 588 | 6,103,66,0,0,24.3,0.249,29,0 589 | 3,176,86,27,156,33.3,1.154,52,1 590 | 0,73,0,0,0,21.1,0.342,25,0 591 | 11,111,84,40,0,46.8,0.925,45,1 592 | 2,112,78,50,140,39.4,0.175,24,0 593 | 3,132,80,0,0,34.4,0.402,44,1 594 | 2,82,52,22,115,28.5,1.699,25,0 595 | 6,123,72,45,230,33.6,0.733,34,0 596 | 0,188,82,14,185,32.0,0.682,22,1 597 | 0,67,76,0,0,45.3,0.194,46,0 598 | 1,89,24,19,25,27.8,0.559,21,0 599 | 1,173,74,0,0,36.8,0.088,38,1 600 | 1,109,38,18,120,23.1,0.407,26,0 601 | 1,108,88,19,0,27.1,0.400,24,0 602 | 6,96,0,0,0,23.7,0.190,28,0 603 | 1,124,74,36,0,27.8,0.100,30,0 604 | 7,150,78,29,126,35.2,0.692,54,1 605 | 4,183,0,0,0,28.4,0.212,36,1 606 | 1,124,60,32,0,35.8,0.514,21,0 607 | 1,181,78,42,293,40.0,1.258,22,1 608 | 1,92,62,25,41,19.5,0.482,25,0 609 | 0,152,82,39,272,41.5,0.270,27,0 610 | 1,111,62,13,182,24.0,0.138,23,0 611 | 3,106,54,21,158,30.9,0.292,24,0 612 | 3,174,58,22,194,32.9,0.593,36,1 613 | 7,168,88,42,321,38.2,0.787,40,1 614 | 6,105,80,28,0,32.5,0.878,26,0 615 | 11,138,74,26,144,36.1,0.557,50,1 616 | 3,106,72,0,0,25.8,0.207,27,0 617 | 6,117,96,0,0,28.7,0.157,30,0 618 | 2,68,62,13,15,20.1,0.257,23,0 619 | 9,112,82,24,0,28.2,1.282,50,1 620 | 0,119,0,0,0,32.4,0.141,24,1 621 | 2,112,86,42,160,38.4,0.246,28,0 622 | 2,92,76,20,0,24.2,1.698,28,0 623 | 6,183,94,0,0,40.8,1.461,45,0 624 | 0,94,70,27,115,43.5,0.347,21,0 625 | 2,108,64,0,0,30.8,0.158,21,0 626 | 4,90,88,47,54,37.7,0.362,29,0 627 | 0,125,68,0,0,24.7,0.206,21,0 628 | 0,132,78,0,0,32.4,0.393,21,0 629 | 5,128,80,0,0,34.6,0.144,45,0 630 | 4,94,65,22,0,24.7,0.148,21,0 631 | 7,114,64,0,0,27.4,0.732,34,1 632 | 0,102,78,40,90,34.5,0.238,24,0 633 | 2,111,60,0,0,26.2,0.343,23,0 634 | 1,128,82,17,183,27.5,0.115,22,0 635 | 10,92,62,0,0,25.9,0.167,31,0 636 | 13,104,72,0,0,31.2,0.465,38,1 637 | 5,104,74,0,0,28.8,0.153,48,0 638 | 2,94,76,18,66,31.6,0.649,23,0 639 | 7,97,76,32,91,40.9,0.871,32,1 640 | 1,100,74,12,46,19.5,0.149,28,0 641 | 0,102,86,17,105,29.3,0.695,27,0 642 | 4,128,70,0,0,34.3,0.303,24,0 643 | 6,147,80,0,0,29.5,0.178,50,1 644 | 4,90,0,0,0,28.0,0.610,31,0 645 | 3,103,72,30,152,27.6,0.730,27,0 646 | 2,157,74,35,440,39.4,0.134,30,0 647 | 1,167,74,17,144,23.4,0.447,33,1 648 | 0,179,50,36,159,37.8,0.455,22,1 649 | 11,136,84,35,130,28.3,0.260,42,1 650 | 0,107,60,25,0,26.4,0.133,23,0 651 | 1,91,54,25,100,25.2,0.234,23,0 652 | 1,117,60,23,106,33.8,0.466,27,0 653 | 5,123,74,40,77,34.1,0.269,28,0 654 | 2,120,54,0,0,26.8,0.455,27,0 655 | 1,106,70,28,135,34.2,0.142,22,0 656 | 2,155,52,27,540,38.7,0.240,25,1 657 | 2,101,58,35,90,21.8,0.155,22,0 658 | 1,120,80,48,200,38.9,1.162,41,0 659 | 11,127,106,0,0,39.0,0.190,51,0 660 | 3,80,82,31,70,34.2,1.292,27,1 661 | 10,162,84,0,0,27.7,0.182,54,0 662 | 1,199,76,43,0,42.9,1.394,22,1 663 | 8,167,106,46,231,37.6,0.165,43,1 664 | 9,145,80,46,130,37.9,0.637,40,1 665 | 6,115,60,39,0,33.7,0.245,40,1 666 | 1,112,80,45,132,34.8,0.217,24,0 667 | 4,145,82,18,0,32.5,0.235,70,1 668 | 10,111,70,27,0,27.5,0.141,40,1 669 | 6,98,58,33,190,34.0,0.430,43,0 670 | 9,154,78,30,100,30.9,0.164,45,0 671 | 6,165,68,26,168,33.6,0.631,49,0 672 | 1,99,58,10,0,25.4,0.551,21,0 673 | 10,68,106,23,49,35.5,0.285,47,0 674 | 3,123,100,35,240,57.3,0.880,22,0 675 | 8,91,82,0,0,35.6,0.587,68,0 676 | 6,195,70,0,0,30.9,0.328,31,1 677 | 9,156,86,0,0,24.8,0.230,53,1 678 | 0,93,60,0,0,35.3,0.263,25,0 679 | 3,121,52,0,0,36.0,0.127,25,1 680 | 2,101,58,17,265,24.2,0.614,23,0 681 | 2,56,56,28,45,24.2,0.332,22,0 682 | 0,162,76,36,0,49.6,0.364,26,1 683 | 0,95,64,39,105,44.6,0.366,22,0 684 | 4,125,80,0,0,32.3,0.536,27,1 685 | 5,136,82,0,0,0.0,0.640,69,0 686 | 2,129,74,26,205,33.2,0.591,25,0 687 | 3,130,64,0,0,23.1,0.314,22,0 688 | 1,107,50,19,0,28.3,0.181,29,0 689 | 1,140,74,26,180,24.1,0.828,23,0 690 | 1,144,82,46,180,46.1,0.335,46,1 691 | 8,107,80,0,0,24.6,0.856,34,0 692 | 13,158,114,0,0,42.3,0.257,44,1 693 | 2,121,70,32,95,39.1,0.886,23,0 694 | 7,129,68,49,125,38.5,0.439,43,1 695 | 2,90,60,0,0,23.5,0.191,25,0 696 | 7,142,90,24,480,30.4,0.128,43,1 697 | 3,169,74,19,125,29.9,0.268,31,1 698 | 0,99,0,0,0,25.0,0.253,22,0 699 | 4,127,88,11,155,34.5,0.598,28,0 700 | 4,118,70,0,0,44.5,0.904,26,0 701 | 2,122,76,27,200,35.9,0.483,26,0 702 | 6,125,78,31,0,27.6,0.565,49,1 703 | 1,168,88,29,0,35.0,0.905,52,1 704 | 2,129,0,0,0,38.5,0.304,41,0 705 | 4,110,76,20,100,28.4,0.118,27,0 706 | 6,80,80,36,0,39.8,0.177,28,0 707 | 10,115,0,0,0,0.0,0.261,30,1 708 | 2,127,46,21,335,34.4,0.176,22,0 709 | 9,164,78,0,0,32.8,0.148,45,1 710 | 2,93,64,32,160,38.0,0.674,23,1 711 | 3,158,64,13,387,31.2,0.295,24,0 712 | 5,126,78,27,22,29.6,0.439,40,0 713 | 10,129,62,36,0,41.2,0.441,38,1 714 | 0,134,58,20,291,26.4,0.352,21,0 715 | 3,102,74,0,0,29.5,0.121,32,0 716 | 7,187,50,33,392,33.9,0.826,34,1 717 | 3,173,78,39,185,33.8,0.970,31,1 718 | 10,94,72,18,0,23.1,0.595,56,0 719 | 1,108,60,46,178,35.5,0.415,24,0 720 | 5,97,76,27,0,35.6,0.378,52,1 721 | 4,83,86,19,0,29.3,0.317,34,0 722 | 1,114,66,36,200,38.1,0.289,21,0 723 | 1,149,68,29,127,29.3,0.349,42,1 724 | 5,117,86,30,105,39.1,0.251,42,0 725 | 1,111,94,0,0,32.8,0.265,45,0 726 | 4,112,78,40,0,39.4,0.236,38,0 727 | 1,116,78,29,180,36.1,0.496,25,0 728 | 0,141,84,26,0,32.4,0.433,22,0 729 | 2,175,88,0,0,22.9,0.326,22,0 730 | 2,92,52,0,0,30.1,0.141,22,0 731 | 3,130,78,23,79,28.4,0.323,34,1 732 | 8,120,86,0,0,28.4,0.259,22,1 733 | 2,174,88,37,120,44.5,0.646,24,1 734 | 2,106,56,27,165,29.0,0.426,22,0 735 | 2,105,75,0,0,23.3,0.560,53,0 736 | 4,95,60,32,0,35.4,0.284,28,0 737 | 0,126,86,27,120,27.4,0.515,21,0 738 | 8,65,72,23,0,32.0,0.600,42,0 739 | 2,99,60,17,160,36.6,0.453,21,0 740 | 1,102,74,0,0,39.5,0.293,42,1 741 | 11,120,80,37,150,42.3,0.785,48,1 742 | 3,102,44,20,94,30.8,0.400,26,0 743 | 1,109,58,18,116,28.5,0.219,22,0 744 | 9,140,94,0,0,32.7,0.734,45,1 745 | 13,153,88,37,140,40.6,1.174,39,0 746 | 12,100,84,33,105,30.0,0.488,46,0 747 | 1,147,94,41,0,49.3,0.358,27,1 748 | 1,81,74,41,57,46.3,1.096,32,0 749 | 3,187,70,22,200,36.4,0.408,36,1 750 | 6,162,62,0,0,24.3,0.178,50,1 751 | 4,136,70,0,0,31.2,1.182,22,1 752 | 1,121,78,39,74,39.0,0.261,28,0 753 | 3,108,62,24,0,26.0,0.223,25,0 754 | 0,181,88,44,510,43.3,0.222,26,1 755 | 8,154,78,32,0,32.4,0.443,45,1 756 | 1,128,88,39,110,36.5,1.057,37,1 757 | 7,137,90,41,0,32.0,0.391,39,0 758 | 0,123,72,0,0,36.3,0.258,52,1 759 | 1,106,76,0,0,37.5,0.197,26,0 760 | 6,190,92,0,0,35.5,0.278,66,1 761 | 2,88,58,26,16,28.4,0.766,22,0 762 | 9,170,74,31,0,44.0,0.403,43,1 763 | 9,89,62,0,0,22.5,0.142,33,0 764 | 10,101,76,48,180,32.9,0.171,63,0 765 | 2,122,70,27,0,36.8,0.340,27,0 766 | 5,121,72,23,112,26.2,0.245,30,0 767 | 1,126,60,0,0,30.1,0.349,47,1 768 | 1,93,70,31,0,30.4,0.315,23,0 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Naive-bayes-explained 2 | This is a very in depth explination of naive bayes w.r.t implementation in python which can be used in Machine Learning applications. 3 | --------------------------------------------------------------------------------