From 5aab293e848991a67963790a0d2b626803be8be1 Mon Sep 17 00:00:00 2001 From: codebasics Date: Fri, 8 Oct 2021 13:26:58 -0400 Subject: [PATCH] pca --- ...disease_prediction_exercise_solution.ipynb | 2054 +++++++++++++++++ ML/18_PCA/Exercise/heart.csv | 919 ++++++++ ML/18_PCA/PCA_tutorial_digits.ipynb | 1497 ++++++++++++ ML/18_PCA/pca_exercise.md | 15 + 4 files changed, 4485 insertions(+) create mode 100644 ML/18_PCA/Exercise/PCA_heart_disease_prediction_exercise_solution.ipynb create mode 100644 ML/18_PCA/Exercise/heart.csv create mode 100644 ML/18_PCA/PCA_tutorial_digits.ipynb create mode 100644 ML/18_PCA/pca_exercise.md diff --git a/ML/18_PCA/Exercise/PCA_heart_disease_prediction_exercise_solution.ipynb b/ML/18_PCA/Exercise/PCA_heart_disease_prediction_exercise_solution.ipynb new file mode 100644 index 00000000..d09432d0 --- /dev/null +++ b/ML/18_PCA/Exercise/PCA_heart_disease_prediction_exercise_solution.ipynb @@ -0,0 +1,2054 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

PCA Machine Learning Tutorial Exercise Solution

" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
040MATA1402890Normal172N0.0Up0
149FNAP1601800Normal156N1.0Flat1
237MATA1302830ST98N0.0Up0
348FASY1382140Normal108Y1.5Flat1
454MNAP1501950Normal122N0.0Up0
\n", + "
" + ], + "text/plain": [ + " Age Sex ChestPainType RestingBP Cholesterol FastingBS RestingECG MaxHR \\\n", + "0 40 M ATA 140 289 0 Normal 172 \n", + "1 49 F NAP 160 180 0 Normal 156 \n", + "2 37 M ATA 130 283 0 ST 98 \n", + "3 48 F ASY 138 214 0 Normal 108 \n", + "4 54 M NAP 150 195 0 Normal 122 \n", + "\n", + " ExerciseAngina Oldpeak ST_Slope HeartDisease \n", + "0 N 0.0 Up 0 \n", + "1 N 1.0 Flat 1 \n", + "2 N 0.0 Up 0 \n", + "3 Y 1.5 Flat 1 \n", + "4 N 0.0 Up 0 " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "# https://www.kaggle.com/fedesoriano/heart-failure-prediction\n", + "df = pd.read_csv(\"heart.csv\")\n", + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(918, 12)" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeRestingBPCholesterolFastingBSMaxHROldpeakHeartDisease
count918.000000918.000000918.000000918.000000918.000000918.000000918.000000
mean53.510893132.396514198.7995640.233115136.8093680.8873640.553377
std9.43261718.514154109.3841450.42304625.4603341.0665700.497414
min28.0000000.0000000.0000000.00000060.000000-2.6000000.000000
25%47.000000120.000000173.2500000.000000120.0000000.0000000.000000
50%54.000000130.000000223.0000000.000000138.0000000.6000001.000000
75%60.000000140.000000267.0000000.000000156.0000001.5000001.000000
max77.000000200.000000603.0000001.000000202.0000006.2000001.000000
\n", + "
" + ], + "text/plain": [ + " Age RestingBP Cholesterol FastingBS MaxHR \\\n", + "count 918.000000 918.000000 918.000000 918.000000 918.000000 \n", + "mean 53.510893 132.396514 198.799564 0.233115 136.809368 \n", + "std 9.432617 18.514154 109.384145 0.423046 25.460334 \n", + "min 28.000000 0.000000 0.000000 0.000000 60.000000 \n", + "25% 47.000000 120.000000 173.250000 0.000000 120.000000 \n", + "50% 54.000000 130.000000 223.000000 0.000000 138.000000 \n", + "75% 60.000000 140.000000 267.000000 0.000000 156.000000 \n", + "max 77.000000 200.000000 603.000000 1.000000 202.000000 \n", + "\n", + " Oldpeak HeartDisease \n", + "count 918.000000 918.000000 \n", + "mean 0.887364 0.553377 \n", + "std 1.066570 0.497414 \n", + "min -2.600000 0.000000 \n", + "25% 0.000000 0.000000 \n", + "50% 0.600000 1.000000 \n", + "75% 1.500000 1.000000 \n", + "max 6.200000 1.000000 " + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.describe()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Treat Outliers

" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
7632MASY1185290Normal130N0.0Flat1
14954MASY1306031Normal125Y1.0Flat1
61667FNAP1155640LVH160N1.6Flat0
\n", + "
" + ], + "text/plain": [ + " Age Sex ChestPainType RestingBP Cholesterol FastingBS RestingECG \\\n", + "76 32 M ASY 118 529 0 Normal \n", + "149 54 M ASY 130 603 1 Normal \n", + "616 67 F NAP 115 564 0 LVH \n", + "\n", + " MaxHR ExerciseAngina Oldpeak ST_Slope HeartDisease \n", + "76 130 N 0.0 Flat 1 \n", + "149 125 Y 1.0 Flat 1 \n", + "616 160 N 1.6 Flat 0 " + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[df.Cholesterol>(df.Cholesterol.mean()+3*df.Cholesterol.std())]" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(918, 12)" + ] + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(915, 12)" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df1 = df[df.Cholesterol<=(df.Cholesterol.mean()+3*df.Cholesterol.std())]\n", + "df1.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [Age, Sex, ChestPainType, RestingBP, Cholesterol, FastingBS, RestingECG, MaxHR, ExerciseAngina, Oldpeak, ST_Slope, HeartDisease]\n", + "Index: []" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[df.MaxHR>(df.MaxHR.mean()+3*df.MaxHR.std())]" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [Age, Sex, ChestPainType, RestingBP, Cholesterol, FastingBS, RestingECG, MaxHR, ExerciseAngina, Oldpeak, ST_Slope, HeartDisease]\n", + "Index: []" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[df.FastingBS>(df.FastingBS.mean()+3*df.FastingBS.std())]" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
16650MASY1402310ST140Y5.0Flat1
70259MTA1782700LVH145N4.2Down0
77155MASY1402170Normal111Y5.6Down1
79151MASY1402980Normal122Y4.2Flat1
85062FASY1601640LVH145N6.2Down1
90058MASY1143180ST140N4.4Down1
\n", + "
" + ], + "text/plain": [ + " Age Sex ChestPainType RestingBP Cholesterol FastingBS RestingECG \\\n", + "166 50 M ASY 140 231 0 ST \n", + "702 59 M TA 178 270 0 LVH \n", + "771 55 M ASY 140 217 0 Normal \n", + "791 51 M ASY 140 298 0 Normal \n", + "850 62 F ASY 160 164 0 LVH \n", + "900 58 M ASY 114 318 0 ST \n", + "\n", + " MaxHR ExerciseAngina Oldpeak ST_Slope HeartDisease \n", + "166 140 Y 5.0 Flat 1 \n", + "702 145 N 4.2 Down 0 \n", + "771 111 Y 5.6 Down 1 \n", + "791 122 Y 4.2 Flat 1 \n", + "850 145 N 6.2 Down 1 \n", + "900 140 N 4.4 Down 1 " + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[df.Oldpeak>(df.Oldpeak.mean()+3*df.Oldpeak.std())]" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(909, 12)" + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df2 = df1[df1.Oldpeak<=(df1.Oldpeak.mean()+3*df1.Oldpeak.std())]\n", + "df2.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
10939MATA1902410Normal106N0.0Up0
24154MASY2001980Normal142Y2.0Flat1
36564FASY20000Normal140Y1.0Flat1
39961MNAP20001ST70N0.0Flat1
59261MASY1902871LVH150Y2.0Down1
73256FASY2002881LVH133Y4.0Down1
75954MATA1922830LVH195N0.0Up1
\n", + "
" + ], + "text/plain": [ + " Age Sex ChestPainType RestingBP Cholesterol FastingBS RestingECG \\\n", + "109 39 M ATA 190 241 0 Normal \n", + "241 54 M ASY 200 198 0 Normal \n", + "365 64 F ASY 200 0 0 Normal \n", + "399 61 M NAP 200 0 1 ST \n", + "592 61 M ASY 190 287 1 LVH \n", + "732 56 F ASY 200 288 1 LVH \n", + "759 54 M ATA 192 283 0 LVH \n", + "\n", + " MaxHR ExerciseAngina Oldpeak ST_Slope HeartDisease \n", + "109 106 N 0.0 Up 0 \n", + "241 142 Y 2.0 Flat 1 \n", + "365 140 Y 1.0 Flat 1 \n", + "399 70 N 0.0 Flat 1 \n", + "592 150 Y 2.0 Down 1 \n", + "732 133 Y 4.0 Down 1 \n", + "759 195 N 0.0 Up 1 " + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[df.RestingBP>(df.RestingBP.mean()+3*df.RestingBP.std())]" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(902, 12)" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df3 = df2[df2.RestingBP<=(df2.RestingBP.mean()+3*df2.RestingBP.std())]\n", + "df3.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['ATA', 'NAP', 'ASY', 'TA'], dtype=object)" + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.ChestPainType.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['Normal', 'ST', 'LVH'], dtype=object)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.RestingECG.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['N', 'Y'], dtype=object)" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.ExerciseAngina.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['Up', 'Flat', 'Down'], dtype=object)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.ST_Slope.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeSexChestPainTypeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDisease
040MATA1402890117200.030
149FNAP1601800115601.021
237MATA130283029800.030
348FASY1382140110811.521
454MNAP1501950112200.030
\n", + "
" + ], + "text/plain": [ + " Age Sex ChestPainType RestingBP Cholesterol FastingBS RestingECG \\\n", + "0 40 M ATA 140 289 0 1 \n", + "1 49 F NAP 160 180 0 1 \n", + "2 37 M ATA 130 283 0 2 \n", + "3 48 F ASY 138 214 0 1 \n", + "4 54 M NAP 150 195 0 1 \n", + "\n", + " MaxHR ExerciseAngina Oldpeak ST_Slope HeartDisease \n", + "0 172 0 0.0 3 0 \n", + "1 156 0 1.0 2 1 \n", + "2 98 0 0.0 3 0 \n", + "3 108 1 1.5 2 1 \n", + "4 122 0 0.0 3 0 " + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df4 = df3.copy()\n", + "df4.ExerciseAngina.replace(\n", + " {\n", + " 'N': 0,\n", + " 'Y': 1\n", + " },\n", + " inplace=True)\n", + "\n", + "df4.ST_Slope.replace(\n", + " {\n", + " 'Down': 1,\n", + " 'Flat': 2,\n", + " 'Up': 3\n", + " },\n", + " inplace=True\n", + ")\n", + "\n", + "df4.RestingECG.replace(\n", + " {\n", + " 'Normal': 1,\n", + " 'ST': 2,\n", + " 'LVH': 3\n", + " },\n", + " inplace=True)\n", + "\n", + "df4.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeHeartDiseaseSex_MChestPainType_ATAChestPainType_NAPChestPainType_TA
0401402890117200.0301100
1491601800115601.0210010
237130283029800.0301100
3481382140110811.5210000
4541501950112200.0301010
\n", + "
" + ], + "text/plain": [ + " Age RestingBP Cholesterol FastingBS RestingECG MaxHR ExerciseAngina \\\n", + "0 40 140 289 0 1 172 0 \n", + "1 49 160 180 0 1 156 0 \n", + "2 37 130 283 0 2 98 0 \n", + "3 48 138 214 0 1 108 1 \n", + "4 54 150 195 0 1 122 0 \n", + "\n", + " Oldpeak ST_Slope HeartDisease Sex_M ChestPainType_ATA \\\n", + "0 0.0 3 0 1 1 \n", + "1 1.0 2 1 0 0 \n", + "2 0.0 3 0 1 1 \n", + "3 1.5 2 1 0 0 \n", + "4 0.0 3 0 1 0 \n", + "\n", + " ChestPainType_NAP ChestPainType_TA \n", + "0 0 0 \n", + "1 1 0 \n", + "2 0 0 \n", + "3 0 0 \n", + "4 1 0 " + ] + }, + "execution_count": 99, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df5 = pd.get_dummies(df4, drop_first=True)\n", + "df5.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeSex_MChestPainType_ATAChestPainType_NAPChestPainType_TA
0401402890117200.031100
1491601800115601.020010
237130283029800.031100
3481382140110811.520000
4541501950112200.031010
\n", + "
" + ], + "text/plain": [ + " Age RestingBP Cholesterol FastingBS RestingECG MaxHR ExerciseAngina \\\n", + "0 40 140 289 0 1 172 0 \n", + "1 49 160 180 0 1 156 0 \n", + "2 37 130 283 0 2 98 0 \n", + "3 48 138 214 0 1 108 1 \n", + "4 54 150 195 0 1 122 0 \n", + "\n", + " Oldpeak ST_Slope Sex_M ChestPainType_ATA ChestPainType_NAP \\\n", + "0 0.0 3 1 1 0 \n", + "1 1.0 2 0 0 1 \n", + "2 0.0 3 1 1 0 \n", + "3 1.5 2 0 0 0 \n", + "4 0.0 3 1 0 1 \n", + "\n", + " ChestPainType_TA \n", + "0 0 \n", + "1 0 \n", + "2 0 \n", + "3 0 \n", + "4 0 " + ] + }, + "execution_count": 100, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X = df5.drop(\"HeartDisease\",axis='columns')\n", + "y = df5.HeartDisease\n", + "\n", + "X.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[-1.42896269, 0.46089071, 0.85238015, ..., 2.06757196,\n", + " -0.53547478, -0.22914788],\n", + " [-0.47545956, 1.5925728 , -0.16132855, ..., -0.4836591 ,\n", + " 1.86750159, -0.22914788],\n", + " [-1.74679706, -0.10495034, 0.79657967, ..., 2.06757196,\n", + " -0.53547478, -0.22914788],\n", + " ...,\n", + " [ 0.37209878, -0.10495034, -0.61703246, ..., -0.4836591 ,\n", + " -0.53547478, -0.22914788],\n", + " [ 0.37209878, -0.10495034, 0.35947592, ..., 2.06757196,\n", + " -0.53547478, -0.22914788],\n", + " [-1.64085227, 0.3477225 , -0.20782894, ..., -0.4836591 ,\n", + " 1.86750159, -0.22914788]])" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.preprocessing import StandardScaler\n", + "\n", + "scaler = StandardScaler()\n", + "X_scaled = scaler.fit_transform(X)\n", + "X_scaled" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "\n", + "X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.2, random_state=30)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(721, 13)" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X_train.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(181, 13)" + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X_test.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.8784530386740331" + ] + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.ensemble import RandomForestClassifier\n", + "\n", + "model_rf = RandomForestClassifier()\n", + "model_rf.fit(X_train, y_train)\n", + "model_rf.score(X_test, y_test)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Use PCA to reduce dimensions

" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
AgeRestingBPCholesterolFastingBSRestingECGMaxHRExerciseAnginaOldpeakST_SlopeSex_MChestPainType_ATAChestPainType_NAPChestPainType_TA
0401402890117200.031100
1491601800115601.020010
237130283029800.031100
3481382140110811.520000
4541501950112200.031010
..........................................
913451102640113201.221001
914681441931114103.421000
915571301310111511.221000
916571302360317400.020100
917381381750117300.031010
\n", + "

902 rows × 13 columns

\n", + "
" + ], + "text/plain": [ + " Age RestingBP Cholesterol FastingBS RestingECG MaxHR \\\n", + "0 40 140 289 0 1 172 \n", + "1 49 160 180 0 1 156 \n", + "2 37 130 283 0 2 98 \n", + "3 48 138 214 0 1 108 \n", + "4 54 150 195 0 1 122 \n", + ".. ... ... ... ... ... ... \n", + "913 45 110 264 0 1 132 \n", + "914 68 144 193 1 1 141 \n", + "915 57 130 131 0 1 115 \n", + "916 57 130 236 0 3 174 \n", + "917 38 138 175 0 1 173 \n", + "\n", + " ExerciseAngina Oldpeak ST_Slope Sex_M ChestPainType_ATA \\\n", + "0 0 0.0 3 1 1 \n", + "1 0 1.0 2 0 0 \n", + "2 0 0.0 3 1 1 \n", + "3 1 1.5 2 0 0 \n", + "4 0 0.0 3 1 0 \n", + ".. ... ... ... ... ... \n", + "913 0 1.2 2 1 0 \n", + "914 0 3.4 2 1 0 \n", + "915 1 1.2 2 1 0 \n", + "916 0 0.0 2 0 1 \n", + "917 0 0.0 3 1 0 \n", + "\n", + " ChestPainType_NAP ChestPainType_TA \n", + "0 0 0 \n", + "1 1 0 \n", + "2 0 0 \n", + "3 0 0 \n", + "4 1 0 \n", + ".. ... ... \n", + "913 0 1 \n", + "914 0 0 \n", + "915 0 0 \n", + "916 0 0 \n", + "917 1 0 \n", + "\n", + "[902 rows x 13 columns]" + ] + }, + "execution_count": 120, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X" + ] + }, + { + "cell_type": "code", + "execution_count": 121, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 93.82465373, -29.40099458],\n", + " [-15.58422331, -14.10909233],\n", + " [ 83.29606634, 38.6867453 ],\n", + " ...,\n", + " [-67.57318721, 17.61319354],\n", + " [ 40.70458237, -33.38750602],\n", + " [-19.91368346, -37.29085722]])" + ] + }, + "execution_count": 121, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.decomposition import PCA\n", + "\n", + "pca = PCA(0.95)\n", + "X_pca = pca.fit_transform(X)\n", + "X_pca" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": {}, + "outputs": [], + "source": [ + "X_train_pca, X_test_pca, y_train, y_test = train_test_split(X_pca, y, test_size=0.2, random_state=30)" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.7348066298342542" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.ensemble import RandomForestClassifier\n", + "\n", + "model_rf = RandomForestClassifier()\n", + "model_rf.fit(X_train_pca, y_train)\n", + "model_rf.score(X_test_pca, y_test)" + ] + } + ], + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/ML/18_PCA/Exercise/heart.csv b/ML/18_PCA/Exercise/heart.csv new file mode 100644 index 00000000..5d9bce69 --- /dev/null +++ b/ML/18_PCA/Exercise/heart.csv @@ -0,0 +1,919 @@ +Age,Sex,ChestPainType,RestingBP,Cholesterol,FastingBS,RestingECG,MaxHR,ExerciseAngina,Oldpeak,ST_Slope,HeartDisease +40,M,ATA,140,289,0,Normal,172,N,0,Up,0 +49,F,NAP,160,180,0,Normal,156,N,1,Flat,1 +37,M,ATA,130,283,0,ST,98,N,0,Up,0 +48,F,ASY,138,214,0,Normal,108,Y,1.5,Flat,1 +54,M,NAP,150,195,0,Normal,122,N,0,Up,0 +39,M,NAP,120,339,0,Normal,170,N,0,Up,0 +45,F,ATA,130,237,0,Normal,170,N,0,Up,0 +54,M,ATA,110,208,0,Normal,142,N,0,Up,0 +37,M,ASY,140,207,0,Normal,130,Y,1.5,Flat,1 +48,F,ATA,120,284,0,Normal,120,N,0,Up,0 +37,F,NAP,130,211,0,Normal,142,N,0,Up,0 +58,M,ATA,136,164,0,ST,99,Y,2,Flat,1 +39,M,ATA,120,204,0,Normal,145,N,0,Up,0 +49,M,ASY,140,234,0,Normal,140,Y,1,Flat,1 +42,F,NAP,115,211,0,ST,137,N,0,Up,0 +54,F,ATA,120,273,0,Normal,150,N,1.5,Flat,0 +38,M,ASY,110,196,0,Normal,166,N,0,Flat,1 +43,F,ATA,120,201,0,Normal,165,N,0,Up,0 +60,M,ASY,100,248,0,Normal,125,N,1,Flat,1 +36,M,ATA,120,267,0,Normal,160,N,3,Flat,1 +43,F,TA,100,223,0,Normal,142,N,0,Up,0 +44,M,ATA,120,184,0,Normal,142,N,1,Flat,0 +49,F,ATA,124,201,0,Normal,164,N,0,Up,0 +44,M,ATA,150,288,0,Normal,150,Y,3,Flat,1 +40,M,NAP,130,215,0,Normal,138,N,0,Up,0 +36,M,NAP,130,209,0,Normal,178,N,0,Up,0 +53,M,ASY,124,260,0,ST,112,Y,3,Flat,0 +52,M,ATA,120,284,0,Normal,118,N,0,Up,0 +53,F,ATA,113,468,0,Normal,127,N,0,Up,0 +51,M,ATA,125,188,0,Normal,145,N,0,Up,0 +53,M,NAP,145,518,0,Normal,130,N,0,Flat,1 +56,M,NAP,130,167,0,Normal,114,N,0,Up,0 +54,M,ASY,125,224,0,Normal,122,N,2,Flat,1 +41,M,ASY,130,172,0,ST,130,N,2,Flat,1 +43,F,ATA,150,186,0,Normal,154,N,0,Up,0 +32,M,ATA,125,254,0,Normal,155,N,0,Up,0 +65,M,ASY,140,306,1,Normal,87,Y,1.5,Flat,1 +41,F,ATA,110,250,0,ST,142,N,0,Up,0 +48,F,ATA,120,177,1,ST,148,N,0,Up,0 +48,F,ASY,150,227,0,Normal,130,Y,1,Flat,0 +54,F,ATA,150,230,0,Normal,130,N,0,Up,0 +54,F,NAP,130,294,0,ST,100,Y,0,Flat,1 +35,M,ATA,150,264,0,Normal,168,N,0,Up,0 +52,M,NAP,140,259,0,ST,170,N,0,Up,0 +43,M,ASY,120,175,0,Normal,120,Y,1,Flat,1 +59,M,NAP,130,318,0,Normal,120,Y,1,Flat,0 +37,M,ASY,120,223,0,Normal,168,N,0,Up,0 +50,M,ATA,140,216,0,Normal,170,N,0,Up,0 +36,M,NAP,112,340,0,Normal,184,N,1,Flat,0 +41,M,ASY,110,289,0,Normal,170,N,0,Flat,1 +50,M,ASY,130,233,0,Normal,121,Y,2,Flat,1 +47,F,ASY,120,205,0,Normal,98,Y,2,Flat,1 +45,M,ATA,140,224,1,Normal,122,N,0,Up,0 +41,F,ATA,130,245,0,Normal,150,N,0,Up,0 +52,F,ASY,130,180,0,Normal,140,Y,1.5,Flat,0 +51,F,ATA,160,194,0,Normal,170,N,0,Up,0 +31,M,ASY,120,270,0,Normal,153,Y,1.5,Flat,1 +58,M,NAP,130,213,0,ST,140,N,0,Flat,1 +54,M,ASY,150,365,0,ST,134,N,1,Up,0 +52,M,ASY,112,342,0,ST,96,Y,1,Flat,1 +49,M,ATA,100,253,0,Normal,174,N,0,Up,0 +43,F,NAP,150,254,0,Normal,175,N,0,Up,0 +45,M,ASY,140,224,0,Normal,144,N,0,Up,0 +46,M,ASY,120,277,0,Normal,125,Y,1,Flat,1 +50,F,ATA,110,202,0,Normal,145,N,0,Up,0 +37,F,ATA,120,260,0,Normal,130,N,0,Up,0 +45,F,ASY,132,297,0,Normal,144,N,0,Up,0 +32,M,ATA,110,225,0,Normal,184,N,0,Up,0 +52,M,ASY,160,246,0,ST,82,Y,4,Flat,1 +44,M,ASY,150,412,0,Normal,170,N,0,Up,0 +57,M,ATA,140,265,0,ST,145,Y,1,Flat,1 +44,M,ATA,130,215,0,Normal,135,N,0,Up,0 +52,M,ASY,120,182,0,Normal,150,N,0,Flat,1 +44,F,ASY,120,218,0,ST,115,N,0,Up,0 +55,M,ASY,140,268,0,Normal,128,Y,1.5,Flat,1 +46,M,NAP,150,163,0,Normal,116,N,0,Up,0 +32,M,ASY,118,529,0,Normal,130,N,0,Flat,1 +35,F,ASY,140,167,0,Normal,150,N,0,Up,0 +52,M,ATA,140,100,0,Normal,138,Y,0,Up,0 +49,M,ASY,130,206,0,Normal,170,N,0,Flat,1 +55,M,NAP,110,277,0,Normal,160,N,0,Up,0 +54,M,ATA,120,238,0,Normal,154,N,0,Up,0 +63,M,ASY,150,223,0,Normal,115,N,0,Flat,1 +52,M,ATA,160,196,0,Normal,165,N,0,Up,0 +56,M,ASY,150,213,1,Normal,125,Y,1,Flat,1 +66,M,ASY,140,139,0,Normal,94,Y,1,Flat,1 +65,M,ASY,170,263,1,Normal,112,Y,2,Flat,1 +53,F,ATA,140,216,0,Normal,142,Y,2,Flat,0 +43,M,TA,120,291,0,ST,155,N,0,Flat,1 +55,M,ASY,140,229,0,Normal,110,Y,0.5,Flat,0 +49,F,ATA,110,208,0,Normal,160,N,0,Up,0 +39,M,ASY,130,307,0,Normal,140,N,0,Up,0 +52,F,ATA,120,210,0,Normal,148,N,0,Up,0 +48,M,ASY,160,329,0,Normal,92,Y,1.5,Flat,1 +39,F,NAP,110,182,0,ST,180,N,0,Up,0 +58,M,ASY,130,263,0,Normal,140,Y,2,Flat,1 +43,M,ATA,142,207,0,Normal,138,N,0,Up,0 +39,M,NAP,160,147,1,Normal,160,N,0,Up,0 +56,M,ASY,120,85,0,Normal,140,N,0,Up,0 +41,M,ATA,125,269,0,Normal,144,N,0,Up,0 +65,M,ASY,130,275,0,ST,115,Y,1,Flat,1 +51,M,ASY,130,179,0,Normal,100,N,0,Up,0 +40,F,ASY,150,392,0,Normal,130,N,2,Flat,1 +40,M,ASY,120,466,1,Normal,152,Y,1,Flat,1 +46,M,ASY,118,186,0,Normal,124,N,0,Flat,1 +57,M,ATA,140,260,1,Normal,140,N,0,Up,0 +48,F,ASY,120,254,0,ST,110,N,0,Up,0 +34,M,ATA,150,214,0,ST,168,N,0,Up,0 +50,M,ASY,140,129,0,Normal,135,N,0,Up,0 +39,M,ATA,190,241,0,Normal,106,N,0,Up,0 +59,F,ATA,130,188,0,Normal,124,N,1,Flat,0 +57,M,ASY,150,255,0,Normal,92,Y,3,Flat,1 +47,M,ASY,140,276,1,Normal,125,Y,0,Up,0 +38,M,ATA,140,297,0,Normal,150,N,0,Up,0 +49,F,NAP,130,207,0,ST,135,N,0,Up,0 +33,F,ASY,100,246,0,Normal,150,Y,1,Flat,1 +38,M,ASY,120,282,0,Normal,170,N,0,Flat,1 +59,F,ASY,130,338,1,ST,130,Y,1.5,Flat,1 +35,F,TA,120,160,0,ST,185,N,0,Up,0 +34,M,TA,140,156,0,Normal,180,N,0,Flat,1 +47,F,NAP,135,248,1,Normal,170,N,0,Flat,1 +52,F,NAP,125,272,0,Normal,139,N,0,Up,0 +46,M,ASY,110,240,0,ST,140,N,0,Up,0 +58,F,ATA,180,393,0,Normal,110,Y,1,Flat,1 +58,M,ATA,130,230,0,Normal,150,N,0,Up,0 +54,M,ATA,120,246,0,Normal,110,N,0,Up,0 +34,F,ATA,130,161,0,Normal,190,N,0,Up,0 +48,F,ASY,108,163,0,Normal,175,N,2,Up,0 +54,F,ATA,120,230,1,Normal,140,N,0,Up,0 +42,M,NAP,120,228,0,Normal,152,Y,1.5,Flat,0 +38,M,NAP,145,292,0,Normal,130,N,0,Up,0 +46,M,ASY,110,202,0,Normal,150,Y,0,Flat,1 +56,M,ASY,170,388,0,ST,122,Y,2,Flat,1 +56,M,ASY,150,230,0,ST,124,Y,1.5,Flat,1 +61,F,ASY,130,294,0,ST,120,Y,1,Flat,0 +49,M,NAP,115,265,0,Normal,175,N,0,Flat,1 +43,F,ATA,120,215,0,ST,175,N,0,Up,0 +39,M,ATA,120,241,0,ST,146,N,2,Up,0 +54,M,ASY,140,166,0,Normal,118,Y,0,Flat,1 +43,M,ASY,150,247,0,Normal,130,Y,2,Flat,1 +52,M,ASY,160,331,0,Normal,94,Y,2.5,Flat,1 +50,M,ASY,140,341,0,ST,125,Y,2.5,Flat,1 +47,M,ASY,160,291,0,ST,158,Y,3,Flat,1 +53,M,ASY,140,243,0,Normal,155,N,0,Up,0 +56,F,ATA,120,279,0,Normal,150,N,1,Flat,1 +39,M,ASY,110,273,0,Normal,132,N,0,Up,0 +42,M,ATA,120,198,0,Normal,155,N,0,Up,0 +43,F,ATA,120,249,0,ST,176,N,0,Up,0 +50,M,ATA,120,168,0,Normal,160,N,0,Up,0 +54,M,ASY,130,603,1,Normal,125,Y,1,Flat,1 +39,M,ATA,130,215,0,Normal,120,N,0,Up,0 +48,M,ATA,100,159,0,Normal,100,N,0,Up,0 +40,M,ATA,130,275,0,Normal,150,N,0,Up,0 +55,M,ASY,120,270,0,Normal,140,N,0,Up,0 +41,M,ATA,120,291,0,ST,160,N,0,Up,0 +56,M,ASY,155,342,1,Normal,150,Y,3,Flat,1 +38,M,ASY,110,190,0,Normal,150,Y,1,Flat,1 +49,M,ASY,140,185,0,Normal,130,N,0,Up,0 +44,M,ASY,130,290,0,Normal,100,Y,2,Flat,1 +54,M,ATA,160,195,0,ST,130,N,1,Up,0 +59,M,ASY,140,264,1,LVH,119,Y,0,Flat,1 +49,M,ASY,128,212,0,Normal,96,Y,0,Flat,1 +47,M,ATA,160,263,0,Normal,174,N,0,Up,0 +42,M,ATA,120,196,0,Normal,150,N,0,Up,0 +52,F,ATA,140,225,0,Normal,140,N,0,Up,0 +46,M,TA,140,272,1,Normal,175,N,2,Flat,1 +50,M,ASY,140,231,0,ST,140,Y,5,Flat,1 +48,M,ATA,140,238,0,Normal,118,N,0,Up,0 +58,M,ASY,135,222,0,Normal,100,N,0,Up,0 +58,M,NAP,140,179,0,Normal,160,N,0,Up,0 +29,M,ATA,120,243,0,Normal,160,N,0,Up,0 +40,M,NAP,140,235,0,Normal,188,N,0,Up,0 +53,M,ATA,140,320,0,Normal,162,N,0,Up,0 +49,M,NAP,140,187,0,Normal,172,N,0,Up,0 +52,M,ASY,140,266,0,Normal,134,Y,2,Flat,1 +43,M,ASY,140,288,0,Normal,135,Y,2,Flat,1 +54,M,ASY,140,216,0,Normal,105,N,1.5,Flat,1 +59,M,ATA,140,287,0,Normal,150,N,0,Up,0 +37,M,NAP,130,194,0,Normal,150,N,0,Up,0 +46,F,ASY,130,238,0,Normal,90,N,0,Up,0 +52,M,ASY,130,225,0,Normal,120,Y,2,Flat,1 +51,M,ATA,130,224,0,Normal,150,N,0,Up,0 +52,M,ASY,140,404,0,Normal,124,Y,2,Flat,1 +46,M,ASY,110,238,0,ST,140,Y,1,Flat,0 +54,F,ATA,160,312,0,Normal,130,N,0,Up,0 +58,M,NAP,160,211,1,ST,92,N,0,Flat,1 +58,M,ATA,130,251,0,Normal,110,N,0,Up,0 +41,M,ASY,120,237,1,Normal,138,Y,1,Flat,1 +50,F,ASY,120,328,0,Normal,110,Y,1,Flat,0 +53,M,ASY,180,285,0,ST,120,Y,1.5,Flat,1 +46,M,ASY,180,280,0,ST,120,N,0,Up,0 +50,M,ATA,170,209,0,ST,116,N,0,Up,0 +48,M,ATA,130,245,0,Normal,160,N,0,Up,0 +45,M,NAP,135,192,0,Normal,110,N,0,Up,0 +41,F,ATA,125,184,0,Normal,180,N,0,Up,0 +62,F,TA,160,193,0,Normal,116,N,0,Up,0 +49,M,ASY,120,297,0,Normal,132,N,1,Flat,0 +42,M,ATA,150,268,0,Normal,136,N,0,Up,0 +53,M,ASY,120,246,0,Normal,116,Y,0,Flat,1 +57,F,TA,130,308,0,Normal,98,N,1,Flat,0 +47,M,TA,110,249,0,Normal,150,N,0,Up,0 +46,M,NAP,120,230,0,Normal,150,N,0,Up,0 +42,M,NAP,160,147,0,Normal,146,N,0,Up,0 +31,F,ATA,100,219,0,ST,150,N,0,Up,0 +56,M,ATA,130,184,0,Normal,100,N,0,Up,0 +50,M,ASY,150,215,0,Normal,140,Y,0,Up,0 +35,M,ATA,120,308,0,LVH,180,N,0,Up,0 +35,M,ATA,110,257,0,Normal,140,N,0,Flat,1 +28,M,ATA,130,132,0,LVH,185,N,0,Up,0 +54,M,ASY,125,216,0,Normal,140,N,0,Flat,1 +48,M,ASY,106,263,1,Normal,110,N,0,Flat,1 +50,F,NAP,140,288,0,Normal,140,Y,0,Flat,1 +56,M,NAP,130,276,0,Normal,128,Y,1,Up,0 +56,F,NAP,130,219,0,ST,164,N,0,Up,0 +47,M,ASY,150,226,0,Normal,98,Y,1.5,Flat,1 +30,F,TA,170,237,0,ST,170,N,0,Up,0 +39,M,ASY,110,280,0,Normal,150,N,0,Flat,1 +54,M,NAP,120,217,0,Normal,137,N,0,Up,0 +55,M,ATA,140,196,0,Normal,150,N,0,Up,0 +29,M,ATA,140,263,0,Normal,170,N,0,Up,0 +46,M,ASY,130,222,0,Normal,112,N,0,Flat,1 +51,F,ASY,160,303,0,Normal,150,Y,1,Flat,1 +48,F,NAP,120,195,0,Normal,125,N,0,Up,0 +33,M,NAP,120,298,0,Normal,185,N,0,Up,0 +55,M,ATA,120,256,1,Normal,137,N,0,Up,0 +50,M,ASY,145,264,0,Normal,150,N,0,Flat,1 +53,M,NAP,120,195,0,Normal,140,N,0,Up,0 +38,M,ASY,92,117,0,Normal,134,Y,2.5,Flat,1 +41,M,ATA,120,295,0,Normal,170,N,0,Up,0 +37,F,ASY,130,173,0,ST,184,N,0,Up,0 +37,M,ASY,130,315,0,Normal,158,N,0,Up,0 +40,M,NAP,130,281,0,Normal,167,N,0,Up,0 +38,F,ATA,120,275,0,Normal,129,N,0,Up,0 +41,M,ASY,112,250,0,Normal,142,N,0,Up,0 +54,F,ATA,140,309,0,ST,140,N,0,Up,0 +39,M,ATA,120,200,0,Normal,160,Y,1,Flat,0 +41,M,ASY,120,336,0,Normal,118,Y,3,Flat,1 +55,M,TA,140,295,0,Normal,136,N,0,Flat,1 +48,M,ASY,160,355,0,Normal,99,Y,2,Flat,1 +48,M,ASY,160,193,0,Normal,102,Y,3,Flat,1 +55,M,ATA,145,326,0,Normal,155,N,0,Up,0 +54,M,ASY,200,198,0,Normal,142,Y,2,Flat,1 +55,M,ATA,160,292,1,Normal,143,Y,2,Flat,1 +43,F,ATA,120,266,0,Normal,118,N,0,Up,0 +48,M,ASY,160,268,0,Normal,103,Y,1,Flat,1 +54,M,TA,120,171,0,Normal,137,N,2,Up,0 +54,M,NAP,120,237,0,Normal,150,Y,1.5,Flat,1 +48,M,ASY,122,275,1,ST,150,Y,2,Down,1 +45,M,ASY,130,219,0,ST,130,Y,1,Flat,1 +49,M,ASY,130,341,0,Normal,120,Y,1,Flat,1 +44,M,ASY,135,491,0,Normal,135,N,0,Flat,1 +48,M,ASY,120,260,0,Normal,115,N,2,Flat,1 +61,M,ASY,125,292,0,ST,115,Y,0,Up,0 +62,M,ATA,140,271,0,Normal,152,N,1,Up,0 +55,M,ASY,145,248,0,Normal,96,Y,2,Flat,1 +53,F,NAP,120,274,0,Normal,130,N,0,Up,0 +55,F,ATA,130,394,0,LVH,150,N,0,Up,0 +36,M,NAP,150,160,0,Normal,172,N,0,Up,0 +51,F,NAP,150,200,0,Normal,120,N,0.5,Up,0 +55,F,ATA,122,320,0,Normal,155,N,0,Up,0 +46,M,ATA,140,275,0,Normal,165,Y,0,Up,0 +54,F,ATA,120,221,0,Normal,138,N,1,Up,0 +46,M,ASY,120,231,0,Normal,115,Y,0,Flat,1 +59,M,ASY,130,126,0,Normal,125,N,0,Flat,1 +47,M,NAP,140,193,0,Normal,145,Y,1,Flat,1 +54,M,ATA,160,305,0,Normal,175,N,0,Up,0 +52,M,ASY,130,298,0,Normal,110,Y,1,Flat,1 +34,M,ATA,98,220,0,Normal,150,N,0,Up,0 +54,M,ASY,130,242,0,Normal,91,Y,1,Flat,1 +47,F,NAP,130,235,0,Normal,145,N,2,Flat,0 +45,M,ASY,120,225,0,Normal,140,N,0,Up,0 +32,F,ATA,105,198,0,Normal,165,N,0,Up,0 +55,M,ASY,140,201,0,Normal,130,Y,3,Flat,1 +55,M,NAP,120,220,0,LVH,134,N,0,Up,0 +45,F,ATA,180,295,0,Normal,180,N,0,Up,0 +59,M,NAP,180,213,0,Normal,100,N,0,Up,0 +51,M,NAP,135,160,0,Normal,150,N,2,Flat,1 +52,M,ASY,170,223,0,Normal,126,Y,1.5,Flat,1 +57,F,ASY,180,347,0,ST,126,Y,0.8,Flat,0 +54,F,ATA,130,253,0,ST,155,N,0,Up,0 +60,M,NAP,120,246,0,LVH,135,N,0,Up,0 +49,M,ASY,150,222,0,Normal,122,N,2,Flat,1 +51,F,NAP,130,220,0,Normal,160,Y,2,Up,0 +55,F,ATA,110,344,0,ST,160,N,0,Up,0 +42,M,ASY,140,358,0,Normal,170,N,0,Up,0 +51,F,NAP,110,190,0,Normal,120,N,0,Up,0 +59,M,ASY,140,169,0,Normal,140,N,0,Up,0 +53,M,ATA,120,181,0,Normal,132,N,0,Up,0 +48,F,ATA,133,308,0,ST,156,N,2,Up,0 +36,M,ATA,120,166,0,Normal,180,N,0,Up,0 +48,M,NAP,110,211,0,Normal,138,N,0,Up,0 +47,F,ATA,140,257,0,Normal,135,N,1,Up,0 +53,M,ASY,130,182,0,Normal,148,N,0,Up,0 +65,M,ASY,115,0,0,Normal,93,Y,0,Flat,1 +32,M,TA,95,0,1,Normal,127,N,0.7,Up,1 +61,M,ASY,105,0,1,Normal,110,Y,1.5,Up,1 +50,M,ASY,145,0,1,Normal,139,Y,0.7,Flat,1 +57,M,ASY,110,0,1,ST,131,Y,1.4,Up,1 +51,M,ASY,110,0,1,Normal,92,N,0,Flat,1 +47,M,ASY,110,0,1,ST,149,N,2.1,Up,1 +60,M,ASY,160,0,1,Normal,149,N,0.4,Flat,1 +55,M,ATA,140,0,0,ST,150,N,0.2,Up,0 +53,M,ASY,125,0,1,Normal,120,N,1.5,Up,1 +62,F,ASY,120,0,1,ST,123,Y,1.7,Down,1 +51,M,ASY,95,0,1,Normal,126,N,2.2,Flat,1 +51,F,ASY,120,0,1,Normal,127,Y,1.5,Up,1 +55,M,ASY,115,0,1,Normal,155,N,0.1,Flat,1 +53,M,ATA,130,0,0,ST,120,N,0.7,Down,0 +58,M,ASY,115,0,1,Normal,138,N,0.5,Up,1 +57,M,ASY,95,0,1,Normal,182,N,0.7,Down,1 +65,M,ASY,155,0,0,Normal,154,N,1,Up,0 +60,M,ASY,125,0,1,Normal,110,N,0.1,Up,1 +41,M,ASY,125,0,1,Normal,176,N,1.6,Up,1 +34,M,ASY,115,0,1,Normal,154,N,0.2,Up,1 +53,M,ASY,80,0,0,Normal,141,Y,2,Down,0 +74,M,ATA,145,0,1,ST,123,N,1.3,Up,1 +57,M,NAP,105,0,1,Normal,148,N,0.3,Flat,1 +56,M,ASY,140,0,1,Normal,121,Y,1.8,Up,1 +61,M,ASY,130,0,1,Normal,77,N,2.5,Flat,1 +68,M,ASY,145,0,1,Normal,136,N,1.8,Up,1 +59,M,NAP,125,0,1,Normal,175,N,2.6,Flat,1 +63,M,ASY,100,0,1,Normal,109,N,-0.9,Flat,1 +38,F,ASY,105,0,1,Normal,166,N,2.8,Up,1 +62,M,ASY,115,0,1,Normal,128,Y,2.5,Down,1 +46,M,ASY,100,0,1,ST,133,N,-2.6,Flat,1 +42,M,ASY,105,0,1,Normal,128,Y,-1.5,Down,1 +45,M,NAP,110,0,0,Normal,138,N,-0.1,Up,0 +59,M,ASY,125,0,1,Normal,119,Y,0.9,Up,1 +52,M,ASY,95,0,1,Normal,82,Y,0.8,Flat,1 +60,M,ASY,130,0,1,ST,130,Y,1.1,Down,1 +60,M,NAP,115,0,1,Normal,143,N,2.4,Up,1 +56,M,ASY,115,0,1,ST,82,N,-1,Up,1 +38,M,NAP,100,0,0,Normal,179,N,-1.1,Up,0 +40,M,ASY,95,0,1,ST,144,N,0,Up,1 +51,M,ASY,130,0,1,Normal,170,N,-0.7,Up,1 +62,M,TA,120,0,1,LVH,134,N,-0.8,Flat,1 +72,M,NAP,160,0,0,LVH,114,N,1.6,Flat,0 +63,M,ASY,150,0,1,ST,154,N,3.7,Up,1 +63,M,ASY,140,0,1,LVH,149,N,2,Up,1 +64,F,ASY,95,0,1,Normal,145,N,1.1,Down,1 +43,M,ASY,100,0,1,Normal,122,N,1.5,Down,1 +64,M,ASY,110,0,1,Normal,114,Y,1.3,Down,1 +61,M,ASY,110,0,1,Normal,113,N,1.4,Flat,1 +52,M,ASY,130,0,1,Normal,120,N,0,Flat,1 +51,M,ASY,120,0,1,Normal,104,N,0,Flat,1 +69,M,ASY,135,0,0,Normal,130,N,0,Flat,1 +59,M,ASY,120,0,0,Normal,115,N,0,Flat,1 +48,M,ASY,115,0,1,Normal,128,N,0,Flat,1 +69,M,ASY,137,0,0,ST,104,Y,1.6,Flat,1 +36,M,ASY,110,0,1,Normal,125,Y,1,Flat,1 +53,M,ASY,120,0,1,Normal,120,N,0,Flat,1 +43,M,ASY,140,0,0,ST,140,Y,0.5,Up,1 +56,M,ASY,120,0,0,ST,100,Y,-1,Down,1 +58,M,ASY,130,0,0,ST,100,Y,1,Flat,1 +55,M,ASY,120,0,0,ST,92,N,0.3,Up,1 +67,M,TA,145,0,0,LVH,125,N,0,Flat,1 +46,M,ASY,115,0,0,Normal,113,Y,1.5,Flat,1 +53,M,ATA,120,0,0,Normal,95,N,0,Flat,1 +38,M,NAP,115,0,0,Normal,128,Y,0,Flat,1 +53,M,NAP,105,0,0,Normal,115,N,0,Flat,1 +62,M,NAP,160,0,0,Normal,72,Y,0,Flat,1 +47,M,ASY,160,0,0,Normal,124,Y,0,Flat,1 +56,M,NAP,155,0,0,ST,99,N,0,Flat,1 +56,M,ASY,120,0,0,ST,148,N,0,Flat,1 +56,M,NAP,120,0,0,Normal,97,N,0,Flat,0 +64,F,ASY,200,0,0,Normal,140,Y,1,Flat,1 +61,M,ASY,150,0,0,Normal,117,Y,2,Flat,1 +68,M,ASY,135,0,0,ST,120,Y,0,Up,1 +57,M,ASY,140,0,0,Normal,120,Y,2,Flat,1 +63,M,ASY,150,0,0,Normal,86,Y,2,Flat,1 +60,M,ASY,135,0,0,Normal,63,Y,0.5,Up,1 +66,M,ASY,150,0,0,Normal,108,Y,2,Flat,1 +63,M,ASY,185,0,0,Normal,98,Y,0,Up,1 +59,M,ASY,135,0,0,Normal,115,Y,1,Flat,1 +61,M,ASY,125,0,0,Normal,105,Y,0,Down,1 +73,F,NAP,160,0,0,ST,121,N,0,Up,1 +47,M,NAP,155,0,0,Normal,118,Y,1,Flat,1 +65,M,ASY,160,0,1,ST,122,N,1.2,Flat,1 +70,M,ASY,140,0,1,Normal,157,Y,2,Flat,1 +50,M,ASY,120,0,0,ST,156,Y,0,Up,1 +60,M,ASY,160,0,0,ST,99,Y,0.5,Flat,1 +50,M,ASY,115,0,0,Normal,120,Y,0.5,Flat,1 +43,M,ASY,115,0,0,Normal,145,Y,2,Flat,1 +38,F,ASY,110,0,0,Normal,156,N,0,Flat,1 +54,M,ASY,120,0,0,Normal,155,N,0,Flat,1 +61,M,ASY,150,0,0,Normal,105,Y,0,Flat,1 +42,M,ASY,145,0,0,Normal,99,Y,0,Flat,1 +53,M,ASY,130,0,0,LVH,135,Y,1,Flat,1 +55,M,ASY,140,0,0,Normal,83,N,0,Flat,1 +61,M,ASY,160,0,1,ST,145,N,1,Flat,1 +51,M,ASY,140,0,0,Normal,60,N,0,Flat,1 +70,M,ASY,115,0,0,ST,92,Y,0,Flat,1 +61,M,ASY,130,0,0,LVH,115,N,0,Flat,1 +38,M,ASY,150,0,1,Normal,120,Y,0.7,Flat,1 +57,M,ASY,160,0,1,Normal,98,Y,2,Flat,1 +38,M,ASY,135,0,1,Normal,150,N,0,Flat,1 +62,F,TA,140,0,1,Normal,143,N,0,Flat,1 +58,M,ASY,170,0,1,ST,105,Y,0,Flat,1 +52,M,ASY,165,0,1,Normal,122,Y,1,Up,1 +61,M,NAP,200,0,1,ST,70,N,0,Flat,1 +50,F,ASY,160,0,1,Normal,110,N,0,Flat,1 +51,M,ASY,130,0,1,ST,163,N,0,Flat,1 +65,M,ASY,145,0,1,ST,67,N,0.7,Flat,1 +52,M,ASY,135,0,1,Normal,128,Y,2,Flat,1 +47,M,NAP,110,0,1,Normal,120,Y,0,Flat,1 +35,M,ASY,120,0,1,Normal,130,Y,1.2,Flat,1 +57,M,ASY,140,0,1,Normal,100,Y,0,Flat,1 +62,M,ASY,115,0,1,Normal,72,Y,-0.5,Flat,1 +59,M,ASY,110,0,1,Normal,94,N,0,Flat,1 +53,M,NAP,160,0,1,LVH,122,Y,0,Flat,1 +62,M,ASY,150,0,1,ST,78,N,2,Flat,1 +54,M,ASY,180,0,1,Normal,150,N,1.5,Flat,1 +56,M,ASY,125,0,1,Normal,103,Y,1,Flat,1 +56,M,NAP,125,0,1,Normal,98,N,-2,Flat,1 +54,M,ASY,130,0,1,Normal,110,Y,3,Flat,1 +66,F,ASY,155,0,1,Normal,90,N,0,Flat,1 +63,M,ASY,140,260,0,ST,112,Y,3,Flat,1 +44,M,ASY,130,209,0,ST,127,N,0,Up,0 +60,M,ASY,132,218,0,ST,140,Y,1.5,Down,1 +55,M,ASY,142,228,0,ST,149,Y,2.5,Up,1 +66,M,NAP,110,213,1,LVH,99,Y,1.3,Flat,0 +66,M,NAP,120,0,0,ST,120,N,-0.5,Up,0 +65,M,ASY,150,236,1,ST,105,Y,0,Flat,1 +60,M,NAP,180,0,0,ST,140,Y,1.5,Flat,0 +60,M,NAP,120,0,1,Normal,141,Y,2,Up,1 +60,M,ATA,160,267,1,ST,157,N,0.5,Flat,1 +56,M,ATA,126,166,0,ST,140,N,0,Up,0 +59,M,ASY,140,0,0,ST,117,Y,1,Flat,1 +62,M,ASY,110,0,0,Normal,120,Y,0.5,Flat,1 +63,M,NAP,133,0,0,LVH,120,Y,1,Flat,1 +57,M,ASY,128,0,1,ST,148,Y,1,Flat,1 +62,M,ASY,120,220,0,ST,86,N,0,Up,0 +63,M,ASY,170,177,0,Normal,84,Y,2.5,Down,1 +46,M,ASY,110,236,0,Normal,125,Y,2,Flat,1 +63,M,ASY,126,0,0,ST,120,N,1.5,Down,0 +60,M,ASY,152,0,0,ST,118,Y,0,Up,0 +58,M,ASY,116,0,0,Normal,124,N,1,Up,1 +64,M,ASY,120,0,1,ST,106,N,2,Flat,1 +63,M,NAP,130,0,0,ST,111,Y,0,Flat,1 +74,M,NAP,138,0,0,Normal,116,N,0.2,Up,0 +52,M,NAP,128,0,0,ST,180,N,3,Up,1 +69,M,ASY,130,0,1,ST,129,N,1,Flat,1 +51,M,ASY,128,0,1,ST,125,Y,1.2,Flat,1 +60,M,ASY,130,186,1,ST,140,Y,0.5,Flat,1 +56,M,ASY,120,100,0,Normal,120,Y,1.5,Flat,1 +55,M,NAP,136,228,0,ST,124,Y,1.6,Flat,1 +54,M,ASY,130,0,0,ST,117,Y,1.4,Flat,1 +77,M,ASY,124,171,0,ST,110,Y,2,Up,1 +63,M,ASY,160,230,1,Normal,105,Y,1,Flat,1 +55,M,NAP,0,0,0,Normal,155,N,1.5,Flat,1 +52,M,NAP,122,0,0,Normal,110,Y,2,Down,1 +64,M,ASY,144,0,0,ST,122,Y,1,Flat,1 +60,M,ASY,140,281,0,ST,118,Y,1.5,Flat,1 +60,M,ASY,120,0,0,Normal,133,Y,2,Up,0 +58,M,ASY,136,203,1,Normal,123,Y,1.2,Flat,1 +59,M,ASY,154,0,0,ST,131,Y,1.5,Up,0 +61,M,NAP,120,0,0,Normal,80,Y,0,Flat,1 +40,M,ASY,125,0,1,Normal,165,N,0,Flat,1 +61,M,ASY,134,0,1,ST,86,N,1.5,Flat,1 +41,M,ASY,104,0,0,ST,111,N,0,Up,0 +57,M,ASY,139,277,1,ST,118,Y,1.9,Flat,1 +63,M,ASY,136,0,0,Normal,84,Y,0,Flat,1 +59,M,ASY,122,233,0,Normal,117,Y,1.3,Down,1 +51,M,ASY,128,0,0,Normal,107,N,0,Up,0 +59,M,NAP,131,0,0,Normal,128,Y,2,Down,1 +42,M,NAP,134,240,0,Normal,160,N,0,Up,0 +55,M,NAP,120,0,0,ST,125,Y,2.5,Flat,1 +63,F,ATA,132,0,0,Normal,130,N,0.1,Up,0 +62,M,ASY,152,153,0,ST,97,Y,1.6,Up,1 +56,M,ATA,124,224,1,Normal,161,N,2,Flat,0 +53,M,ASY,126,0,0,Normal,106,N,0,Flat,1 +68,M,ASY,138,0,0,Normal,130,Y,3,Flat,1 +53,M,ASY,154,0,1,ST,140,Y,1.5,Flat,1 +60,M,NAP,141,316,1,ST,122,Y,1.7,Flat,1 +62,M,ATA,131,0,0,Normal,130,N,0.1,Up,0 +59,M,ASY,178,0,1,LVH,120,Y,0,Flat,1 +51,M,ASY,132,218,1,LVH,139,N,0.1,Up,0 +61,M,ASY,110,0,1,Normal,108,Y,2,Down,1 +57,M,ASY,130,311,1,ST,148,Y,2,Flat,1 +56,M,NAP,170,0,0,LVH,123,Y,2.5,Flat,1 +58,M,ATA,126,0,1,Normal,110,Y,2,Flat,1 +69,M,NAP,140,0,1,ST,118,N,2.5,Down,1 +67,M,TA,142,270,1,Normal,125,N,2.5,Up,1 +58,M,ASY,120,0,0,LVH,106,Y,1.5,Down,1 +65,M,ASY,134,0,0,Normal,112,Y,1.1,Flat,1 +63,M,ATA,139,217,1,ST,128,Y,1.2,Flat,1 +55,M,ATA,110,214,1,ST,180,N,0.4,Up,0 +57,M,ASY,140,214,0,ST,144,Y,2,Flat,1 +65,M,TA,140,252,0,Normal,135,N,0.3,Up,0 +54,M,ASY,136,220,0,Normal,140,Y,3,Flat,1 +72,M,NAP,120,214,0,Normal,102,Y,1,Flat,1 +75,M,ASY,170,203,1,ST,108,N,0,Flat,1 +49,M,TA,130,0,0,ST,145,N,3,Flat,1 +51,M,NAP,137,339,0,Normal,127,Y,1.7,Flat,1 +60,M,ASY,142,216,0,Normal,110,Y,2.5,Flat,1 +64,F,ASY,142,276,0,Normal,140,Y,1,Flat,1 +58,M,ASY,132,458,1,Normal,69,N,1,Down,0 +61,M,ASY,146,241,0,Normal,148,Y,3,Down,1 +67,M,ASY,160,384,1,ST,130,Y,0,Flat,1 +62,M,ASY,135,297,0,Normal,130,Y,1,Flat,1 +65,M,ASY,136,248,0,Normal,140,Y,4,Down,1 +63,M,ASY,130,308,0,Normal,138,Y,2,Flat,1 +69,M,ASY,140,208,0,ST,140,Y,2,Flat,1 +51,M,ASY,132,227,1,ST,138,N,0.2,Up,0 +62,M,ASY,158,210,1,Normal,112,Y,3,Down,1 +55,M,NAP,136,245,1,ST,131,Y,1.2,Flat,1 +75,M,ASY,136,225,0,Normal,112,Y,3,Flat,1 +40,M,NAP,106,240,0,Normal,80,Y,0,Up,0 +67,M,ASY,120,0,1,Normal,150,N,1.5,Down,1 +58,M,ASY,110,198,0,Normal,110,N,0,Flat,1 +60,M,ASY,136,195,0,Normal,126,N,0.3,Up,0 +63,M,ASY,160,267,1,ST,88,Y,2,Flat,1 +35,M,NAP,123,161,0,ST,153,N,-0.1,Up,0 +62,M,TA,112,258,0,ST,150,Y,1.3,Flat,1 +43,M,ASY,122,0,0,Normal,120,N,0.5,Up,1 +63,M,NAP,130,0,1,ST,160,N,3,Flat,0 +68,M,NAP,150,195,1,Normal,132,N,0,Flat,1 +65,M,ASY,150,235,0,Normal,120,Y,1.5,Flat,1 +48,M,NAP,102,0,1,ST,110,Y,1,Down,1 +63,M,ASY,96,305,0,ST,121,Y,1,Up,1 +64,M,ASY,130,223,0,ST,128,N,0.5,Flat,0 +61,M,ASY,120,282,0,ST,135,Y,4,Down,1 +50,M,ASY,144,349,0,LVH,120,Y,1,Up,1 +59,M,ASY,124,160,0,Normal,117,Y,1,Flat,1 +55,M,ASY,150,160,0,ST,150,N,0,Up,0 +45,M,NAP,130,236,0,Normal,144,N,0.1,Up,0 +65,M,ASY,144,312,0,LVH,113,Y,1.7,Flat,1 +61,M,ATA,139,283,0,Normal,135,N,0.3,Up,0 +49,M,NAP,131,142,0,Normal,127,Y,1.5,Flat,1 +72,M,ASY,143,211,0,Normal,109,Y,1.4,Flat,1 +50,M,ASY,133,218,0,Normal,128,Y,1.1,Flat,1 +64,M,ASY,143,306,1,ST,115,Y,1.8,Flat,1 +55,M,ASY,116,186,1,ST,102,N,0,Flat,1 +63,M,ASY,110,252,0,ST,140,Y,2,Flat,1 +59,M,ASY,125,222,0,Normal,135,Y,2.5,Down,1 +56,M,ASY,130,0,0,LVH,122,Y,1,Flat,1 +62,M,NAP,133,0,1,ST,119,Y,1.2,Flat,1 +74,M,ASY,150,258,1,ST,130,Y,4,Down,1 +54,M,ASY,130,202,1,Normal,112,Y,2,Flat,1 +57,M,ASY,110,197,0,LVH,100,N,0,Up,0 +62,M,NAP,138,204,0,ST,122,Y,1.2,Flat,1 +76,M,NAP,104,113,0,LVH,120,N,3.5,Down,1 +54,F,ASY,138,274,0,Normal,105,Y,1.5,Flat,1 +70,M,ASY,170,192,0,ST,129,Y,3,Down,1 +61,F,ATA,140,298,1,Normal,120,Y,0,Up,0 +48,M,ASY,132,272,0,ST,139,N,0.2,Up,0 +48,M,NAP,132,220,1,ST,162,N,0,Flat,1 +61,M,TA,142,200,1,ST,100,N,1.5,Down,1 +66,M,ASY,112,261,0,Normal,140,N,1.5,Up,1 +68,M,TA,139,181,1,ST,135,N,0.2,Up,0 +55,M,ASY,172,260,0,Normal,73,N,2,Flat,1 +62,M,NAP,120,220,0,LVH,86,N,0,Up,0 +71,M,NAP,144,221,0,Normal,108,Y,1.8,Flat,1 +74,M,TA,145,216,1,Normal,116,Y,1.8,Flat,1 +53,M,NAP,155,175,1,ST,160,N,0.3,Up,0 +58,M,NAP,150,219,0,ST,118,Y,0,Flat,1 +75,M,ASY,160,310,1,Normal,112,Y,2,Down,0 +56,M,NAP,137,208,1,ST,122,Y,1.8,Flat,1 +58,M,NAP,137,232,0,ST,124,Y,1.4,Flat,1 +64,M,ASY,134,273,0,Normal,102,Y,4,Down,1 +54,M,NAP,133,203,0,ST,137,N,0.2,Up,0 +54,M,ATA,132,182,0,ST,141,N,0.1,Up,0 +59,M,ASY,140,274,0,Normal,154,Y,2,Flat,0 +55,M,ASY,135,204,1,ST,126,Y,1.1,Flat,1 +57,M,ASY,144,270,1,ST,160,Y,2,Flat,1 +61,M,ASY,141,292,0,ST,115,Y,1.7,Flat,1 +41,M,ASY,150,171,0,Normal,128,Y,1.5,Flat,0 +71,M,ASY,130,221,0,ST,115,Y,0,Flat,1 +38,M,ASY,110,289,0,Normal,105,Y,1.5,Down,1 +55,M,ASY,158,217,0,Normal,110,Y,2.5,Flat,1 +56,M,ASY,128,223,0,ST,119,Y,2,Down,1 +69,M,ASY,140,110,1,Normal,109,Y,1.5,Flat,1 +64,M,ASY,150,193,0,ST,135,Y,0.5,Flat,1 +72,M,ASY,160,123,1,LVH,130,N,1.5,Flat,1 +69,M,ASY,142,210,1,ST,112,Y,1.5,Flat,1 +56,M,ASY,137,282,1,Normal,126,Y,1.2,Flat,1 +62,M,ASY,139,170,0,ST,120,Y,3,Flat,1 +67,M,ASY,146,369,0,Normal,110,Y,1.9,Flat,1 +57,M,ASY,156,173,0,LVH,119,Y,3,Down,1 +69,M,ASY,145,289,1,ST,110,Y,1.8,Flat,1 +51,M,ASY,131,152,1,LVH,130,Y,1,Flat,1 +48,M,ASY,140,208,0,Normal,159,Y,1.5,Up,1 +69,M,ASY,122,216,1,LVH,84,Y,0,Flat,1 +69,M,NAP,142,271,0,LVH,126,N,0.3,Up,0 +64,M,ASY,141,244,1,ST,116,Y,1.5,Flat,1 +57,M,ATA,180,285,1,ST,120,N,0.8,Flat,1 +53,M,ASY,124,243,0,Normal,122,Y,2,Flat,1 +37,M,NAP,118,240,0,LVH,165,N,1,Flat,0 +67,M,ASY,140,219,0,ST,122,Y,2,Flat,1 +74,M,NAP,140,237,1,Normal,94,N,0,Flat,1 +63,M,ATA,136,165,0,ST,133,N,0.2,Up,0 +58,M,ASY,100,213,0,ST,110,N,0,Up,0 +61,M,ASY,190,287,1,LVH,150,Y,2,Down,1 +64,M,ASY,130,258,1,LVH,130,N,0,Flat,1 +58,M,ASY,160,256,1,LVH,113,Y,1,Up,1 +60,M,ASY,130,186,1,LVH,140,Y,0.5,Flat,1 +57,M,ASY,122,264,0,LVH,100,N,0,Flat,1 +55,M,NAP,133,185,0,ST,136,N,0.2,Up,0 +55,M,ASY,120,226,0,LVH,127,Y,1.7,Down,1 +56,M,ASY,130,203,1,Normal,98,N,1.5,Flat,1 +57,M,ASY,130,207,0,ST,96,Y,1,Flat,0 +61,M,NAP,140,284,0,Normal,123,Y,1.3,Flat,1 +61,M,NAP,120,337,0,Normal,98,Y,0,Flat,1 +74,M,ASY,155,310,0,Normal,112,Y,1.5,Down,1 +68,M,NAP,134,254,1,Normal,151,Y,0,Up,0 +51,F,ASY,114,258,1,LVH,96,N,1,Up,0 +62,M,ASY,160,254,1,ST,108,Y,3,Flat,1 +53,M,ASY,144,300,1,ST,128,Y,1.5,Flat,1 +62,M,ASY,158,170,0,ST,138,Y,0,Flat,1 +46,M,ASY,134,310,0,Normal,126,N,0,Flat,1 +54,F,ASY,127,333,1,ST,154,N,0,Flat,1 +62,M,TA,135,139,0,ST,137,N,0.2,Up,0 +55,M,ASY,122,223,1,ST,100,N,0,Flat,1 +58,M,ASY,140,385,1,LVH,135,N,0.3,Up,0 +62,M,ATA,120,254,0,LVH,93,Y,0,Flat,1 +70,M,ASY,130,322,0,LVH,109,N,2.4,Flat,1 +67,F,NAP,115,564,0,LVH,160,N,1.6,Flat,0 +57,M,ATA,124,261,0,Normal,141,N,0.3,Up,1 +64,M,ASY,128,263,0,Normal,105,Y,0.2,Flat,0 +74,F,ATA,120,269,0,LVH,121,Y,0.2,Up,0 +65,M,ASY,120,177,0,Normal,140,N,0.4,Up,0 +56,M,NAP,130,256,1,LVH,142,Y,0.6,Flat,1 +59,M,ASY,110,239,0,LVH,142,Y,1.2,Flat,1 +60,M,ASY,140,293,0,LVH,170,N,1.2,Flat,1 +63,F,ASY,150,407,0,LVH,154,N,4,Flat,1 +59,M,ASY,135,234,0,Normal,161,N,0.5,Flat,0 +53,M,ASY,142,226,0,LVH,111,Y,0,Up,0 +44,M,NAP,140,235,0,LVH,180,N,0,Up,0 +61,M,TA,134,234,0,Normal,145,N,2.6,Flat,1 +57,F,ASY,128,303,0,LVH,159,N,0,Up,0 +71,F,ASY,112,149,0,Normal,125,N,1.6,Flat,0 +46,M,ASY,140,311,0,Normal,120,Y,1.8,Flat,1 +53,M,ASY,140,203,1,LVH,155,Y,3.1,Down,1 +64,M,TA,110,211,0,LVH,144,Y,1.8,Flat,0 +40,M,TA,140,199,0,Normal,178,Y,1.4,Up,0 +67,M,ASY,120,229,0,LVH,129,Y,2.6,Flat,1 +48,M,ATA,130,245,0,LVH,180,N,0.2,Flat,0 +43,M,ASY,115,303,0,Normal,181,N,1.2,Flat,0 +47,M,ASY,112,204,0,Normal,143,N,0.1,Up,0 +54,F,ATA,132,288,1,LVH,159,Y,0,Up,0 +48,F,NAP,130,275,0,Normal,139,N,0.2,Up,0 +46,F,ASY,138,243,0,LVH,152,Y,0,Flat,0 +51,F,NAP,120,295,0,LVH,157,N,0.6,Up,0 +58,M,NAP,112,230,0,LVH,165,N,2.5,Flat,1 +71,F,NAP,110,265,1,LVH,130,N,0,Up,0 +57,M,NAP,128,229,0,LVH,150,N,0.4,Flat,1 +66,M,ASY,160,228,0,LVH,138,N,2.3,Up,0 +37,F,NAP,120,215,0,Normal,170,N,0,Up,0 +59,M,ASY,170,326,0,LVH,140,Y,3.4,Down,1 +50,M,ASY,144,200,0,LVH,126,Y,0.9,Flat,1 +48,M,ASY,130,256,1,LVH,150,Y,0,Up,1 +61,M,ASY,140,207,0,LVH,138,Y,1.9,Up,1 +59,M,TA,160,273,0,LVH,125,N,0,Up,1 +42,M,NAP,130,180,0,Normal,150,N,0,Up,0 +48,M,ASY,122,222,0,LVH,186,N,0,Up,0 +40,M,ASY,152,223,0,Normal,181,N,0,Up,1 +62,F,ASY,124,209,0,Normal,163,N,0,Up,0 +44,M,NAP,130,233,0,Normal,179,Y,0.4,Up,0 +46,M,ATA,101,197,1,Normal,156,N,0,Up,0 +59,M,NAP,126,218,1,Normal,134,N,2.2,Flat,1 +58,M,NAP,140,211,1,LVH,165,N,0,Up,0 +49,M,NAP,118,149,0,LVH,126,N,0.8,Up,1 +44,M,ASY,110,197,0,LVH,177,N,0,Up,1 +66,M,ATA,160,246,0,Normal,120,Y,0,Flat,1 +65,F,ASY,150,225,0,LVH,114,N,1,Flat,1 +42,M,ASY,136,315,0,Normal,125,Y,1.8,Flat,1 +52,M,ATA,128,205,1,Normal,184,N,0,Up,0 +65,F,NAP,140,417,1,LVH,157,N,0.8,Up,0 +63,F,ATA,140,195,0,Normal,179,N,0,Up,0 +45,F,ATA,130,234,0,LVH,175,N,0.6,Flat,0 +41,F,ATA,105,198,0,Normal,168,N,0,Up,0 +61,M,ASY,138,166,0,LVH,125,Y,3.6,Flat,1 +60,F,NAP,120,178,1,Normal,96,N,0,Up,0 +59,F,ASY,174,249,0,Normal,143,Y,0,Flat,1 +62,M,ATA,120,281,0,LVH,103,N,1.4,Flat,1 +57,M,NAP,150,126,1,Normal,173,N,0.2,Up,0 +51,F,ASY,130,305,0,Normal,142,Y,1.2,Flat,1 +44,M,NAP,120,226,0,Normal,169,N,0,Up,0 +60,F,TA,150,240,0,Normal,171,N,0.9,Up,0 +63,M,TA,145,233,1,LVH,150,N,2.3,Down,0 +57,M,ASY,150,276,0,LVH,112,Y,0.6,Flat,1 +51,M,ASY,140,261,0,LVH,186,Y,0,Up,0 +58,F,ATA,136,319,1,LVH,152,N,0,Up,1 +44,F,NAP,118,242,0,Normal,149,N,0.3,Flat,0 +47,M,NAP,108,243,0,Normal,152,N,0,Up,1 +61,M,ASY,120,260,0,Normal,140,Y,3.6,Flat,1 +57,F,ASY,120,354,0,Normal,163,Y,0.6,Up,0 +70,M,ATA,156,245,0,LVH,143,N,0,Up,0 +76,F,NAP,140,197,0,ST,116,N,1.1,Flat,0 +67,F,ASY,106,223,0,Normal,142,N,0.3,Up,0 +45,M,ASY,142,309,0,LVH,147,Y,0,Flat,1 +45,M,ASY,104,208,0,LVH,148,Y,3,Flat,0 +39,F,NAP,94,199,0,Normal,179,N,0,Up,0 +42,F,NAP,120,209,0,Normal,173,N,0,Flat,0 +56,M,ATA,120,236,0,Normal,178,N,0.8,Up,0 +58,M,ASY,146,218,0,Normal,105,N,2,Flat,1 +35,M,ASY,120,198,0,Normal,130,Y,1.6,Flat,1 +58,M,ASY,150,270,0,LVH,111,Y,0.8,Up,1 +41,M,NAP,130,214,0,LVH,168,N,2,Flat,0 +57,M,ASY,110,201,0,Normal,126,Y,1.5,Flat,0 +42,M,TA,148,244,0,LVH,178,N,0.8,Up,0 +62,M,ATA,128,208,1,LVH,140,N,0,Up,0 +59,M,TA,178,270,0,LVH,145,N,4.2,Down,0 +41,F,ATA,126,306,0,Normal,163,N,0,Up,0 +50,M,ASY,150,243,0,LVH,128,N,2.6,Flat,1 +59,M,ATA,140,221,0,Normal,164,Y,0,Up,0 +61,F,ASY,130,330,0,LVH,169,N,0,Up,1 +54,M,ASY,124,266,0,LVH,109,Y,2.2,Flat,1 +54,M,ASY,110,206,0,LVH,108,Y,0,Flat,1 +52,M,ASY,125,212,0,Normal,168,N,1,Up,1 +47,M,ASY,110,275,0,LVH,118,Y,1,Flat,1 +66,M,ASY,120,302,0,LVH,151,N,0.4,Flat,0 +58,M,ASY,100,234,0,Normal,156,N,0.1,Up,1 +64,F,NAP,140,313,0,Normal,133,N,0.2,Up,0 +50,F,ATA,120,244,0,Normal,162,N,1.1,Up,0 +44,F,NAP,108,141,0,Normal,175,N,0.6,Flat,0 +67,M,ASY,120,237,0,Normal,71,N,1,Flat,1 +49,F,ASY,130,269,0,Normal,163,N,0,Up,0 +57,M,ASY,165,289,1,LVH,124,N,1,Flat,1 +63,M,ASY,130,254,0,LVH,147,N,1.4,Flat,1 +48,M,ASY,124,274,0,LVH,166,N,0.5,Flat,1 +51,M,NAP,100,222,0,Normal,143,Y,1.2,Flat,0 +60,F,ASY,150,258,0,LVH,157,N,2.6,Flat,1 +59,M,ASY,140,177,0,Normal,162,Y,0,Up,1 +45,F,ATA,112,160,0,Normal,138,N,0,Flat,0 +55,F,ASY,180,327,0,ST,117,Y,3.4,Flat,1 +41,M,ATA,110,235,0,Normal,153,N,0,Up,0 +60,F,ASY,158,305,0,LVH,161,N,0,Up,1 +54,F,NAP,135,304,1,Normal,170,N,0,Up,0 +42,M,ATA,120,295,0,Normal,162,N,0,Up,0 +49,F,ATA,134,271,0,Normal,162,N,0,Flat,0 +46,M,ASY,120,249,0,LVH,144,N,0.8,Up,1 +56,F,ASY,200,288,1,LVH,133,Y,4,Down,1 +66,F,TA,150,226,0,Normal,114,N,2.6,Down,0 +56,M,ASY,130,283,1,LVH,103,Y,1.6,Down,1 +49,M,NAP,120,188,0,Normal,139,N,2,Flat,1 +54,M,ASY,122,286,0,LVH,116,Y,3.2,Flat,1 +57,M,ASY,152,274,0,Normal,88,Y,1.2,Flat,1 +65,F,NAP,160,360,0,LVH,151,N,0.8,Up,0 +54,M,NAP,125,273,0,LVH,152,N,0.5,Down,0 +54,F,NAP,160,201,0,Normal,163,N,0,Up,0 +62,M,ASY,120,267,0,Normal,99,Y,1.8,Flat,1 +52,F,NAP,136,196,0,LVH,169,N,0.1,Flat,0 +52,M,ATA,134,201,0,Normal,158,N,0.8,Up,0 +60,M,ASY,117,230,1,Normal,160,Y,1.4,Up,1 +63,F,ASY,108,269,0,Normal,169,Y,1.8,Flat,1 +66,M,ASY,112,212,0,LVH,132,Y,0.1,Up,1 +42,M,ASY,140,226,0,Normal,178,N,0,Up,0 +64,M,ASY,120,246,0,LVH,96,Y,2.2,Down,1 +54,M,NAP,150,232,0,LVH,165,N,1.6,Up,0 +46,F,NAP,142,177,0,LVH,160,Y,1.4,Down,0 +67,F,NAP,152,277,0,Normal,172,N,0,Up,0 +56,M,ASY,125,249,1,LVH,144,Y,1.2,Flat,1 +34,F,ATA,118,210,0,Normal,192,N,0.7,Up,0 +57,M,ASY,132,207,0,Normal,168,Y,0,Up,0 +64,M,ASY,145,212,0,LVH,132,N,2,Flat,1 +59,M,ASY,138,271,0,LVH,182,N,0,Up,0 +50,M,NAP,140,233,0,Normal,163,N,0.6,Flat,1 +51,M,TA,125,213,0,LVH,125,Y,1.4,Up,0 +54,M,ATA,192,283,0,LVH,195,N,0,Up,1 +53,M,ASY,123,282,0,Normal,95,Y,2,Flat,1 +52,M,ASY,112,230,0,Normal,160,N,0,Up,1 +40,M,ASY,110,167,0,LVH,114,Y,2,Flat,1 +58,M,NAP,132,224,0,LVH,173,N,3.2,Up,1 +41,F,NAP,112,268,0,LVH,172,Y,0,Up,0 +41,M,NAP,112,250,0,Normal,179,N,0,Up,0 +50,F,NAP,120,219,0,Normal,158,N,1.6,Flat,0 +54,F,NAP,108,267,0,LVH,167,N,0,Up,0 +64,F,ASY,130,303,0,Normal,122,N,2,Flat,0 +51,F,NAP,130,256,0,LVH,149,N,0.5,Up,0 +46,F,ATA,105,204,0,Normal,172,N,0,Up,0 +55,M,ASY,140,217,0,Normal,111,Y,5.6,Down,1 +45,M,ATA,128,308,0,LVH,170,N,0,Up,0 +56,M,TA,120,193,0,LVH,162,N,1.9,Flat,0 +66,F,ASY,178,228,1,Normal,165,Y,1,Flat,1 +38,M,TA,120,231,0,Normal,182,Y,3.8,Flat,1 +62,F,ASY,150,244,0,Normal,154,Y,1.4,Flat,1 +55,M,ATA,130,262,0,Normal,155,N,0,Up,0 +58,M,ASY,128,259,0,LVH,130,Y,3,Flat,1 +43,M,ASY,110,211,0,Normal,161,N,0,Up,0 +64,F,ASY,180,325,0,Normal,154,Y,0,Up,0 +50,F,ASY,110,254,0,LVH,159,N,0,Up,0 +53,M,NAP,130,197,1,LVH,152,N,1.2,Down,0 +45,F,ASY,138,236,0,LVH,152,Y,0.2,Flat,0 +65,M,TA,138,282,1,LVH,174,N,1.4,Flat,1 +69,M,TA,160,234,1,LVH,131,N,0.1,Flat,0 +69,M,NAP,140,254,0,LVH,146,N,2,Flat,1 +67,M,ASY,100,299,0,LVH,125,Y,0.9,Flat,1 +68,F,NAP,120,211,0,LVH,115,N,1.5,Flat,0 +34,M,TA,118,182,0,LVH,174,N,0,Up,0 +62,F,ASY,138,294,1,Normal,106,N,1.9,Flat,1 +51,M,ASY,140,298,0,Normal,122,Y,4.2,Flat,1 +46,M,NAP,150,231,0,Normal,147,N,3.6,Flat,1 +67,M,ASY,125,254,1,Normal,163,N,0.2,Flat,1 +50,M,NAP,129,196,0,Normal,163,N,0,Up,0 +42,M,NAP,120,240,1,Normal,194,N,0.8,Down,0 +56,F,ASY,134,409,0,LVH,150,Y,1.9,Flat,1 +41,M,ASY,110,172,0,LVH,158,N,0,Up,1 +42,F,ASY,102,265,0,LVH,122,N,0.6,Flat,0 +53,M,NAP,130,246,1,LVH,173,N,0,Up,0 +43,M,NAP,130,315,0,Normal,162,N,1.9,Up,0 +56,M,ASY,132,184,0,LVH,105,Y,2.1,Flat,1 +52,M,ASY,108,233,1,Normal,147,N,0.1,Up,0 +62,F,ASY,140,394,0,LVH,157,N,1.2,Flat,0 +70,M,NAP,160,269,0,Normal,112,Y,2.9,Flat,1 +54,M,ASY,140,239,0,Normal,160,N,1.2,Up,0 +70,M,ASY,145,174,0,Normal,125,Y,2.6,Down,1 +54,M,ATA,108,309,0,Normal,156,N,0,Up,0 +35,M,ASY,126,282,0,LVH,156,Y,0,Up,1 +48,M,NAP,124,255,1,Normal,175,N,0,Up,0 +55,F,ATA,135,250,0,LVH,161,N,1.4,Flat,0 +58,F,ASY,100,248,0,LVH,122,N,1,Flat,0 +54,F,NAP,110,214,0,Normal,158,N,1.6,Flat,0 +69,F,TA,140,239,0,Normal,151,N,1.8,Up,0 +77,M,ASY,125,304,0,LVH,162,Y,0,Up,1 +68,M,NAP,118,277,0,Normal,151,N,1,Up,0 +58,M,ASY,125,300,0,LVH,171,N,0,Up,1 +60,M,ASY,125,258,0,LVH,141,Y,2.8,Flat,1 +51,M,ASY,140,299,0,Normal,173,Y,1.6,Up,1 +55,M,ASY,160,289,0,LVH,145,Y,0.8,Flat,1 +52,M,TA,152,298,1,Normal,178,N,1.2,Flat,0 +60,F,NAP,102,318,0,Normal,160,N,0,Up,0 +58,M,NAP,105,240,0,LVH,154,Y,0.6,Flat,0 +64,M,NAP,125,309,0,Normal,131,Y,1.8,Flat,1 +37,M,NAP,130,250,0,Normal,187,N,3.5,Down,0 +59,M,TA,170,288,0,LVH,159,N,0.2,Flat,1 +51,M,NAP,125,245,1,LVH,166,N,2.4,Flat,0 +43,F,NAP,122,213,0,Normal,165,N,0.2,Flat,0 +58,M,ASY,128,216,0,LVH,131,Y,2.2,Flat,1 +29,M,ATA,130,204,0,LVH,202,N,0,Up,0 +41,F,ATA,130,204,0,LVH,172,N,1.4,Up,0 +63,F,NAP,135,252,0,LVH,172,N,0,Up,0 +51,M,NAP,94,227,0,Normal,154,Y,0,Up,0 +54,M,NAP,120,258,0,LVH,147,N,0.4,Flat,0 +44,M,ATA,120,220,0,Normal,170,N,0,Up,0 +54,M,ASY,110,239,0,Normal,126,Y,2.8,Flat,1 +65,M,ASY,135,254,0,LVH,127,N,2.8,Flat,1 +57,M,NAP,150,168,0,Normal,174,N,1.6,Up,0 +63,M,ASY,130,330,1,LVH,132,Y,1.8,Up,1 +35,F,ASY,138,183,0,Normal,182,N,1.4,Up,0 +41,M,ATA,135,203,0,Normal,132,N,0,Flat,0 +62,F,NAP,130,263,0,Normal,97,N,1.2,Flat,1 +43,F,ASY,132,341,1,LVH,136,Y,3,Flat,1 +58,F,TA,150,283,1,LVH,162,N,1,Up,0 +52,M,TA,118,186,0,LVH,190,N,0,Flat,0 +61,F,ASY,145,307,0,LVH,146,Y,1,Flat,1 +39,M,ASY,118,219,0,Normal,140,N,1.2,Flat,1 +45,M,ASY,115,260,0,LVH,185,N,0,Up,0 +52,M,ASY,128,255,0,Normal,161,Y,0,Up,1 +62,M,NAP,130,231,0,Normal,146,N,1.8,Flat,0 +62,F,ASY,160,164,0,LVH,145,N,6.2,Down,1 +53,F,ASY,138,234,0,LVH,160,N,0,Up,0 +43,M,ASY,120,177,0,LVH,120,Y,2.5,Flat,1 +47,M,NAP,138,257,0,LVH,156,N,0,Up,0 +52,M,ATA,120,325,0,Normal,172,N,0.2,Up,0 +68,M,NAP,180,274,1,LVH,150,Y,1.6,Flat,1 +39,M,NAP,140,321,0,LVH,182,N,0,Up,0 +53,F,ASY,130,264,0,LVH,143,N,0.4,Flat,0 +62,F,ASY,140,268,0,LVH,160,N,3.6,Down,1 +51,F,NAP,140,308,0,LVH,142,N,1.5,Up,0 +60,M,ASY,130,253,0,Normal,144,Y,1.4,Up,1 +65,M,ASY,110,248,0,LVH,158,N,0.6,Up,1 +65,F,NAP,155,269,0,Normal,148,N,0.8,Up,0 +60,M,NAP,140,185,0,LVH,155,N,3,Flat,1 +60,M,ASY,145,282,0,LVH,142,Y,2.8,Flat,1 +54,M,ASY,120,188,0,Normal,113,N,1.4,Flat,1 +44,M,ATA,130,219,0,LVH,188,N,0,Up,0 +44,M,ASY,112,290,0,LVH,153,N,0,Up,1 +51,M,NAP,110,175,0,Normal,123,N,0.6,Up,0 +59,M,NAP,150,212,1,Normal,157,N,1.6,Up,0 +71,F,ATA,160,302,0,Normal,162,N,0.4,Up,0 +61,M,NAP,150,243,1,Normal,137,Y,1,Flat,0 +55,M,ASY,132,353,0,Normal,132,Y,1.2,Flat,1 +64,M,NAP,140,335,0,Normal,158,N,0,Up,1 +43,M,ASY,150,247,0,Normal,171,N,1.5,Up,0 +58,F,NAP,120,340,0,Normal,172,N,0,Up,0 +60,M,ASY,130,206,0,LVH,132,Y,2.4,Flat,1 +58,M,ATA,120,284,0,LVH,160,N,1.8,Flat,1 +49,M,ATA,130,266,0,Normal,171,N,0.6,Up,0 +48,M,ATA,110,229,0,Normal,168,N,1,Down,1 +52,M,NAP,172,199,1,Normal,162,N,0.5,Up,0 +44,M,ATA,120,263,0,Normal,173,N,0,Up,0 +56,F,ATA,140,294,0,LVH,153,N,1.3,Flat,0 +57,M,ASY,140,192,0,Normal,148,N,0.4,Flat,0 +67,M,ASY,160,286,0,LVH,108,Y,1.5,Flat,1 +53,F,NAP,128,216,0,LVH,115,N,0,Up,0 +52,M,NAP,138,223,0,Normal,169,N,0,Up,0 +43,M,ASY,132,247,1,LVH,143,Y,0.1,Flat,1 +52,M,ASY,128,204,1,Normal,156,Y,1,Flat,1 +59,M,TA,134,204,0,Normal,162,N,0.8,Up,1 +64,M,TA,170,227,0,LVH,155,N,0.6,Flat,0 +66,F,NAP,146,278,0,LVH,152,N,0,Flat,0 +39,F,NAP,138,220,0,Normal,152,N,0,Flat,0 +57,M,ATA,154,232,0,LVH,164,N,0,Up,1 +58,F,ASY,130,197,0,Normal,131,N,0.6,Flat,0 +57,M,ASY,110,335,0,Normal,143,Y,3,Flat,1 +47,M,NAP,130,253,0,Normal,179,N,0,Up,0 +55,F,ASY,128,205,0,ST,130,Y,2,Flat,1 +35,M,ATA,122,192,0,Normal,174,N,0,Up,0 +61,M,ASY,148,203,0,Normal,161,N,0,Up,1 +58,M,ASY,114,318,0,ST,140,N,4.4,Down,1 +58,F,ASY,170,225,1,LVH,146,Y,2.8,Flat,1 +58,M,ATA,125,220,0,Normal,144,N,0.4,Flat,0 +56,M,ATA,130,221,0,LVH,163,N,0,Up,0 +56,M,ATA,120,240,0,Normal,169,N,0,Down,0 +67,M,NAP,152,212,0,LVH,150,N,0.8,Flat,1 +55,F,ATA,132,342,0,Normal,166,N,1.2,Up,0 +44,M,ASY,120,169,0,Normal,144,Y,2.8,Down,1 +63,M,ASY,140,187,0,LVH,144,Y,4,Up,1 +63,F,ASY,124,197,0,Normal,136,Y,0,Flat,1 +41,M,ATA,120,157,0,Normal,182,N,0,Up,0 +59,M,ASY,164,176,1,LVH,90,N,1,Flat,1 +57,F,ASY,140,241,0,Normal,123,Y,0.2,Flat,1 +45,M,TA,110,264,0,Normal,132,N,1.2,Flat,1 +68,M,ASY,144,193,1,Normal,141,N,3.4,Flat,1 +57,M,ASY,130,131,0,Normal,115,Y,1.2,Flat,1 +57,F,ATA,130,236,0,LVH,174,N,0,Flat,1 +38,M,NAP,138,175,0,Normal,173,N,0,Up,0 diff --git a/ML/18_PCA/PCA_tutorial_digits.ipynb b/ML/18_PCA/PCA_tutorial_digits.ipynb new file mode 100644 index 00000000..4a44f017 --- /dev/null +++ b/ML/18_PCA/PCA_tutorial_digits.ipynb @@ -0,0 +1,1497 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Principal Component Analysis Tutorial

" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['data', 'target', 'frame', 'feature_names', 'target_names', 'images', 'DESCR'])" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.datasets import load_digits\n", + "import pandas as pd\n", + "\n", + "dataset = load_digits()\n", + "dataset.keys()" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1797, 64)" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset.data.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 0., 0., 5., 13., 9., 1., 0., 0., 0., 0., 13., 15., 10.,\n", + " 15., 5., 0., 0., 3., 15., 2., 0., 11., 8., 0., 0., 4.,\n", + " 12., 0., 0., 8., 8., 0., 0., 5., 8., 0., 0., 9., 8.,\n", + " 0., 0., 4., 11., 0., 1., 12., 7., 0., 0., 2., 14., 5.,\n", + " 10., 12., 0., 0., 0., 0., 6., 13., 10., 0., 0., 0.])" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset.data[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0., 0., 5., 13., 9., 1., 0., 0.],\n", + " [ 0., 0., 13., 15., 10., 15., 5., 0.],\n", + " [ 0., 3., 15., 2., 0., 11., 8., 0.],\n", + " [ 0., 4., 12., 0., 0., 8., 8., 0.],\n", + " [ 0., 5., 8., 0., 0., 9., 8., 0.],\n", + " [ 0., 4., 11., 0., 1., 12., 7., 0.],\n", + " [ 0., 2., 14., 5., 10., 12., 0., 0.],\n", + " [ 0., 0., 6., 13., 10., 0., 0., 0.]])" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset.data[0].reshape(8,8)" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "image/png": "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\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "from matplotlib import pyplot as plt\n", + "%matplotlib inline\n", + "plt.gray()\n", + "plt.matshow(dataset.data[0].reshape(8,8))" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAECCAYAAADXWsr9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAALx0lEQVR4nO3d3Ytd9RXG8efpmOBb4ki1IkacKiUgQidBQiUg00QlVkm96EUEhUhLetGKoQXR3hT/AUkuihCiVjBGNJpQpLUGfENotUmcqdHEoHHENGoUjVELDerqxdkpaZx29sT9+82ZWd8PHHLOzJm91mR4zn45++zliBCA2e1b090AgPIIOpAAQQcSIOhAAgQdSICgAwn0RdBtr7D9uu03bN9RuNZ9tg/Z3l2yznH1LrT9jO09tl+1fVvheqfafsn2WFPvrpL1mpoDtl+2/UTpWk29cduv2B61vaNwrUHbW2zvbf6GVxSstbD5nY7djthe28nCI2Jab5IGJL0p6WJJcyWNSbq0YL0rJS2WtLvS73e+pMXN/XmS9hX+/SzpzOb+HEkvSvpB4d/xV5IekvREpf/TcUnnVKr1gKSfNffnShqsVHdA0nuSLupief2wRl8i6Y2I2B8RRyU9LOnHpYpFxPOSPiq1/AnqvRsRu5r7n0raI+mCgvUiIj5rHs5pbsXOirK9QNJ1kjaWqjFdbM9Xb8VwryRFxNGIOFyp/HJJb0bE210srB+CfoGkd457fEAFgzCdbA9JWqTeWrZknQHbo5IOSdoeESXrrZN0u6SvCtY4UUh6yvZO22sK1rlY0geS7m92TTbaPqNgveOtkrS5q4X1Q9A9wddm3Xm5ts+U9JiktRFxpGStiPgyIoYlLZC0xPZlJerYvl7SoYjYWWL5/8fSiFgs6VpJv7B9ZaE6p6i3m3dPRCyS9LmkoseQJMn2XEkrJT3a1TL7IegHJF143OMFkg5OUy9F2J6jXsg3RcTjteo2m5nPSlpRqMRSSSttj6u3y7XM9oOFav1HRBxs/j0kaat6u38lHJB04Lgtoi3qBb+0ayXtioj3u1pgPwT9b5K+Z/u7zSvZKkl/mOaeOmPb6u3j7YmIuyvUO9f2YHP/NElXSdpbolZE3BkRCyJiSL2/29MRcVOJWsfYPsP2vGP3JV0jqcg7KBHxnqR3bC9svrRc0mslap3gRnW42S71Nk2mVUR8YfuXkv6s3pHG+yLi1VL1bG+WNCLpHNsHJP02Iu4tVU+9td7Nkl5p9psl6TcR8cdC9c6X9IDtAfVeyB+JiCpve1VynqStvddPnSLpoYh4smC9WyVtalZC+yXdUrCWbJ8u6WpJP+90uc2hfACzWD9sugMojKADCRB0IAGCDiRA0IEE+irohU9nnLZa1KPedNfrq6BLqvmfWfUPRz3qTWe9fgs6gAKKnDBje1afhXPJJZdM+WeOHDmi+fPnn1S9gYGBKf/MJ598orPOOuuk6u3bt++kfg79ISK+9kExgn4Stm3bVrXe4OBg1XojIyNV66FbEwWdTXcgAYIOJEDQgQQIOpAAQQcSIOhAAgQdSICgAwm0CnrNkUkAujdp0JuLDP5OvUvQXirpRtuXlm4MQHfarNGrjkwC0L02QU8zMgmYrdpc173VyKTmg/K1P7MLoIU2QW81MikiNkjaIM3+T68BM02bTfdZPTIJyGDSNXrtkUkAutdq9lozJ6zUrDAAhXFmHJAAQQcSIOhAAgQdSICgAwkQdCABgg4kQNCBBGbFpJahoaGa5fTWW29VrTfbjY2NVa03PDxctV5tTGoBkiLoQAIEHUiAoAMJEHQgAYIOJEDQgQQIOpAAQQcSIOhAAm1GMt1n+5Dt3TUaAtC9Nmv030taUbgPAAVNGvSIeF7SRxV6AVAI++hAAq2u694Gs9eA/tVZ0Jm9BvQvNt2BBNq8vbZZ0l8kLbR9wPZPy7cFoEtthizeWKMRAOWw6Q4kQNCBBAg6kABBBxIg6EACBB1IgKADCRB0IIHOznWfToODg9PdQlHPPfdc1Xrj4+NV642MjFStlxFrdCABgg4kQNCBBAg6kABBBxIg6EACBB1IgKADCRB0IAGCDiTQ5uKQF9p+xvYe26/avq1GYwC60+Zc9y8k/ToidtmeJ2mn7e0R8Vrh3gB0pM3stXcjYldz/1NJeyRdULoxAN2Z0j667SFJiyS9WKQbAEW0/piq7TMlPSZpbUQcmeD7zF4D+lSroNueo17IN0XE4xM9h9lrQP9qc9Tdku6VtCci7i7fEoCutdlHXyrpZknLbI82tx8V7gtAh9rMXntBkiv0AqAQzowDEiDoQAIEHUiAoAMJEHQgAYIOJEDQgQQIOpCAI7o/Lb32ue61Z699/PHHVeudffbZVett27atar3h4eGq9Wb7rL6I+NoJbqzRgQQIOpAAQQcSIOhAAgQdSICgAwkQdCABgg4kQNCBBAg6kECbq8Ceavsl22PN7LW7ajQGoDttruv+L0nLIuKz5vruL9j+U0T8tXBvADrS5iqwIemz5uGc5saABmAGabWPbnvA9qikQ5K2RwSz14AZpFXQI+LLiBiWtEDSEtuXnfgc22ts77C9o+MeAXxDUzrqHhGHJT0racUE39sQEZdHxOXdtAagK22Oup9re7C5f5qkqyTtLdwXgA61Oep+vqQHbA+o98LwSEQ8UbYtAF1qc9T975IWVegFQCGcGQckQNCBBAg6kABBBxIg6EACBB1IgKADCRB0IIE2Z8b1vcOHD1etNzY2VrVe7Vlv69evr1qv9uy1oaGhqvXGx8er1psIa3QgAYIOJEDQgQQIOpAAQQcSIOhAAgQdSICgAwkQdCABgg4k0DrozRCHl21zYUhghpnKGv02SXtKNQKgnLYjmRZIuk7SxrLtACih7Rp9naTbJX1VrhUApbSZ1HK9pEMRsXOS5zF7DehTbdboSyWttD0u6WFJy2w/eOKTmL0G9K9Jgx4Rd0bEgogYkrRK0tMRcVPxzgB0hvfRgQSmdCmpiHhWvbHJAGYQ1uhAAgQdSICgAwkQdCABgg4kQNCBBAg6kABBBxJwRHS/ULv7hSZWezbZ6Oho1Xrr1q2rWq/27LUbbrihar2I8IlfY40OJEDQgQQIOpAAQQcSIOhAAgQdSICgAwkQdCABgg4kQNCBBFpdM6651POnkr6U9AWXdAZmlqlcHPKHEfFhsU4AFMOmO5BA26CHpKds77S9pmRDALrXdtN9aUQctP0dSdtt742I549/QvMCwIsA0IdardEj4mDz7yFJWyUtmeA5zF4D+lSbaapn2J537L6kayTtLt0YgO602XQ/T9JW28ee/1BEPFm0KwCdmjToEbFf0vcr9AKgEN5eAxIg6EACBB1IgKADCRB0IAGCDiRA0IEECDqQwFQ+j45pMttnoa1evbpqvdqz0PoBa3QgAYIOJEDQgQQIOpAAQQcSIOhAAgQdSICgAwkQdCABgg4k0Crotgdtb7G91/Ye21eUbgxAd9qe675e0pMR8RPbcyWdXrAnAB2bNOi250u6UtJqSYqIo5KOlm0LQJfabLpfLOkDSffbftn2xmaQw3+xvcb2Dts7Ou8SwDfSJuinSFos6Z6IWCTpc0l3nPgkRjIB/atN0A9IOhARLzaPt6gXfAAzxKRBj4j3JL1je2HzpeWSXivaFYBOtT3qfqukTc0R9/2SbinXEoCutQp6RIxKYt8bmKE4Mw5IgKADCRB0IAGCDiRA0IEECDqQAEEHEiDoQALMXjsJtWeTDQ8PV603ODhYtd7IyEjVerVn2fUD1uhAAgQdSICgAwkQdCABgg4kQNCBBAg6kABBBxIg6EACkwbd9kLbo8fdjtheW6E3AB2Z9BTYiHhd0rAk2R6Q9A9JW8u2BaBLU910Xy7pzYh4u0QzAMqYatBXSdpcohEA5bQOenNN95WSHv0f32f2GtCnpvIx1Wsl7YqI9yf6ZkRskLRBkmxHB70B6MhUNt1vFJvtwIzUKui2T5d0taTHy7YDoIS2I5n+KenbhXsBUAhnxgEJEHQgAYIOJEDQgQQIOpAAQQcSIOhAAgQdSICgAwk4ovvPn9j+QNLJfGb9HEkfdtxOP9SiHvVq1bsoIs498YtFgn6ybO+IiMtnWy3qUW+667HpDiRA0IEE+i3oG2ZpLepRb1rr9dU+OoAy+m2NDqAAgg4kQNCBBAg6kABBBxL4N14NjAwB0Bd0AAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "plt.matshow(dataset.data[9].reshape(8,8))" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0, 1, 2, 3, 4])" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset.target[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
pixel_0_0pixel_0_1pixel_0_2pixel_0_3pixel_0_4pixel_0_5pixel_0_6pixel_0_7pixel_1_0pixel_1_1...pixel_6_6pixel_6_7pixel_7_0pixel_7_1pixel_7_2pixel_7_3pixel_7_4pixel_7_5pixel_7_6pixel_7_7
00.00.05.013.09.01.00.00.00.00.0...0.00.00.00.06.013.010.00.00.00.0
10.00.00.012.013.05.00.00.00.00.0...0.00.00.00.00.011.016.010.00.00.0
20.00.00.04.015.012.00.00.00.00.0...5.00.00.00.00.03.011.016.09.00.0
30.00.07.015.013.01.00.00.00.08.0...9.00.00.00.07.013.013.09.00.00.0
40.00.00.01.011.00.00.00.00.00.0...0.00.00.00.00.02.016.04.00.00.0
\n", + "

5 rows × 64 columns

\n", + "
" + ], + "text/plain": [ + " pixel_0_0 pixel_0_1 pixel_0_2 pixel_0_3 pixel_0_4 pixel_0_5 \\\n", + "0 0.0 0.0 5.0 13.0 9.0 1.0 \n", + "1 0.0 0.0 0.0 12.0 13.0 5.0 \n", + "2 0.0 0.0 0.0 4.0 15.0 12.0 \n", + "3 0.0 0.0 7.0 15.0 13.0 1.0 \n", + "4 0.0 0.0 0.0 1.0 11.0 0.0 \n", + "\n", + " pixel_0_6 pixel_0_7 pixel_1_0 pixel_1_1 ... pixel_6_6 pixel_6_7 \\\n", + "0 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "1 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "2 0.0 0.0 0.0 0.0 ... 5.0 0.0 \n", + "3 0.0 0.0 0.0 8.0 ... 9.0 0.0 \n", + "4 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "\n", + " pixel_7_0 pixel_7_1 pixel_7_2 pixel_7_3 pixel_7_4 pixel_7_5 \\\n", + "0 0.0 0.0 6.0 13.0 10.0 0.0 \n", + "1 0.0 0.0 0.0 11.0 16.0 10.0 \n", + "2 0.0 0.0 0.0 3.0 11.0 16.0 \n", + "3 0.0 0.0 7.0 13.0 13.0 9.0 \n", + "4 0.0 0.0 0.0 2.0 16.0 4.0 \n", + "\n", + " pixel_7_6 pixel_7_7 \n", + "0 0.0 0.0 \n", + "1 0.0 0.0 \n", + "2 9.0 0.0 \n", + "3 0.0 0.0 \n", + "4 0.0 0.0 \n", + "\n", + "[5 rows x 64 columns]" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df = pd.DataFrame(dataset.data, columns=dataset.feature_names)\n", + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0, 1, 2, ..., 8, 9, 8])" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dataset.target" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
pixel_0_0pixel_0_1pixel_0_2pixel_0_3pixel_0_4pixel_0_5pixel_0_6pixel_0_7pixel_1_0pixel_1_1...pixel_6_6pixel_6_7pixel_7_0pixel_7_1pixel_7_2pixel_7_3pixel_7_4pixel_7_5pixel_7_6pixel_7_7
count1797.01797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.000000...1797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.0000001797.000000
mean0.00.3038405.20478611.83583811.8480805.7818591.3622700.1296610.0055651.993879...3.7250970.2064550.0005560.2793545.55759612.08903711.8091266.7640512.0678910.364496
std0.00.9071924.7548264.2488424.2873885.6664183.3257751.0373830.0942223.196160...4.9194060.9844010.0235900.9343025.1030194.3746944.9339475.9006234.0905481.860122
min0.00.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
25%0.00.0000001.00000010.00000010.0000000.0000000.0000000.0000000.0000000.000000...0.0000000.0000000.0000000.0000001.00000011.00000010.0000000.0000000.0000000.000000
50%0.00.0000004.00000013.00000013.0000004.0000000.0000000.0000000.0000000.000000...1.0000000.0000000.0000000.0000004.00000013.00000014.0000006.0000000.0000000.000000
75%0.00.0000009.00000015.00000015.00000011.0000000.0000000.0000000.0000003.000000...7.0000000.0000000.0000000.00000010.00000016.00000016.00000012.0000002.0000000.000000
max0.08.00000016.00000016.00000016.00000016.00000016.00000015.0000002.00000016.000000...16.00000013.0000001.0000009.00000016.00000016.00000016.00000016.00000016.00000016.000000
\n", + "

8 rows × 64 columns

\n", + "
" + ], + "text/plain": [ + " pixel_0_0 pixel_0_1 pixel_0_2 pixel_0_3 pixel_0_4 \\\n", + "count 1797.0 1797.000000 1797.000000 1797.000000 1797.000000 \n", + "mean 0.0 0.303840 5.204786 11.835838 11.848080 \n", + "std 0.0 0.907192 4.754826 4.248842 4.287388 \n", + "min 0.0 0.000000 0.000000 0.000000 0.000000 \n", + "25% 0.0 0.000000 1.000000 10.000000 10.000000 \n", + "50% 0.0 0.000000 4.000000 13.000000 13.000000 \n", + "75% 0.0 0.000000 9.000000 15.000000 15.000000 \n", + "max 0.0 8.000000 16.000000 16.000000 16.000000 \n", + "\n", + " pixel_0_5 pixel_0_6 pixel_0_7 pixel_1_0 pixel_1_1 ... \\\n", + "count 1797.000000 1797.000000 1797.000000 1797.000000 1797.000000 ... \n", + "mean 5.781859 1.362270 0.129661 0.005565 1.993879 ... \n", + "std 5.666418 3.325775 1.037383 0.094222 3.196160 ... \n", + "min 0.000000 0.000000 0.000000 0.000000 0.000000 ... \n", + "25% 0.000000 0.000000 0.000000 0.000000 0.000000 ... \n", + "50% 4.000000 0.000000 0.000000 0.000000 0.000000 ... \n", + "75% 11.000000 0.000000 0.000000 0.000000 3.000000 ... \n", + "max 16.000000 16.000000 15.000000 2.000000 16.000000 ... \n", + "\n", + " pixel_6_6 pixel_6_7 pixel_7_0 pixel_7_1 pixel_7_2 \\\n", + "count 1797.000000 1797.000000 1797.000000 1797.000000 1797.000000 \n", + "mean 3.725097 0.206455 0.000556 0.279354 5.557596 \n", + "std 4.919406 0.984401 0.023590 0.934302 5.103019 \n", + "min 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "25% 0.000000 0.000000 0.000000 0.000000 1.000000 \n", + "50% 1.000000 0.000000 0.000000 0.000000 4.000000 \n", + "75% 7.000000 0.000000 0.000000 0.000000 10.000000 \n", + "max 16.000000 13.000000 1.000000 9.000000 16.000000 \n", + "\n", + " pixel_7_3 pixel_7_4 pixel_7_5 pixel_7_6 pixel_7_7 \n", + "count 1797.000000 1797.000000 1797.000000 1797.000000 1797.000000 \n", + "mean 12.089037 11.809126 6.764051 2.067891 0.364496 \n", + "std 4.374694 4.933947 5.900623 4.090548 1.860122 \n", + "min 0.000000 0.000000 0.000000 0.000000 0.000000 \n", + "25% 11.000000 10.000000 0.000000 0.000000 0.000000 \n", + "50% 13.000000 14.000000 6.000000 0.000000 0.000000 \n", + "75% 16.000000 16.000000 12.000000 2.000000 0.000000 \n", + "max 16.000000 16.000000 16.000000 16.000000 16.000000 \n", + "\n", + "[8 rows x 64 columns]" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [], + "source": [ + "X = df\n", + "y = dataset.target" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0. , -0.33501649, -0.04308102, ..., -1.14664746,\n", + " -0.5056698 , -0.19600752],\n", + " [ 0. , -0.33501649, -1.09493684, ..., 0.54856067,\n", + " -0.5056698 , -0.19600752],\n", + " [ 0. , -0.33501649, -1.09493684, ..., 1.56568555,\n", + " 1.6951369 , -0.19600752],\n", + " ...,\n", + " [ 0. , -0.33501649, -0.88456568, ..., -0.12952258,\n", + " -0.5056698 , -0.19600752],\n", + " [ 0. , -0.33501649, -0.67419451, ..., 0.8876023 ,\n", + " -0.5056698 , -0.19600752],\n", + " [ 0. , -0.33501649, 1.00877481, ..., 0.8876023 ,\n", + " -0.26113572, -0.19600752]])" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.preprocessing import StandardScaler\n", + "\n", + "scaler = StandardScaler()\n", + "X_scaled = scaler.fit_transform(X)\n", + "X_scaled" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "\n", + "X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.2, random_state=30)" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9722222222222222" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "model = LogisticRegression()\n", + "model.fit(X_train, y_train)\n", + "model.score(X_test, y_test)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Use PCA to reduce dimensions

" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
pixel_0_0pixel_0_1pixel_0_2pixel_0_3pixel_0_4pixel_0_5pixel_0_6pixel_0_7pixel_1_0pixel_1_1...pixel_6_6pixel_6_7pixel_7_0pixel_7_1pixel_7_2pixel_7_3pixel_7_4pixel_7_5pixel_7_6pixel_7_7
00.00.05.013.09.01.00.00.00.00.0...0.00.00.00.06.013.010.00.00.00.0
10.00.00.012.013.05.00.00.00.00.0...0.00.00.00.00.011.016.010.00.00.0
20.00.00.04.015.012.00.00.00.00.0...5.00.00.00.00.03.011.016.09.00.0
30.00.07.015.013.01.00.00.00.08.0...9.00.00.00.07.013.013.09.00.00.0
40.00.00.01.011.00.00.00.00.00.0...0.00.00.00.00.02.016.04.00.00.0
..................................................................
17920.00.04.010.013.06.00.00.00.01.0...4.00.00.00.02.014.015.09.00.00.0
17930.00.06.016.013.011.01.00.00.00.0...1.00.00.00.06.016.014.06.00.00.0
17940.00.01.011.015.01.00.00.00.00.0...0.00.00.00.02.09.013.06.00.00.0
17950.00.02.010.07.00.00.00.00.00.0...2.00.00.00.05.012.016.012.00.00.0
17960.00.010.014.08.01.00.00.00.02.0...8.00.00.01.08.012.014.012.01.00.0
\n", + "

1797 rows × 64 columns

\n", + "
" + ], + "text/plain": [ + " pixel_0_0 pixel_0_1 pixel_0_2 pixel_0_3 pixel_0_4 pixel_0_5 \\\n", + "0 0.0 0.0 5.0 13.0 9.0 1.0 \n", + "1 0.0 0.0 0.0 12.0 13.0 5.0 \n", + "2 0.0 0.0 0.0 4.0 15.0 12.0 \n", + "3 0.0 0.0 7.0 15.0 13.0 1.0 \n", + "4 0.0 0.0 0.0 1.0 11.0 0.0 \n", + "... ... ... ... ... ... ... \n", + "1792 0.0 0.0 4.0 10.0 13.0 6.0 \n", + "1793 0.0 0.0 6.0 16.0 13.0 11.0 \n", + "1794 0.0 0.0 1.0 11.0 15.0 1.0 \n", + "1795 0.0 0.0 2.0 10.0 7.0 0.0 \n", + "1796 0.0 0.0 10.0 14.0 8.0 1.0 \n", + "\n", + " pixel_0_6 pixel_0_7 pixel_1_0 pixel_1_1 ... pixel_6_6 pixel_6_7 \\\n", + "0 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "1 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "2 0.0 0.0 0.0 0.0 ... 5.0 0.0 \n", + "3 0.0 0.0 0.0 8.0 ... 9.0 0.0 \n", + "4 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "... ... ... ... ... ... ... ... \n", + "1792 0.0 0.0 0.0 1.0 ... 4.0 0.0 \n", + "1793 1.0 0.0 0.0 0.0 ... 1.0 0.0 \n", + "1794 0.0 0.0 0.0 0.0 ... 0.0 0.0 \n", + "1795 0.0 0.0 0.0 0.0 ... 2.0 0.0 \n", + "1796 0.0 0.0 0.0 2.0 ... 8.0 0.0 \n", + "\n", + " pixel_7_0 pixel_7_1 pixel_7_2 pixel_7_3 pixel_7_4 pixel_7_5 \\\n", + "0 0.0 0.0 6.0 13.0 10.0 0.0 \n", + "1 0.0 0.0 0.0 11.0 16.0 10.0 \n", + "2 0.0 0.0 0.0 3.0 11.0 16.0 \n", + "3 0.0 0.0 7.0 13.0 13.0 9.0 \n", + "4 0.0 0.0 0.0 2.0 16.0 4.0 \n", + "... ... ... ... ... ... ... \n", + "1792 0.0 0.0 2.0 14.0 15.0 9.0 \n", + "1793 0.0 0.0 6.0 16.0 14.0 6.0 \n", + "1794 0.0 0.0 2.0 9.0 13.0 6.0 \n", + "1795 0.0 0.0 5.0 12.0 16.0 12.0 \n", + "1796 0.0 1.0 8.0 12.0 14.0 12.0 \n", + "\n", + " pixel_7_6 pixel_7_7 \n", + "0 0.0 0.0 \n", + "1 0.0 0.0 \n", + "2 9.0 0.0 \n", + "3 0.0 0.0 \n", + "4 0.0 0.0 \n", + "... ... ... \n", + "1792 0.0 0.0 \n", + "1793 0.0 0.0 \n", + "1794 0.0 0.0 \n", + "1795 0.0 0.0 \n", + "1796 1.0 0.0 \n", + "\n", + "[1797 rows x 64 columns]" + ] + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Use components such that 95% of variance is retained

" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(1797, 29)" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.decomposition import PCA\n", + "\n", + "pca = PCA(0.95)\n", + "X_pca = pca.fit_transform(X)\n", + "X_pca.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0.14890594, 0.13618771, 0.11794594, 0.08409979, 0.05782415,\n", + " 0.0491691 , 0.04315987, 0.03661373, 0.03353248, 0.03078806,\n", + " 0.02372341, 0.02272697, 0.01821863, 0.01773855, 0.01467101,\n", + " 0.01409716, 0.01318589, 0.01248138, 0.01017718, 0.00905617,\n", + " 0.00889538, 0.00797123, 0.00767493, 0.00722904, 0.00695889,\n", + " 0.00596081, 0.00575615, 0.00515158, 0.0048954 ])" + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pca.explained_variance_ratio_" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "29" + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pca.n_components_" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**PCA created 29 components out of 64 original columns**" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ -1.25946645, 21.27488348, -9.46305462, ..., 3.67072108,\n", + " -0.9436689 , -1.13250195],\n", + " [ 7.9576113 , -20.76869896, 4.43950604, ..., 2.18261819,\n", + " -0.51022719, 2.31354911],\n", + " [ 6.99192297, -9.95598641, 2.95855808, ..., 4.22882114,\n", + " 2.1576573 , 0.8379578 ],\n", + " ...,\n", + " [ 10.8012837 , -6.96025223, 5.59955453, ..., -3.56866194,\n", + " 1.82444444, 3.53885886],\n", + " [ -4.87210009, 12.42395362, -10.17086635, ..., 3.25330054,\n", + " 0.95484174, -0.93895602],\n", + " [ -0.34438963, 6.36554919, 10.77370849, ..., -3.01636722,\n", + " 1.29752723, 2.58810313]])" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X_pca" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [], + "source": [ + "X_train_pca, X_test_pca, y_train, y_test = train_test_split(X_pca, y, test_size=0.2, random_state=30)" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9694444444444444" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "model = LogisticRegression(max_iter=1000)\n", + "model.fit(X_train_pca, y_train)\n", + "model.score(X_test_pca, y_test)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Let's now select only two components**" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1797, 2)" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pca = PCA(n_components=2)\n", + "X_pca = pca.fit_transform(X)\n", + "X_pca.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ -1.25946639, 21.27487891],\n", + " [ 7.95760922, -20.76869518],\n", + " [ 6.99192341, -9.95598163],\n", + " ...,\n", + " [ 10.80128435, -6.96025523],\n", + " [ -4.87210315, 12.42395926],\n", + " [ -0.34438701, 6.36554335]])" + ] + }, + "execution_count": 96, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X_pca" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0.14890594, 0.13618771])" + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pca.explained_variance_ratio_" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**You can see that both combined retains 0.14+0.13=0.27 or 27% of important feature information**" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.6083333333333333" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X_train_pca, X_test_pca, y_train, y_test = train_test_split(X_pca, y, test_size=0.2, random_state=30)\n", + "\n", + "model = LogisticRegression(max_iter=1000)\n", + "model.fit(X_train_pca, y_train)\n", + "model.score(X_test_pca, y_test)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We get less accuancy (~60%) as using only 2 components did not retain much of the feature information. However in real life you will find many cases where using 2 or few PCA components can still give you a pretty good accuracy" + ] + } + ], + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/ML/18_PCA/pca_exercise.md b/ML/18_PCA/pca_exercise.md new file mode 100644 index 00000000..413d70e8 --- /dev/null +++ b/ML/18_PCA/pca_exercise.md @@ -0,0 +1,15 @@ +Download heart disease dataset heart.csv in Exercise folder and do following, (credits of dataset: https://www.kaggle.com/fedesoriano/heart-failure-prediction) + +1. Load heart disease dataset in pandas dataframe +1. Remove outliers using Z score. Usual guideline is to remove anything that has Z score > 3 formula or Z score < -3 +1. Convert text columns to numbers using label encoding and one hot encoding +1. Apply scaling +1. Build a classification model using various methods (SVM, logistic regression, random forest) and check which model gives you the best accuracy +1. Now use PCA to reduce dimensions, retrain your model and see what impact it has on your model in terms of accuracy. Keep in mind that many times doing PCA reduces the accuracy but computation is much lighter and that's the trade off you need to consider while building models in real life + + +[Solution Link]() + + + + \ No newline at end of file