completed final part of unsupervised learning
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,213 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Your Turn! (Solution)\n",
|
||||||
|
"\n",
|
||||||
|
"In the last video, you saw two of the main aspects of principal components:\n",
|
||||||
|
"\n",
|
||||||
|
"1. **The amount of variability captured by the component.**\n",
|
||||||
|
"2. **The components themselves.**\n",
|
||||||
|
"\n",
|
||||||
|
"In this notebook, you will get a chance to explore these a bit more yourself. First, let's read in the necessary libraries, as well as the data."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"from sklearn.decomposition import PCA\n",
|
||||||
|
"from sklearn.preprocessing import StandardScaler\n",
|
||||||
|
"from sklearn.ensemble import RandomForestClassifier\n",
|
||||||
|
"from sklearn.model_selection import train_test_split\n",
|
||||||
|
"from sklearn.metrics import confusion_matrix, accuracy_score\n",
|
||||||
|
"from helper_functions import show_images, do_pca, scree_plot, plot_component\n",
|
||||||
|
"import test_code as t\n",
|
||||||
|
"\n",
|
||||||
|
"import matplotlib.image as mpimg\n",
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import seaborn as sns\n",
|
||||||
|
"\n",
|
||||||
|
"%matplotlib inline\n",
|
||||||
|
"\n",
|
||||||
|
"#read in our dataset\n",
|
||||||
|
"train = pd.read_csv('./data/train.csv')\n",
|
||||||
|
"train.fillna(0, inplace=True)\n",
|
||||||
|
"\n",
|
||||||
|
"# save the labels to a Pandas series target\n",
|
||||||
|
"y = train['label']\n",
|
||||||
|
"# Drop the label feature\n",
|
||||||
|
"X = train.drop(\"label\",axis=1)\n",
|
||||||
|
"\n",
|
||||||
|
"show_images(30)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"`1.` Perform PCA on the **X** matrix using on your own or using the **do_pca** function from the **helper_functions** module. Reduce the original more than 700 features to only 10 principal components."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"pca, X_pca = do_pca(10, X)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"`2.` Now use the **scree_plot** function from the **helper_functions** module to take a closer look at the results of your analysis."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"scree_plot(pca)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"`3.` Using the results of your scree plot, match each letter as the value to the correct key in the **solution_three** dictionary. Once you are confident in your solution run the next cell to see if your solution matches ours."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"a = True\n",
|
||||||
|
"b = False\n",
|
||||||
|
"c = 6.13\n",
|
||||||
|
"d = 'The total amount of variability in the data explained by the first two principal components'\n",
|
||||||
|
"e = None\n",
|
||||||
|
"\n",
|
||||||
|
"solution_three = {\n",
|
||||||
|
" '10.42' : d, \n",
|
||||||
|
" 'The first component will ALWAYS have the most amount of variability explained.': a,\n",
|
||||||
|
" 'The total amount of variability in the data explained by the first component': c,\n",
|
||||||
|
" 'The sum of the variability explained by all the components can be greater than 100%': b\n",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"#Run this cell to see if your solution matches ours\n",
|
||||||
|
"t.question_3_check(solution_three)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"`4.` Use the **plot_component** function from the **helper_functions** module to look at each of the components (remember they are 0 indexed). Use the results to assist with question 5."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"plot_component(pca, 3)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"`5.` Using the results from viewing each of your principal component weights in question 4, change the following values of the **solution_five** dictionary to the **number of the index** for the principal component that best matches the description. Once you are confident in your solution run the next cell to see if your solution matches ours."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"solution_five = {\n",
|
||||||
|
" 'This component looks like it will assist in identifying zero': 0,\n",
|
||||||
|
" 'This component looks like it will assist in identifying three': 3\n",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"#Run this cell to see if your solution matches ours\n",
|
||||||
|
"t.question_5_check(solution_five)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"From this notebook, you have had an opportunity to look at the two major parts of PCA:\n",
|
||||||
|
"\n",
|
||||||
|
"`I.` The amount of **variance explained by each component**. This is called an **eigenvalue**.\n",
|
||||||
|
"\n",
|
||||||
|
"`II.` The principal components themselves, each component is a vector of weights. In this case, the principal components help us understand which pixels of the image are most helpful in identifying the difference between between digits. **Principal components** are also known as **eigenvectors**."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.6.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,388 @@
|
|||||||
|
Sports,SUV,Wagon,Minivan,Pickup,AWD,RWD,Retail,Dealer,Engine,Cylinders,Horsepower,CityMPG,HighwayMPG,Weight,Wheelbase,Length,Width
|
||||||
|
Acura 3.5 RL,0,0,0,0,0,0,0,43755,39014,3.5,6,225,18,24,3880,115,197,72
|
||||||
|
Acura 3.5 RL Navigation,0,0,0,0,0,0,0,46100,41100,3.5,6,225,18,24,3893,115,197,72
|
||||||
|
Acura MDX,0,1,0,0,0,1,0,36945,33337,3.5,6,265,17,23,4451,106,189,77
|
||||||
|
Acura NSX S,1,0,0,0,0,0,1,89765,79978,3.2,6,290,17,24,3153,100,174,71
|
||||||
|
Acura RSX,0,0,0,0,0,0,0,23820,21761,2.0,4,200,24,31,2778,101,172,68
|
||||||
|
Acura TL,0,0,0,0,0,0,0,33195,30299,3.2,6,270,20,28,3575,108,186,72
|
||||||
|
Acura TSX,0,0,0,0,0,0,0,26990,24647,2.4,4,200,22,29,3230,105,183,69
|
||||||
|
Audi A4 1.8T,0,0,0,0,0,0,0,25940,23508,1.8,4,170,22,31,3252,104,179,70
|
||||||
|
Audi A4 1.8T convertible,0,0,0,0,0,0,0,35940,32506,1.8,4,170,23,30,3638,105,180,70
|
||||||
|
Audi A4 3.0 convertible,0,0,0,0,0,0,0,42490,38325,3.0,6,220,20,27,3814,105,180,70
|
||||||
|
Audi A4 3.0,0,0,0,0,0,0,0,31840,28846,3.0,6,220,20,28,3462,104,179,70
|
||||||
|
Audi A4 3.0 Quattro manual,0,0,0,0,0,1,0,33430,30366,3.0,6,220,17,26,3583,104,179,70
|
||||||
|
Audi A4 3.0 Quattro auto,0,0,0,0,0,1,0,34480,31388,3.0,6,220,18,25,3627,104,179,70
|
||||||
|
Audi A4 3.0 Quattro convertible,0,0,0,0,0,1,0,44240,40075,3.0,6,220,18,25,4013,105,180,70
|
||||||
|
Audi A6 2.7 Turbo Quattro four-door,0,0,0,0,0,1,0,42840,38840,2.7,6,250,18,25,3836,109,192,71
|
||||||
|
Audi A6 3.0,0,0,0,0,0,0,0,36640,33129,3.0,6,220,20,27,3561,109,192,71
|
||||||
|
Audi A6 3.0 Avant Quattro,0,0,1,0,0,1,0,40840,37060,3.0,6,220,18,25,4035,109,192,71
|
||||||
|
Audi A6 3.0 Quattro,0,0,0,0,0,1,0,39640,35992,3.0,6,220,18,25,3880,109,192,71
|
||||||
|
Audi A6 4.2 Quattro,0,0,0,0,0,1,0,49690,44936,4.2,8,300,17,24,4024,109,193,71
|
||||||
|
Audi A8 L Quattro,0,0,0,0,0,1,0,69190,64740,4.2,8,330,17,24,4399,121,204,75
|
||||||
|
Audi S4 Avant Quattro,0,0,1,0,0,1,0,49090,44446,4.2,8,340,15,21,3936,104,179,70
|
||||||
|
Audi S4 Quattro,0,0,0,0,0,1,0,48040,43556,4.2,8,340,14,20,3825,104,179,70
|
||||||
|
Audi RS 6,1,0,0,0,0,0,0,84600,76417,4.2,8,450,15,22,4024,109,191,78
|
||||||
|
Audi TT 1.8,1,0,0,0,0,0,0,35940,32512,1.8,4,180,20,28,3131,95,159,73
|
||||||
|
Audi TT 1.8 Quattro,1,0,0,0,0,1,0,37390,33891,1.8,4,225,20,28,2921,96,159,73
|
||||||
|
Audi TT 3.2,1,0,0,0,0,1,0,40590,36739,3.2,6,250,21,29,3351,96,159,73
|
||||||
|
BMW 325i,0,0,0,0,0,0,1,28495,26155,2.5,6,184,20,29,3219,107,176,69
|
||||||
|
BMW 325Ci,0,0,0,0,0,0,1,30795,28245,2.5,6,184,20,29,3197,107,177,69
|
||||||
|
BMW 325Ci convertible,0,0,0,0,0,0,1,37995,34800,2.5,6,184,19,27,3560,107,177,69
|
||||||
|
BMW 325xi,0,0,0,0,0,1,0,30245,27745,2.5,6,184,19,27,3461,107,176,69
|
||||||
|
BMW 325xi Sport,0,0,1,0,0,1,0,32845,30110,2.5,6,184,19,26,3594,107,176,69
|
||||||
|
BMW 330Ci,0,0,0,0,0,0,1,36995,33890,3.0,6,225,20,30,3285,107,176,69
|
||||||
|
BMW 330Ci convertible,0,0,0,0,0,0,1,44295,40530,3.0,6,225,19,28,3616,107,177,69
|
||||||
|
BMW 330i,0,0,0,0,0,0,1,35495,32525,3.0,6,225,20,30,3285,107,176,69
|
||||||
|
BMW 330xi,0,0,0,0,0,1,0,37245,34115,3.0,6,225,20,29,3483,107,176,69
|
||||||
|
BMW 525i four-door,0,0,0,0,0,0,1,39995,36620,2.5,6,184,19,28,3428,114,191,73
|
||||||
|
BMW 530i four-door,0,0,0,0,0,0,1,44995,41170,3.0,6,225,20,30,3472,114,191,73
|
||||||
|
BMW 545iA four-door,0,0,0,0,0,0,1,54995,50270,4.4,8,325,18,26,3814,114,191,73
|
||||||
|
BMW 745i four-door,0,0,0,0,0,0,1,69195,63190,4.4,8,325,18,26,4376,118,198,75
|
||||||
|
BMW 745Li four-door,0,0,0,0,0,0,1,73195,66830,4.4,8,325,18,26,4464,123,204,75
|
||||||
|
BMW M3,1,0,0,0,0,0,1,48195,44170,3.2,6,333,16,24,3415,108,177,70
|
||||||
|
BMW M3 convertible,1,0,0,0,0,0,1,56595,51815,3.2,6,333,16,23,3781,108,177,70
|
||||||
|
BMW X3 3.0i,0,1,0,0,0,1,0,37000,33873,3.0,6,225,16,23,4023,110,180,73
|
||||||
|
BMW X5 4.4i,0,1,0,0,0,1,0,52195,47720,4.4,8,325,16,22,4824,111,184,74
|
||||||
|
BMW Z4 convertible 2.5i two-door,1,0,0,0,0,0,1,33895,31065,2.5,6,184,20,28,2932,98,161,70
|
||||||
|
BMW Z4 convertible 3.0i two-door,1,0,0,0,0,0,1,41045,37575,3.0,6,225,21,29,2998,98,161,70
|
||||||
|
Buick Century Custom,0,0,0,0,0,0,0,22180,20351,3.1,6,175,20,30,3353,109,195,73
|
||||||
|
Buick LeSabre Custom four-door,0,0,0,0,0,0,0,26470,24282,3.8,6,205,20,29,3567,112,200,74
|
||||||
|
Buick LeSabre Limited,0,0,0,0,0,0,0,32245,29566,3.8,6,205,20,29,3591,112,200,74
|
||||||
|
Buick Park Avenue,0,0,0,0,0,0,0,35545,32244,3.8,6,205,20,29,3778,114,207,75
|
||||||
|
Buick Park Avenue Ultra,0,0,0,0,0,0,0,40720,36927,3.8,6,240,18,28,3909,114,207,75
|
||||||
|
Buick Rainier,0,1,0,0,0,1,0,37895,34357,4.2,6,275,15,21,4600,113,193,75
|
||||||
|
Buick Regal GS,0,0,0,0,0,0,0,28345,26047,3.8,6,240,18,28,3536,109,196,73
|
||||||
|
Buick Regal LS,0,0,0,0,0,0,0,24895,22835,3.8,6,200,20,30,3461,109,196,73
|
||||||
|
Buick Rendezvous CX,0,1,0,0,0,0,0,26545,24085,3.4,6,185,19,26,4024,112,187,74
|
||||||
|
Cadillac CTS VVT,0,0,0,0,0,0,1,30835,28575,3.6,6,255,18,25,3694,113,190,71
|
||||||
|
Cadillac Deville,0,0,0,0,0,0,0,45445,41650,4.6,8,275,18,26,3984,115,207,74
|
||||||
|
Cadillac Deville DTS,0,0,0,0,0,0,0,50595,46362,4.6,8,300,18,26,4044,115,207,74
|
||||||
|
Cadillac Escaladet,0,1,0,0,0,0,0,52795,48377,5.3,8,295,14,18,5367,116,199,79
|
||||||
|
Cadillac Seville,0,0,0,0,0,0,0,47955,43841,4.6,8,275,18,26,3992,112,201,75
|
||||||
|
Cadillac SRX V8,0,1,0,0,0,0,0,46995,43523,4.6,8,320,16,21,4302,116,195,73
|
||||||
|
Cadillac XLR,1,0,0,0,0,0,1,76200,70546,4.6,8,320,17,25,3647,106,178,72
|
||||||
|
Chevrolet Aveo,0,0,0,0,0,0,0,11690,10965,1.6,4,103,28,34,2370,98,167,66
|
||||||
|
Chevrolet Astro,0,0,0,1,0,1,0,26395,23954,4.3,6,190,14,17,4605,111,190,78
|
||||||
|
Chevrolet Aveo LS,0,0,0,0,0,0,0,12585,11802,1.6,4,103,28,34,2348,98,153,66
|
||||||
|
Chevrolet Cavalier two-door,0,0,0,0,0,0,0,14610,13697,2.2,4,140,26,37,2617,104,183,69
|
||||||
|
Chevrolet Cavalier four-door,0,0,0,0,0,0,0,14810,13884,2.2,4,140,26,37,2676,104,183,68
|
||||||
|
Chevrolet Cavalier LS,0,0,0,0,0,0,0,16385,15357,2.2,4,140,26,37,2617,104,183,69
|
||||||
|
Chevrolet Corvette,1,0,0,0,0,0,1,44535,39068,5.7,8,350,18,25,3246,105,180,74
|
||||||
|
Chevrolet Corvette convertible,1,0,0,0,0,0,1,51535,45193,5.7,8,350,18,25,3248,105,180,74
|
||||||
|
Chevrolet Impala,0,0,0,0,0,0,0,21900,20095,3.4,6,180,21,32,3465,111,200,73
|
||||||
|
Chevrolet Impala LS,0,0,0,0,0,0,0,25000,22931,3.8,6,200,20,30,3476,111,200,73
|
||||||
|
Chevrolet Impala SS,0,0,0,0,0,0,0,27995,25672,3.8,6,240,18,28,3606,111,200,73
|
||||||
|
Chevrolet Malibu,0,0,0,0,0,0,0,18995,17434,2.2,4,145,24,34,3174,106,188,70
|
||||||
|
Chevrolet Malibu LS,0,0,0,0,0,0,0,20370,18639,3.5,6,200,22,30,3297,106,188,70
|
||||||
|
Chevrolet Malibu LT,0,0,0,0,0,0,0,23495,21551,3.5,6,200,23,32,3315,106,188,70
|
||||||
|
Chevrolet Malibu Maxx,0,0,1,0,0,0,0,22225,20394,3.5,6,200,22,30,3458,112,188,70
|
||||||
|
Chevrolet Monte Carlo LS,0,0,0,0,0,0,0,21825,20026,3.4,6,180,21,32,3340,111,198,73
|
||||||
|
Chevrolet Monte Carlo SS,0,0,0,0,0,0,0,24225,22222,3.8,6,200,18,28,3434,111,198,73
|
||||||
|
Chevrolet Suburban 1500 LT,0,1,0,0,0,0,0,42735,37422,5.3,8,295,14,18,4947,130,219,79
|
||||||
|
Chevrolet Tahoe LT,0,1,0,0,0,1,0,41465,36287,5.3,8,295,14,18,5050,116,197,79
|
||||||
|
Chevrolet Tracker,0,1,0,0,0,0,0,20255,19108,2.5,6,165,19,22,2866,98,163,67
|
||||||
|
Chevrolet TrailBlazer LT,0,1,0,0,0,0,0,30295,27479,4.2,6,275,16,21,4425,113,192,75
|
||||||
|
Chevrolet Venture LS,0,0,0,1,0,0,0,27020,24518,3.4,6,185,19,26,3699,112,187,72
|
||||||
|
Chrysler 300M,0,0,0,0,0,0,0,29865,27797,3.5,6,250,18,27,3581,113,198,74
|
||||||
|
Chrysler 300M Special Edition,0,0,0,0,0,0,0,33295,30884,3.5,6,255,18,27,3650,113,198,74
|
||||||
|
Chrysler Concorde LX,0,0,0,0,0,0,0,24130,22452,2.7,6,200,21,29,3479,113,208,74
|
||||||
|
Chrysler Concorde LXi,0,0,0,0,0,0,0,26860,24909,3.5,6,232,19,27,3548,113,208,74
|
||||||
|
Chrysler Crossfire,1,0,0,0,0,0,1,34495,32033,3.2,6,215,17,25,3060,95,160,70
|
||||||
|
Chrysler Pacifica,0,0,1,0,0,0,1,31230,28725,3.5,6,250,17,23,4675,116,199,79
|
||||||
|
Chrysler PT Cruiser,0,0,0,0,0,0,0,17985,16919,2.4,4,150,22,29,3101,103,169,67
|
||||||
|
Chrysler PT Cruiser GT,0,0,0,0,0,0,0,25955,24172,2.4,4,220,21,27,3217,103,169,67
|
||||||
|
Chrysler PT Cruiser Limited,0,0,0,0,0,0,0,22000,20573,2.4,4,150,22,29,3105,103,169,67
|
||||||
|
Chrysler Sebring,0,0,0,0,0,0,0,19090,17805,2.4,4,150,22,30,3173,108,191,71
|
||||||
|
Chrysler Sebring Touring,0,0,0,0,0,0,0,21840,20284,2.7,6,200,21,28,3222,108,191,71
|
||||||
|
Chrysler Sebring convertible,0,0,0,0,0,0,0,25215,23451,2.4,4,150,22,30,3357,106,194,64
|
||||||
|
Chrysler Sebring Limited convertible,0,0,0,0,0,0,0,30950,28613,2.7,6,200,21,28,3448,106,194,69
|
||||||
|
Chrysler Town and Country LX,0,0,0,1,0,0,0,27490,25371,3.3,6,180,19,26,4068,119,201,79
|
||||||
|
Chrysler Town and Country Limited,0,0,0,1,0,0,0,38380,35063,3.8,6,215,18,25,4331,119,201,79
|
||||||
|
Dodge Caravan SE,0,0,0,1,0,0,0,21795,20508,2.4,4,150,20,26,3862,113,189,79
|
||||||
|
Dodge Durango SLT,0,1,0,0,0,1,0,32235,29472,4.7,8,230,15,21,4987,119,201,76
|
||||||
|
Dodge Grand Caravan SXT,0,0,0,1,0,1,0,32660,29812,3.8,6,215,18,25,4440,119,201,79
|
||||||
|
Dodge Intrepid ES,0,0,0,0,0,0,0,24885,23058,3.5,6,232,18,27,3487,113,204,75
|
||||||
|
Dodge Intrepid SE,0,0,0,0,0,0,0,22035,20502,2.7,6,200,21,29,3469,113,204,75
|
||||||
|
Dodge Neon SE,0,0,0,0,0,0,0,13670,12849,2.0,4,132,29,36,2581,105,174,67
|
||||||
|
Dodge Neon SXT,0,0,0,0,0,0,0,15040,14086,2.0,4,132,29,36,2626,105,174,67
|
||||||
|
Dodge Stratus SXT,0,0,0,0,0,0,0,18820,17512,2.4,4,150,21,28,3182,108,191,71
|
||||||
|
Dodge Stratus SE,0,0,0,0,0,0,0,20220,18821,2.4,4,150,21,28,3175,108,191,71
|
||||||
|
Ford Crown Victoria,0,0,0,0,0,0,1,24345,22856,4.6,8,224,17,25,4057,115,212,78
|
||||||
|
Ford Crown Victoria LX,0,0,0,0,0,0,1,27370,25105,4.6,8,224,17,25,4057,115,212,78
|
||||||
|
Ford Crown Victoria LX Sport,0,0,0,0,0,0,1,30315,27756,4.6,8,239,17,25,4057,115,212,78
|
||||||
|
Ford Escape XLS,0,1,0,0,0,1,0,22515,20907,3.0,6,201,18,23,3346,103,173,70
|
||||||
|
Ford Expedition 4.6 XLT,0,1,0,0,0,0,0,34560,30468,4.6,8,232,15,19,5000,119,206,79
|
||||||
|
Ford Explorer XLT V6,0,1,0,0,0,1,0,29670,26983,4.0,6,210,15,20,4463,114,190,72
|
||||||
|
Ford Focus LX,0,0,0,0,0,0,0,13730,12906,2.0,4,110,27,36,2606,103,168,67
|
||||||
|
Ford Focus SE,0,0,0,0,0,0,0,15460,14496,2.0,4,130,26,33,2606,103,168,67
|
||||||
|
Ford Focus SVT,0,0,0,0,0,0,0,19135,17878,2.0,4,170,21,28,2750,103,168,67
|
||||||
|
Ford Focus ZTW,0,0,1,0,0,0,0,17475,16375,2.0,4,130,26,33,2702,103,178,67
|
||||||
|
Ford Focus ZX5,0,0,0,0,0,0,0,15580,14607,2.0,4,130,26,33,2691,103,168,67
|
||||||
|
Ford Focus ZX3,0,0,0,0,0,0,0,13270,12482,2.0,4,130,26,33,2612,103,168,67
|
||||||
|
Ford Freestar SE,0,0,0,1,0,0,0,26930,24498,3.9,6,193,17,23,4275,121,201,77
|
||||||
|
Ford Mustang,1,0,0,0,0,0,1,18345,16943,3.8,6,193,20,29,3290,101,183,73
|
||||||
|
Ford Mustang GT Premium,1,0,0,0,0,0,1,29380,26875,4.6,8,260,17,25,3347,101,183,73
|
||||||
|
Ford Taurus LX,0,0,0,0,0,0,0,20320,18881,3.0,6,155,20,27,3306,109,198,73
|
||||||
|
Ford Taurus SE,0,0,1,0,0,0,0,22290,20457,3.0,6,155,19,26,3497,109,198,73
|
||||||
|
Ford Taurus SES Duratec,0,0,0,0,0,0,0,22735,20857,3.0,6,201,19,26,3313,109,198,73
|
||||||
|
Ford Thunderbird Deluxe,1,0,0,0,0,0,0,37530,34483,3.9,8,280,17,24,3780,107,186,72
|
||||||
|
GMC Envoy XUV SLE,0,1,0,0,0,0,0,31890,28922,4.2,6,275,15,19,4945,129,208,75
|
||||||
|
GMC Safari SLE,0,0,0,1,0,0,1,25640,23215,4.3,6,190,16,20,4309,111,190,78
|
||||||
|
GMC Yukon 1500 SLE,0,1,0,0,0,0,0,35725,31361,4.8,8,285,16,19,5042,116,199,79
|
||||||
|
GMC Yukon XL 2500 SLT,0,1,0,0,0,1,0,46265,40534,6.0,8,325,13,17,6133,130,219,79
|
||||||
|
Honda Accord EX,0,0,0,0,0,0,0,22260,20080,2.4,4,160,26,34,3047,105,188,71
|
||||||
|
Honda Accord EX V6,0,0,0,0,0,0,0,26960,24304,3.0,6,240,21,30,3294,105,188,71
|
||||||
|
Honda Accord LX,0,0,0,0,0,0,0,19860,17924,2.4,4,160,26,34,2994,105,188,71
|
||||||
|
Honda Accord LX V6,0,0,0,0,0,0,0,23760,21428,3.0,6,240,21,30,3349,108,190,72
|
||||||
|
Honda Civic EX,0,0,0,0,0,0,0,17750,16265,1.7,4,127,32,37,2601,103,175,68
|
||||||
|
Honda Civic DX,0,0,0,0,0,0,0,13270,12175,1.7,4,115,32,38,2432,103,175,67
|
||||||
|
Honda Civic HX,0,0,0,0,0,0,0,14170,12996,1.7,4,117,36,44,2500,103,175,67
|
||||||
|
Honda Civic LX,0,0,0,0,0,0,0,15850,14531,1.7,4,115,32,38,2513,103,175,68
|
||||||
|
Honda Civic Si,0,0,0,0,0,0,0,19490,17849,2.0,4,160,26,30,2782,101,166,67
|
||||||
|
Honda Civic Hybrid,0,0,0,0,0,0,0,20140,18451,1.4,4,93,46,51,2732,103,175,68
|
||||||
|
Honda CR-V LX,0,1,0,0,0,1,0,19860,18419,2.4,4,160,21,25,3258,103,179,70
|
||||||
|
Honda Element LX,0,1,0,0,0,1,0,18690,17334,2.4,4,160,21,24,3468,101,167,72
|
||||||
|
Honda Insight,0,0,0,0,0,0,0,19110,17911,2.0,3,73,60,66,1850,95,155,67
|
||||||
|
Honda Odyssey EX,0,0,0,1,0,0,0,27450,24744,3.5,6,240,18,25,4365,118,201,76
|
||||||
|
Honda Odyssey LX,0,0,0,1,0,0,0,24950,22498,3.5,6,240,18,25,4310,118,201,76
|
||||||
|
Honda Pilot LX,0,1,0,0,0,1,0,27560,24843,3.5,6,240,17,22,4387,106,188,77
|
||||||
|
Honda S2000,1,0,0,0,0,0,1,33260,29965,2.2,4,240,20,25,2835,95,162,69
|
||||||
|
Hummer H2,0,1,0,0,0,1,0,49995,45815,6.0,8,316,10,12,6400,123,190,81
|
||||||
|
Hyundai Accent,0,0,0,0,0,0,0,10539,10107,1.6,4,103,29,33,2255,96,167,66
|
||||||
|
Hyundai Accent GL,0,0,0,0,0,0,0,11839,11116,1.6,4,103,29,33,2290,96,167,66
|
||||||
|
Hyundai Accent GT,0,0,0,0,0,0,0,11939,11209,1.6,4,103,29,33,2339,96,167,66
|
||||||
|
Hyundai Elantra GLS,0,0,0,0,0,0,0,13839,12781,2.0,4,138,26,34,2635,103,178,68
|
||||||
|
Hyundai Elantra GT,0,0,0,0,0,0,0,15389,14207,2.0,4,138,26,34,2635,103,178,68
|
||||||
|
Hyundai Elantra GT hatch,0,0,0,0,0,0,0,15389,14207,2.0,4,138,26,34,2698,103,178,68
|
||||||
|
Hyundai Santa Fe GLS,0,1,0,0,0,0,0,21589,20201,2.7,6,173,20,26,3549,103,177,73
|
||||||
|
Hyundai Sonata GLS,0,0,0,0,0,0,0,19339,17574,2.7,6,170,19,27,3217,106,187,72
|
||||||
|
Hyundai Sonata LX,0,0,0,0,0,0,0,20339,18380,2.7,6,170,19,27,3217,106,187,72
|
||||||
|
Hyundai Tiburon GT V6,1,0,0,0,0,0,0,18739,17101,2.7,6,172,19,26,3023,100,173,69
|
||||||
|
Hyundai XG350,0,0,0,0,0,0,0,24589,22055,3.5,6,194,17,26,3651,108,192,72
|
||||||
|
Hyundai XG350 L,0,0,0,0,0,0,0,26189,23486,3.5,6,194,17,26,3651,108,192,72
|
||||||
|
Infiniti FX35,0,0,1,0,0,0,1,34895,31756,3.5,6,280,16,22,4056,112,189,76
|
||||||
|
Infiniti FX45,0,0,1,0,0,1,0,36395,33121,4.5,8,315,15,19,4309,112,189,76
|
||||||
|
Infiniti G35,0,0,0,0,0,0,1,28495,26157,3.5,6,260,18,26,3336,112,187,69
|
||||||
|
Infiniti G35 Sport Coupe,0,0,0,0,0,0,1,29795,27536,3.5,6,280,18,26,3416,112,182,72
|
||||||
|
Infiniti G35 AWD,0,0,0,0,0,1,0,32445,29783,3.5,6,260,18,26,3677,112,187,69
|
||||||
|
Infiniti I35,0,0,0,0,0,0,0,31145,28320,3.5,6,255,19,26,3306,108,194,70
|
||||||
|
Infiniti M45,0,0,0,0,0,0,1,42845,38792,4.5,8,340,17,23,3851,110,197,70
|
||||||
|
Infiniti Q45 Luxury,0,0,0,0,0,0,1,52545,47575,4.5,8,340,17,23,3977,113,200,73
|
||||||
|
Isuzu Ascender S,0,1,0,0,0,1,0,31849,29977,4.2,6,275,15,20,4967,129,208,76
|
||||||
|
Isuzu Rodeo S,0,1,0,0,0,0,0,20449,19261,3.2,6,193,17,21,3836,106,178,70
|
||||||
|
Jaguar S-Type 3.0,0,0,0,0,0,0,1,43895,40004,3.0,6,235,18,26,3777,115,192,72
|
||||||
|
Jaguar S-Type 4.2,0,0,0,0,0,0,1,49995,45556,4.2,8,294,18,28,3874,115,192,72
|
||||||
|
Jaguar S-Type R,0,0,0,0,0,0,1,63120,57499,4.2,8,390,17,24,4046,115,192,72
|
||||||
|
Jaguar Vanden Plas,0,0,0,0,0,0,1,68995,62846,4.2,8,294,18,28,3803,119,200,73
|
||||||
|
Jaguar X-Type 2.5,0,0,0,0,0,1,0,29995,27355,2.5,6,192,18,26,3428,107,184,70
|
||||||
|
Jaguar X-Type 3.0,0,0,0,0,0,1,0,33995,30995,3.0,6,227,18,25,3516,107,184,70
|
||||||
|
Jaguar XJ8,0,0,0,0,0,0,1,59995,54656,4.2,8,294,18,28,3803,119,200,73
|
||||||
|
Jaguar XJR,0,0,0,0,0,0,1,74995,68306,4.2,8,390,17,24,3948,119,200,73
|
||||||
|
Jaguar XK8 coupe,1,0,0,0,0,0,1,69995,63756,4.2,8,294,18,26,3779,102,187,71
|
||||||
|
Jaguar XK8 convertible,1,0,0,0,0,0,1,74995,68306,4.2,8,294,18,26,3980,102,187,71
|
||||||
|
Jaguar XKR coupe,1,0,0,0,0,0,1,81995,74676,4.2,8,390,16,23,3865,102,187,71
|
||||||
|
Jaguar XKR convertible,1,0,0,0,0,0,1,86995,79226,4.2,8,390,16,23,4042,102,187,71
|
||||||
|
Jeep Grand Cherokee Laredo,0,1,0,0,0,0,0,27905,25686,4.0,6,195,16,21,3790,106,181,72
|
||||||
|
Jeep Liberty Sport,0,1,0,0,0,1,0,20130,18973,2.4,4,150,20,24,3826,104,174,72
|
||||||
|
Jeep Wrangler Sahara,0,1,0,0,0,1,0,25520,23275,4.0,6,190,16,19,3575,93,150,67
|
||||||
|
Kia Optima LX,0,0,0,0,0,0,0,16040,14910,2.4,4,138,23,30,3281,106,186,72
|
||||||
|
Kia Optima LX V6,0,0,0,0,0,0,0,18435,16850,2.7,6,170,20,27,3279,106,186,72
|
||||||
|
Kia Rio auto,0,0,0,0,0,0,0,11155,10705,1.6,4,104,25,32,2458,95,167,66
|
||||||
|
Kia Rio manual,0,0,0,0,0,0,0,10280,9875,1.6,4,104,26,33,2403,95,167,66
|
||||||
|
Kia Rio Cinco,0,0,1,0,0,0,0,11905,11410,1.6,4,104,26,33,2447,95,167,66
|
||||||
|
Kia Sedona LX,0,0,0,1,0,0,0,20615,19400,3.5,6,195,16,22,4802,115,194,75
|
||||||
|
Kia Sorento LX,0,1,0,0,0,0,0,19635,18630,3.5,6,192,16,19,4112,107,180,73
|
||||||
|
Kia Spectra,0,0,0,0,0,0,0,12360,11630,1.8,4,124,24,32,2661,101,178,68
|
||||||
|
Kia Spectra GS,0,0,0,0,0,0,0,13580,12830,1.8,4,124,24,32,2686,101,178,68
|
||||||
|
Kia Spectra GSX,0,0,0,0,0,0,0,14630,13790,1.8,4,124,24,32,2697,101,178,68
|
||||||
|
Land Rover Discovery SE,0,1,0,0,0,1,0,39250,35777,4.6,8,217,12,16,4576,100,185,74
|
||||||
|
Land Rover Freelander SE,0,1,0,0,0,1,0,25995,23969,2.5,6,174,18,21,3577,101,175,71
|
||||||
|
Land Rover Range Rover HSE,0,1,0,0,0,1,0,72250,65807,4.4,8,282,12,16,5379,113,195,76
|
||||||
|
Lexus ES 330,0,0,0,0,0,0,0,32350,28755,3.3,6,225,20,29,3460,107,191,71
|
||||||
|
Lexus GS 300,0,0,0,0,0,0,1,41010,36196,3.0,6,220,18,25,3649,110,189,71
|
||||||
|
Lexus GS 430,0,0,0,0,0,0,1,48450,42232,4.3,8,300,18,23,3715,110,189,71
|
||||||
|
Lexus GX 470,0,1,0,0,0,1,0,45700,39838,4.7,8,235,15,19,4740,110,188,74
|
||||||
|
Lexus IS 300 manual,0,0,0,0,0,0,1,31045,27404,3.0,6,215,18,25,3255,105,177,68
|
||||||
|
Lexus IS 300 auto,0,0,0,0,0,0,1,32415,28611,3.0,6,215,18,24,3285,105,177,68
|
||||||
|
Lexus IS 300 SportCross,0,0,1,0,0,0,1,32455,28647,3.0,6,215,18,24,3410,105,177,68
|
||||||
|
Lexus LS 430,0,0,0,0,0,0,1,55750,48583,4.3,8,290,18,25,3990,115,197,72
|
||||||
|
Lexus LX 470,0,1,0,0,0,1,0,64800,56455,4.7,8,235,13,17,5590,112,193,76
|
||||||
|
Lexus SC 430,1,0,0,0,0,0,1,63200,55063,4.3,8,300,18,23,3840,103,178,72
|
||||||
|
Lexus RX 330,0,1,0,0,0,1,0,39195,34576,3.3,6,230,18,24,4065,107,186,73
|
||||||
|
Lincoln Aviator Ultimate,0,1,0,0,0,0,0,42915,39443,4.6,8,302,13,18,4834,114,193,76
|
||||||
|
Lincoln LS V6 Luxury,0,0,0,0,0,0,1,32495,29969,3.0,6,232,20,26,3681,115,194,73
|
||||||
|
Lincoln LS V6 Premium,0,0,0,0,0,0,1,36895,33929,3.0,6,232,20,26,3681,115,194,73
|
||||||
|
Lincoln LS V8 Sport,0,0,0,0,0,0,1,40095,36809,3.9,8,280,17,24,3768,115,194,73
|
||||||
|
Lincoln LS V8 Ultimate,0,0,0,0,0,0,1,43495,39869,3.9,8,280,17,24,3768,115,194,73
|
||||||
|
Lincoln Navigator Luxury,0,1,0,0,0,1,0,52775,46360,5.4,8,300,13,18,5969,119,206,80
|
||||||
|
Lincoln Town Car Signature,0,0,0,0,0,0,1,41815,38418,4.6,8,239,17,25,4369,118,215,78
|
||||||
|
Lincoln Town Car Ultimate,0,0,0,0,0,0,1,44925,41217,4.6,8,239,17,25,4369,118,215,78
|
||||||
|
Lincoln Town Car Ultimate L,0,0,0,0,0,0,1,50470,46208,4.6,8,239,17,25,4474,124,221,78
|
||||||
|
Mazda6 i,0,0,0,0,0,0,0,19270,17817,2.3,4,160,24,32,3042,105,187,70
|
||||||
|
Mazda MPV ES,0,0,0,1,0,0,0,28750,26600,3.0,6,200,18,25,3812,112,188,72
|
||||||
|
Mazda MX-5 Miata,1,0,0,0,0,0,1,22388,20701,1.8,4,142,23,28,2387,89,156,66
|
||||||
|
Mazda MX-5 Miata LS,1,0,0,0,0,0,1,25193,23285,1.8,4,142,23,28,2387,89,156,66
|
||||||
|
Mazda Tribute DX 2.0,0,1,0,0,0,1,0,21087,19742,2.0,4,130,22,25,3091,103,173,72
|
||||||
|
Mercedes-Benz C32 AMG,0,0,0,0,0,0,1,52120,48522,3.2,6,349,16,21,3540,107,178,68
|
||||||
|
Mercedes-Benz C230 Sport,0,0,0,0,0,0,1,26060,24249,1.8,4,189,22,30,3250,107,178,68
|
||||||
|
Mercedes-Benz C240,0,0,1,0,0,0,1,33780,31466,2.6,6,168,19,25,3470,107,179,68
|
||||||
|
Mercedes-Benz C240 RWD,0,0,0,0,0,0,1,32280,30071,2.6,6,168,20,25,3360,107,178,68
|
||||||
|
Mercedes-Benz C240 AWD,0,0,0,0,0,1,0,33480,31187,2.6,6,168,19,25,3360,107,178,68
|
||||||
|
Mercedes-Benz C320,0,0,0,0,0,0,1,37630,35046,3.2,6,215,20,26,3450,107,178,68
|
||||||
|
Mercedes-Benz C320 Sport two-door,0,0,0,0,0,0,1,28370,26435,3.2,6,215,19,26,3430,107,178,68
|
||||||
|
Mercedes-Benz C320 Sport four-door,0,0,0,0,0,0,1,35920,33456,3.2,6,215,19,26,3430,107,178,68
|
||||||
|
Mercedes-Benz CL500,0,0,0,0,0,0,1,94820,88324,5.0,8,302,16,24,4085,114,196,73
|
||||||
|
Mercedes-Benz CL600,0,0,0,0,0,0,1,128420,119600,5.5,12,493,13,19,4473,114,196,73
|
||||||
|
Mercedes-Benz CLK320,0,0,0,0,0,0,1,45707,41966,3.2,6,215,20,26,3770,107,183,69
|
||||||
|
Mercedes-Benz CLK500,0,0,0,0,0,0,1,52800,49104,5.0,8,302,17,22,3585,107,183,69
|
||||||
|
Mercedes-Benz E320,0,0,1,0,0,0,1,50670,47174,3.2,6,221,19,27,3966,112,190,71
|
||||||
|
Mercedes-Benz E320 four-door,0,0,0,0,0,0,1,48170,44849,3.2,6,221,19,27,3635,112,190,71
|
||||||
|
Mercedes-Benz E500,0,0,1,0,0,1,0,60670,56474,5.0,8,302,16,24,4230,112,190,71
|
||||||
|
Mercedes-Benz E500 four-door,0,0,0,0,0,0,1,57270,53382,5.0,8,302,16,20,3815,112,190,71
|
||||||
|
Mercedes-Benz G500,0,1,0,0,0,1,0,76870,71540,5.0,8,292,13,14,5423,112,186,71
|
||||||
|
Mercedes-Benz ML500,0,1,0,0,0,1,0,46470,43268,5.0,8,288,14,17,4874,111,183,72
|
||||||
|
Mercedes-Benz S430,0,0,0,0,0,0,1,74320,69168,4.3,8,275,18,26,4160,122,203,73
|
||||||
|
Mercedes-Benz S500,0,0,0,0,0,1,0,86970,80939,5.0,8,302,16,24,4390,122,203,73
|
||||||
|
Mercedes-Benz SL500,1,0,0,0,0,0,1,90520,84325,5.0,8,302,16,23,4065,101,179,72
|
||||||
|
Mercedes-Benz SL55 AMG,1,0,0,0,0,0,1,121770,113388,5.5,8,493,14,21,4235,101,179,72
|
||||||
|
Mercedes-Benz SL600,1,0,0,0,0,0,1,126670,117854,5.5,12,493,13,19,4429,101,179,72
|
||||||
|
Mercedes-Benz SLK230,1,0,0,0,0,0,1,40320,37548,2.3,4,192,21,29,3055,95,158,68
|
||||||
|
Mercedes-Benz SLK32 AMG,1,0,0,0,0,0,1,56170,52289,3.2,6,349,17,22,3220,95,158,68
|
||||||
|
Mercury Grand Marquis GS,0,0,0,0,0,0,1,24695,23217,4.6,8,224,17,25,4052,115,212,78
|
||||||
|
Mercury Grand Marquis LS Premium,0,0,0,0,0,0,1,29595,27148,4.6,8,224,17,25,4052,115,212,78
|
||||||
|
Mercury Grand Marquis LS Ultimate,0,0,0,0,0,0,1,30895,28318,4.6,8,224,17,25,4052,115,212,78
|
||||||
|
Mercury Marauder,0,0,0,0,0,0,1,34495,31558,4.6,8,302,17,23,4195,115,212,78
|
||||||
|
Mercury Monterey Luxury,0,0,0,1,0,0,0,33995,30846,4.2,6,201,16,23,4340,121,202,77
|
||||||
|
Mercury Mountaineer,0,1,0,0,0,0,0,29995,27317,4.0,6,210,16,21,4374,114,190,72
|
||||||
|
Mercury Sable GS,0,0,1,0,0,0,0,22595,20748,3.0,6,155,19,26,3488,109,198,73
|
||||||
|
Mercury Sable GS four-door,0,0,0,0,0,0,0,21595,19848,3.0,6,155,20,27,3308,109,200,73
|
||||||
|
Mercury Sable LS Premium,0,0,0,0,0,0,0,23895,21918,3.0,6,201,19,26,3315,109,200,73
|
||||||
|
Mini Cooper,0,0,0,0,0,0,0,16999,15437,1.6,4,115,28,37,2524,97,143,67
|
||||||
|
Mini Cooper S,0,0,0,0,0,0,0,19999,18137,1.6,4,163,25,34,2678,97,144,67
|
||||||
|
Mitsubishi Diamante LS,0,0,0,0,0,0,0,29282,27250,3.5,6,205,18,25,3549,107,194,70
|
||||||
|
Mitsubishi Eclipse GTS,1,0,0,0,0,0,0,25092,23456,3.0,6,210,21,28,3241,101,177,69
|
||||||
|
Mitsubishi Eclipse Spyder GT,1,0,0,0,0,0,0,26992,25218,3.0,6,210,21,28,3296,101,177,69
|
||||||
|
Mitsubishi Endeavor,0,1,0,0,0,1,0,30492,28330,3.8,6,215,17,21,4134,109,190,74
|
||||||
|
Mitsubishi Galant,0,0,0,0,0,0,0,25700,23883,3.8,6,230,18,26,3649,108,191,72
|
||||||
|
Mitsubishi Lancer Evolution,1,0,0,0,0,0,0,29562,27466,2.0,4,271,18,26,3263,103,179,70
|
||||||
|
Mitsubishi Montero,0,1,0,0,0,1,0,33112,30763,3.8,6,215,15,19,4718,110,190,75
|
||||||
|
Mitsubishi Outlander,0,1,0,0,0,0,0,18892,17569,2.4,4,160,21,27,3240,103,179,69
|
||||||
|
Nissan 350Z,1,0,0,0,0,0,1,26910,25203,3.5,6,287,20,26,3188,104,169,72
|
||||||
|
Nissan 350Z Enthusiast,1,0,0,0,0,0,1,34390,31845,3.5,6,287,20,26,3428,104,169,72
|
||||||
|
Nissan Altima S,0,0,0,0,0,0,0,19240,18030,2.5,4,175,21,26,3039,110,192,70
|
||||||
|
Nissan Altima SE,0,0,0,0,0,0,0,23290,21580,3.5,6,245,21,26,3197,110,192,70
|
||||||
|
Nissan Maxima SE,0,0,0,0,0,0,0,27490,25182,3.5,6,265,20,28,3473,111,194,72
|
||||||
|
Nissan Maxima SL,0,0,0,0,0,0,0,29440,26966,3.5,6,265,20,28,3476,111,194,72
|
||||||
|
Nissan Murano,0,0,1,0,0,0,1,28739,27300,3.5,6,245,20,25,3801,111,188,74
|
||||||
|
Nissan Pathfinder SE,0,1,0,0,0,0,0,27339,25972,3.5,6,240,16,21,3871,106,183,72
|
||||||
|
Nissan Pathfinder Armada SE,0,1,0,0,0,0,0,33840,30815,5.6,8,305,13,19,5013,123,207,79
|
||||||
|
Nissan Quest S,0,0,0,1,0,0,0,24780,22958,3.5,6,240,19,26,4012,124,204,78
|
||||||
|
Nissan Quest SE,0,0,0,1,0,0,0,32780,30019,3.5,6,240,18,25,4175,124,204,78
|
||||||
|
Nissan Sentra 1.8,0,0,0,0,0,0,0,12740,12205,1.8,4,126,28,35,2513,100,178,67
|
||||||
|
Nissan Sentra 1.8 S,0,0,0,0,0,0,0,14740,13747,1.8,4,126,28,35,2581,100,178,67
|
||||||
|
Nissan Sentra SE-R,0,0,0,0,0,0,0,17640,16444,2.5,4,165,23,28,2761,100,178,67
|
||||||
|
Nissan Xterra XE,0,1,0,0,0,0,0,20939,19512,3.3,6,180,17,20,3760,104,178,70
|
||||||
|
Oldsmobile Alero GLS,0,0,0,0,0,0,0,23675,21485,3.4,6,170,20,29,3085,107,187,70
|
||||||
|
Oldsmobile Alero GX,0,0,0,0,0,0,0,18825,17642,2.2,4,140,24,32,2946,107,187,70
|
||||||
|
Oldsmobile Silhouette GL,0,0,0,1,0,0,0,28790,26120,3.4,6,185,19,26,3948,120,201,72
|
||||||
|
Pontiac Aztekt,0,1,0,0,0,0,0,21595,19810,3.4,6,185,19,26,3779,108,182,74
|
||||||
|
Porsche Cayenne S,0,1,0,0,0,1,0,56665,49865,4.5,8,340,14,18,4950,112,188,76
|
||||||
|
Pontiac Grand Am GT,0,0,0,0,0,0,0,22450,20595,3.4,6,175,20,29,3118,107,186,70
|
||||||
|
Pontiac Grand Prix GT1,0,0,0,0,0,0,0,22395,20545,3.8,6,200,20,30,3477,111,198,74
|
||||||
|
Pontiac Grand Prix GT2,0,0,0,0,0,0,0,24295,22284,3.8,6,200,20,30,3484,111,198,74
|
||||||
|
Pontiac Montana,0,0,0,1,0,0,0,23845,21644,3.4,6,185,19,26,3803,112,187,72
|
||||||
|
Pontiac Montana EWB,0,0,0,1,0,1,0,31370,28454,3.4,6,185,18,24,4431,121,201,72
|
||||||
|
Pontiac Sunfire 1SA,0,0,0,0,0,0,0,15495,14375,2.2,4,140,24,33,2771,104,182,68
|
||||||
|
Pontiac Sunfire 1SC,0,0,0,0,0,0,0,17735,16369,2.2,4,140,24,33,2771,104,182,68
|
||||||
|
Pontiac Vibe,0,0,1,0,0,0,1,17045,15973,1.8,4,130,29,36,2701,102,172,70
|
||||||
|
Porsche 911 Carrera,1,0,0,0,0,0,1,79165,69229,3.6,6,315,18,26,3135,93,175,70
|
||||||
|
Porsche 911 Carrera 4S,1,0,0,0,0,1,0,84165,72206,3.6,6,315,17,24,3240,93,175,72
|
||||||
|
Porsche 911 Targa,1,0,0,0,0,0,1,76765,67128,3.6,6,315,18,26,3119,93,175,70
|
||||||
|
Porsche 911 GT2,1,0,0,0,0,0,1,192465,173560,3.6,6,477,17,24,3131,93,175,72
|
||||||
|
Porsche Boxster,1,0,0,0,0,0,1,43365,37886,2.7,6,228,20,29,2811,95,170,70
|
||||||
|
Porsche Boxster S,1,0,0,0,0,0,1,52365,45766,3.2,6,258,18,26,2911,95,170,70
|
||||||
|
Saab 9-3 Arc,0,0,0,0,0,0,0,40670,38520,2.0,4,210,21,29,3480,105,182,69
|
||||||
|
Saab 9-3 Arc Sport,0,0,0,0,0,0,0,30860,29269,2.0,4,210,20,28,3175,105,183,69
|
||||||
|
Saab 9-3 Aero,0,0,0,0,0,0,0,33360,31562,2.0,4,210,20,28,3175,105,183,69
|
||||||
|
Saab 9-3 Aero convertible,0,0,0,0,0,0,0,43175,40883,2.0,4,210,21,30,3700,105,182,69
|
||||||
|
Saab 9-5 Arc,0,0,0,0,0,0,0,35105,33011,2.3,4,220,21,29,3470,106,190,71
|
||||||
|
Saab 9-5 Aero,0,0,1,0,0,0,0,40845,38376,2.3,4,250,19,29,3620,106,190,71
|
||||||
|
Saab 9-5 Aero four-door,0,0,0,0,0,0,0,39465,37721,2.3,4,250,21,29,3470,106,190,71
|
||||||
|
Saturn Ion1,0,0,0,0,0,0,0,10995,10319,2.2,4,140,26,35,2692,103,185,67
|
||||||
|
Saturn Ion2, 0,0,0,0,0,0,0,14300,13393,2.2,4,140,26,35,2692,103,185,67
|
||||||
|
Saturn Ion2 quad coupe,0,0,0,0,0,0,0,14850,13904,2.2,4,140,26,35,2751,103,185,68
|
||||||
|
Saturn Ion3, 0,0,0,0,0,0,0,15825,14811,2.2,4,140,26,35,2692,103,185,67
|
||||||
|
Saturn Ion3 quad coupe,0,0,0,0,0,0,0,16350,15299,2.2,4,140,26,35,2751,103,185,68
|
||||||
|
Saturn L300, 0,0,0,1,0,0,0,23560,21779,2.2,4,140,24,34,3109,107,190,69
|
||||||
|
Saturn L300-2,0,0,0,0,0,0,0,21410,19801,3.0,6,182,20,28,3197,107,190,69
|
||||||
|
Saturn VUE,0,1,0,0,0,1,0,20585,19238,2.2,4,143,21,26,3381,107,181,72
|
||||||
|
Scion xA,0,0,0,0,0,0,0,12965,12340,1.5,4,108,32,38,2340,93,154,67
|
||||||
|
Scion xB,0,0,1,0,0,0,0,14165,13480,1.5,4,108,31,35,2425,98,155,67
|
||||||
|
Subaru Forester,0,0,1,0,0,1,0,21445,19646,2.5,4,165,21,28,3090,99,175,68
|
||||||
|
Subaru Impreza 2.5 RS,0,0,0,0,0,1,0,19945,18399,2.5,4,165,22,28,2965,99,174,69
|
||||||
|
Subaru Impreza WRX,1,0,0,0,0,1,0,25045,23022,2.0,4,227,20,27,3085,99,174,69
|
||||||
|
Subaru Impreza WRX STi,1,0,0,0,0,1,0,31545,29130,2.5,4,300,18,24,3263,100,174,69
|
||||||
|
Subaru Legacy GT,0,0,0,0,0,1,0,25645,23336,2.5,4,165,21,28,3395,104,184,69
|
||||||
|
Subaru Legacy L,0,0,0,0,0,1,0,20445,18713,2.5,4,165,21,28,3285,104,184,69
|
||||||
|
Subaru Outback,0,0,1,0,0,1,0,23895,21773,2.5,4,165,21,28,3430,104,187,69
|
||||||
|
Subaru Outback Limited Sedan,0,0,0,0,0,1,0,27145,24687,2.5,4,165,20,27,3495,104,184,69
|
||||||
|
Subaru Outback H6,0,0,0,0,0,1,0,29345,26660,3.0,6,212,19,26,3610,104,184,69
|
||||||
|
Subaru Outback H-6 VDC,0,0,0,0,0,1,0,31545,28603,3.0,6,212,19,26,3630,104,184,69
|
||||||
|
Suzuki Aeno S,0,0,0,0,0,0,0,12884,12719,2.3,4,155,25,31,2676,98,171,68
|
||||||
|
Suzuki Aerio LX,0,0,0,0,0,0,0,14500,14317,2.3,4,155,25,31,2676,98,171,68
|
||||||
|
Suzuki Aerio SX,0,0,1,0,0,1,0,16497,16291,2.3,4,155,24,29,2932,98,167,68
|
||||||
|
Suzuki Forenza S,0,0,0,0,0,0,0,12269,12116,2.0,4,119,24,31,2701,102,177,68
|
||||||
|
Suzuki Forenza EX,0,0,0,0,0,0,0,15568,15378,2.0,4,119,22,30,2756,102,177,68
|
||||||
|
Suzuki Verona LX,0,0,0,0,0,0,0,17262,17053,2.5,6,155,20,27,3380,106,188,72
|
||||||
|
Suzuki Vitara LX,0,1,0,0,0,1,0,17163,16949,2.5,6,165,19,22,3020,98,163,67
|
||||||
|
Suzuki XL-7 EX,0,1,0,0,0,0,0,23699,22307,2.7,6,185,18,22,3682,110,187,70
|
||||||
|
Toyota 4Runner SR5 V6,0,1,0,0,0,0,0,27710,24801,4.0,6,245,18,21,4035,110,189,74
|
||||||
|
Toyota Avalon XL,0,0,0,0,0,0,0,26560,23693,3.0,6,210,21,29,3417,107,192,72
|
||||||
|
Toyota Avalon XLS,0,0,0,0,0,0,0,30920,27271,3.0,6,210,21,29,3439,107,192,72
|
||||||
|
Toyota Camry LE,0,0,0,0,0,0,0,19560,17558,2.4,4,157,24,33,3086,107,189,71
|
||||||
|
Toyota Camry LE V6,0,0,0,0,0,0,0,22775,20325,3.0,6,210,21,29,3296,107,189,71
|
||||||
|
Toyota Camry XLE V6,0,0,0,0,0,0,0,25920,23125,3.0,6,210,21,29,3362,107,189,71
|
||||||
|
Toyota Camry Solara SE,0,0,0,0,0,0,0,19635,17722,2.4,4,157,24,33,3175,107,193,72
|
||||||
|
Toyota Camry Solara SE V6,0,0,0,0,0,0,0,21965,19819,3.3,6,225,20,29,3417,107,193,72
|
||||||
|
Toyota Camry Solara SLE V6 two-door,0,0,0,0,0,0,0,26510,23908,3.3,6,225,20,29,3439,107,193,72
|
||||||
|
Toyota Celica,1,0,0,0,0,0,0,22570,20363,1.8,4,180,24,33,2500,102,171,68
|
||||||
|
Toyota Corolla CE,0,0,0,0,0,0,0,14085,13065,1.8,4,130,32,40,2502,102,178,67
|
||||||
|
Toyota Corolla S,0,0,0,0,0,0,0,15030,13650,1.8,4,130,32,40,2524,102,178,67
|
||||||
|
Toyota Corolla LE,0,0,0,0,0,0,0,15295,13889,1.8,4,130,32,40,2524,102,178,67
|
||||||
|
Toyota Echo two-door manual,0,0,0,0,0,0,0,10760,10144,1.5,4,108,35,43,2035,93,163,65
|
||||||
|
Toyota Echo two-door auto,0,0,0,0,0,0,0,11560,10896,1.5,4,108,33,39,2085,93,163,65
|
||||||
|
Toyota Echo four-door,0,0,0,0,0,0,0,11290,10642,1.5,4,108,35,43,2055,93,163,65
|
||||||
|
Toyota Highlander V6,0,1,0,0,0,1,0,27930,24915,3.3,6,230,18,24,3935,107,185,72
|
||||||
|
Toyota Land Cruiser,0,1,0,0,0,1,0,54765,47986,4.7,8,325,13,17,5390,112,193,76
|
||||||
|
Toyota Matrix,0,0,1,0,0,0,0,16695,15156,1.8,4,130,29,36,2679,102,171,70
|
||||||
|
Toyota MR2 Spyder,1,0,0,0,0,0,1,25130,22787,1.8,4,138,26,32,2195,97,153,67
|
||||||
|
Toyota Prius,0,0,0,0,0,0,0,20510,18926,1.5,4,110,59,51,2890,106,175,68
|
||||||
|
Toyota RAV4,0,1,0,0,0,1,0,20290,18553,2.4,4,161,22,27,3119,98,167,68
|
||||||
|
Toyota Sequoia SR5,0,1,0,0,0,1,0,35695,31827,4.7,8,240,14,17,5270,118,204,78
|
||||||
|
Toyota Sienna CE,0,0,0,1,0,0,0,23495,21198,3.3,6,230,19,27,4120,119,200,77
|
||||||
|
Toyota Sienna XLE,0,0,0,1,0,0,0,28800,25690,3.3,6,230,19,27,4165,119,200,77
|
||||||
|
Volkswagen Golf,0,0,0,0,0,0,0,18715,17478,2.0,4,115,24,31,2897,99,165,68
|
||||||
|
Volkswagen GTI,0,0,0,0,0,0,0,19825,18109,1.8,4,180,24,31,2934,99,168,68
|
||||||
|
Volkswagen Jetta GL,0,0,1,0,0,0,0,19005,17427,2.0,4,115,24,30,3034,99,174,68
|
||||||
|
Volkswagen Jetta GLI,0,0,0,0,0,0,0,23785,21686,2.8,6,200,21,30,3179,99,172,68
|
||||||
|
Volkswagen Jetta GLS,0,0,0,0,0,0,0,21055,19638,1.9,4,100,38,46,3003,99,172,68
|
||||||
|
Volkswagen New Beetle GLS 1.8T,0,0,0,0,0,0,0,21055,19638,1.8,4,150,24,31,2820,99,161,68
|
||||||
|
Volkswagen New Beetle GLS convertible,0,0,0,0,0,0,0,23215,21689,2.0,4,115,24,30,3082,99,161,68
|
||||||
|
Volkswagen Passat GLS,0,0,1,0,0,0,0,24955,22801,1.8,4,170,22,31,3338,106,184,69
|
||||||
|
Volkswagen Passat GLS four-door,0,0,0,0,0,0,0,23955,21898,1.8,4,170,22,31,3241,106,185,69
|
||||||
|
Volkswagen Passat GLX V6 4MOTION four-door,0,0,0,0,0,0,0,33180,30583,2.8,6,190,19,26,3721,106,185,69
|
||||||
|
Volkswagen Passat W8,0,0,1,0,0,0,0,40235,36956,4.0,8,270,18,25,4067,106,184,69
|
||||||
|
Volkswagen Passat W8 4MOTION,0,0,0,0,0,0,0,39235,36052,4.0,8,270,18,25,3953,106,185,69
|
||||||
|
Volkswagen Touareg V6,0,1,0,0,0,1,0,35515,32243,3.2,6,220,15,20,5086,112,187,76
|
||||||
|
Volvo C70 LPT,0,0,0,0,0,0,0,40565,38203,2.4,5,197,21,28,3450,105,186,72
|
||||||
|
Volvo C70 HPT,0,0,0,0,0,0,0,42565,40083,2.3,5,242,20,26,3450,105,186,72
|
||||||
|
Volvo S40,0,0,0,0,0,0,0,25135,23701,1.9,4,170,22,29,2767,101,178,68
|
||||||
|
Volvo S60 2.5,0,0,0,0,0,1,0,31745,29916,2.5,5,208,20,27,3903,107,180,71
|
||||||
|
Volvo S60 T5,0,0,0,0,0,0,0,34845,32902,2.3,5,247,20,28,3766,107,180,71
|
||||||
|
Volvo S60 R,0,0,0,0,0,1,0,37560,35382,2.5,5,300,18,25,3571,107,181,71
|
||||||
|
Volvo S80 2.5T,0,0,0,0,0,1,0,37885,35688,2.5,5,194,20,27,3691,110,190,72
|
||||||
|
Volvo S80 2.9,0,0,0,0,0,0,0,37730,35542,2.9,6,208,20,28,3576,110,190,72
|
||||||
|
Volvo S80 T6,0,0,0,0,0,0,0,45210,42573,2.9,6,268,19,26,3653,110,190,72
|
||||||
|
Volvo V40,0,0,1,0,0,0,0,26135,24641,1.9,4,170,22,29,2822,101,180,68
|
||||||
|
Volvo XC70,0,0,1,0,0,1,0,35145,33112,2.5,5,208,20,27,3823,109,186,73
|
||||||
|
Volvo XC90 T6,0,1,0,0,0,1,0,41250,38851,2.9,6,268,15,20,4638,113,189,75
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -0,0 +1,236 @@
|
|||||||
|
###########################################
|
||||||
|
# Suppress matplotlib user warnings
|
||||||
|
# Necessary for newer version of matplotlib
|
||||||
|
import warnings
|
||||||
|
warnings.filterwarnings("ignore", category = UserWarning, module = "matplotlib")
|
||||||
|
#
|
||||||
|
# Display inline matplotlib plots with IPython
|
||||||
|
from IPython import get_ipython
|
||||||
|
get_ipython().run_line_magic('matplotlib', 'inline')
|
||||||
|
###########################################
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
from sklearn.decomposition import PCA
|
||||||
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
from sklearn.ensemble import RandomForestClassifier
|
||||||
|
from sklearn.model_selection import train_test_split
|
||||||
|
from sklearn.metrics import confusion_matrix, accuracy_score
|
||||||
|
|
||||||
|
import matplotlib.image as mpimg
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import matplotlib.cm as cm
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
train = pd.read_csv('./data/train.csv')
|
||||||
|
|
||||||
|
# save the labels to a Pandas series target
|
||||||
|
y = train['label']
|
||||||
|
|
||||||
|
# Drop the label feature
|
||||||
|
X = train.drop("label",axis=1)
|
||||||
|
|
||||||
|
def show_images(num_images):
|
||||||
|
'''
|
||||||
|
This function plots the num_images provided of MNIST dataset.
|
||||||
|
|
||||||
|
INPUT: int - The number of images you would like to view.
|
||||||
|
Mod 10 of num_images should be 0 and it should be fewer than 101 images.
|
||||||
|
OUTPUT: A figure with the images shown for the training data.
|
||||||
|
'''
|
||||||
|
if num_images % 10 == 0 and num_images <= 100:
|
||||||
|
for digit_num in range(0,num_images):
|
||||||
|
plt.subplot(num_images/10,10,digit_num+1) #create subplots
|
||||||
|
mat_data = X.iloc[digit_num].as_matrix().reshape(28,28) #reshape images
|
||||||
|
plt.imshow(mat_data) #plot the data
|
||||||
|
plt.xticks([]) #removes numbered labels on x-axis
|
||||||
|
plt.yticks([]) #removes numbered labels on y-axis
|
||||||
|
else:
|
||||||
|
print('That is not the right input, please read the docstring before continuing.')
|
||||||
|
|
||||||
|
|
||||||
|
def show_images_by_digit(digit_to_see):
|
||||||
|
'''
|
||||||
|
This function plots 50 images all of the type digits_to_see of the MNIST dataset.
|
||||||
|
|
||||||
|
INPUT: digits_to_see - int - A number between 0 and 9 of what you want to see.
|
||||||
|
OUTPUT: A figure with the images shown for the training data.
|
||||||
|
'''
|
||||||
|
if digit_to_see in list(range(10)):
|
||||||
|
indices = np.where(y == digit_to_see) # pull indices for num of interest
|
||||||
|
for digit_num in range(0,50):
|
||||||
|
plt.subplot(5,10, digit_num+1) #create subplots
|
||||||
|
mat_data = X.iloc[indices[0][digit_num]].as_matrix().reshape(28,28) #reshape images
|
||||||
|
plt.imshow(mat_data) #plot the data
|
||||||
|
plt.xticks([]) #removes numbered labels on x-axis
|
||||||
|
plt.yticks([]) #removes numbered labels on y-axis
|
||||||
|
else:
|
||||||
|
print('That is not the right input, please read the docstring before continuing.')
|
||||||
|
|
||||||
|
|
||||||
|
def fit_random_forest_classifier(X, y):
|
||||||
|
'''
|
||||||
|
INPUT: names are pretty self explanatory
|
||||||
|
OUTPUT: none - prints the confusion matrix and accuracy
|
||||||
|
'''
|
||||||
|
#First let's create training and testing data
|
||||||
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
|
||||||
|
|
||||||
|
#We could grid search and tune, but let's just fit a simple model to see how it does
|
||||||
|
#instantiate
|
||||||
|
clf = RandomForestClassifier(n_estimators=100, max_depth=None)
|
||||||
|
|
||||||
|
#fit
|
||||||
|
clf.fit(X_train, y_train)
|
||||||
|
|
||||||
|
#predict
|
||||||
|
y_preds = clf.predict(X_test)
|
||||||
|
|
||||||
|
#score
|
||||||
|
print(confusion_matrix(y_test, y_preds))
|
||||||
|
acc = accuracy_score(y_test, y_preds)
|
||||||
|
print(acc)
|
||||||
|
return acc
|
||||||
|
|
||||||
|
|
||||||
|
def fit_random_forest_classifier2(X, y):
|
||||||
|
'''
|
||||||
|
INPUT: X - the x-matrix of input features
|
||||||
|
y - the response column
|
||||||
|
OUTPUT: none - prints the confusion matrix and accuracy
|
||||||
|
'''
|
||||||
|
#First let's create training and testing data
|
||||||
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
|
||||||
|
|
||||||
|
#We could grid search and tune, but let's just fit a simple model to see how it does
|
||||||
|
#instantiate
|
||||||
|
clf = RandomForestClassifier(n_estimators=100, max_depth=None)
|
||||||
|
|
||||||
|
#fit
|
||||||
|
clf.fit(X_train, y_train)
|
||||||
|
|
||||||
|
#predict
|
||||||
|
y_preds = clf.predict(X_test)
|
||||||
|
|
||||||
|
#score
|
||||||
|
acc = accuracy_score(y_test, y_preds)
|
||||||
|
return acc
|
||||||
|
|
||||||
|
|
||||||
|
def do_pca(n_components, data):
|
||||||
|
'''
|
||||||
|
Transforms data using PCA to create n_components, and provides back the results of the
|
||||||
|
transformation.
|
||||||
|
|
||||||
|
INPUT: n_components - int - the number of principal components to create
|
||||||
|
data - the data you would like to transform
|
||||||
|
|
||||||
|
OUTPUT: pca - the pca object created after fitting the data
|
||||||
|
X_pca - the transformed X matrix with new number of components
|
||||||
|
'''
|
||||||
|
X = StandardScaler().fit_transform(data)
|
||||||
|
pca = PCA(n_components)
|
||||||
|
X_pca = pca.fit_transform(X)
|
||||||
|
return pca, X_pca
|
||||||
|
|
||||||
|
|
||||||
|
def plot_components(X, y):
|
||||||
|
'''
|
||||||
|
plots the data in a 2 dimensional space to view separation
|
||||||
|
INPUT: X - the x-matrix of input features
|
||||||
|
y - the response column
|
||||||
|
OUTPUT: none
|
||||||
|
'''
|
||||||
|
x_min, x_max = np.min(X, 0), np.max(X, 0)
|
||||||
|
X = (X - x_min) / (x_max - x_min)
|
||||||
|
plt.figure(figsize=(10, 6))
|
||||||
|
for i in range(X.shape[0]):
|
||||||
|
plt.text(X[i, 0], X[i, 1], str(y[i]), color=plt.cm.Set1(y[i]), fontdict={'size': 15})
|
||||||
|
|
||||||
|
plt.xticks([]), plt.yticks([]), plt.ylim([-0.1,1.1]), plt.xlim([-0.1,1.1])
|
||||||
|
|
||||||
|
|
||||||
|
def scree_plot(pca):
|
||||||
|
'''
|
||||||
|
Creates a scree plot associated with the principal components
|
||||||
|
|
||||||
|
INPUT: pca - the result of instantian of PCA in scikit learn
|
||||||
|
|
||||||
|
OUTPUT:
|
||||||
|
None
|
||||||
|
'''
|
||||||
|
num_components=len(pca.explained_variance_ratio_)
|
||||||
|
ind = np.arange(num_components)
|
||||||
|
vals = pca.explained_variance_ratio_
|
||||||
|
|
||||||
|
plt.figure(figsize=(10, 6))
|
||||||
|
ax = plt.subplot(111)
|
||||||
|
cumvals = np.cumsum(vals)
|
||||||
|
ax.bar(ind, vals)
|
||||||
|
ax.plot(ind, cumvals)
|
||||||
|
for i in range(num_components):
|
||||||
|
ax.annotate(r"%s%%" % ((str(vals[i]*100)[:4])), (ind[i]+0.2, vals[i]), va="bottom", ha="center", fontsize=12)
|
||||||
|
|
||||||
|
ax.xaxis.set_tick_params(width=0)
|
||||||
|
ax.yaxis.set_tick_params(width=2, length=12)
|
||||||
|
|
||||||
|
ax.set_xlabel("Principal Component")
|
||||||
|
ax.set_ylabel("Variance Explained (%)")
|
||||||
|
plt.title('Explained Variance Per Principal Component')
|
||||||
|
|
||||||
|
|
||||||
|
def plot_component(pca, comp):
|
||||||
|
'''
|
||||||
|
Plots an image associated with each component to understand how the weighting
|
||||||
|
of the components
|
||||||
|
INPUT:
|
||||||
|
pca - pca object created from PCA in sklearn
|
||||||
|
comp - int - the component you want to see starting at 0
|
||||||
|
OUTPUT
|
||||||
|
None
|
||||||
|
'''
|
||||||
|
if comp <= len(pca.components_):
|
||||||
|
mat_data = np.asmatrix(pca.components_[comp]).reshape(28,28) #reshape images
|
||||||
|
plt.imshow(mat_data); #plot the data
|
||||||
|
plt.xticks([]) #removes numbered labels on x-axis
|
||||||
|
plt.yticks([]) #removes numbered labels on y-axis
|
||||||
|
else:
|
||||||
|
print('That is not the right input, please read the docstring before continuing.')
|
||||||
|
|
||||||
|
|
||||||
|
def pca_results(full_dataset, pca):
|
||||||
|
'''
|
||||||
|
Create a DataFrame of the PCA results
|
||||||
|
Includes dimension feature weights and explained variance
|
||||||
|
Visualizes the PCA results
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Dimension indexing
|
||||||
|
dimensions = dimensions = ['Dimension {}'.format(i) for i in range(1,len(pca.components_)+1)]
|
||||||
|
|
||||||
|
# PCA components
|
||||||
|
components = pd.DataFrame(np.round(pca.components_, 4), columns = full_dataset.keys())
|
||||||
|
components.index = dimensions
|
||||||
|
|
||||||
|
# PCA explained variance
|
||||||
|
ratios = pca.explained_variance_ratio_.reshape(len(pca.components_), 1)
|
||||||
|
variance_ratios = pd.DataFrame(np.round(ratios, 4), columns = ['Explained Variance'])
|
||||||
|
variance_ratios.index = dimensions
|
||||||
|
|
||||||
|
# Create a bar plot visualization
|
||||||
|
fig, ax = plt.subplots(figsize = (14,8))
|
||||||
|
|
||||||
|
# Plot the feature weights as a function of the components
|
||||||
|
components.plot(ax = ax, kind = 'bar');
|
||||||
|
ax.set_ylabel("Feature Weights")
|
||||||
|
ax.set_xticklabels(dimensions, rotation=0)
|
||||||
|
|
||||||
|
|
||||||
|
# Display the explained variance ratios
|
||||||
|
for i, ev in enumerate(pca.explained_variance_ratio_):
|
||||||
|
ax.text(i-0.40, ax.get_ylim()[1] + 0.05, "Explained Variance\n %.4f"%(ev))
|
||||||
|
|
||||||
|
# Return a concatenated DataFrame
|
||||||
|
return pd.concat([variance_ratios, components], axis = 1)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
from sklearn.decomposition import PCA
|
||||||
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
from sklearn.ensemble import RandomForestClassifier
|
||||||
|
from sklearn.model_selection import train_test_split
|
||||||
|
from sklearn.metrics import confusion_matrix, accuracy_score
|
||||||
|
from helper_functions import show_images, show_images_by_digit
|
||||||
|
from helper_functions import fit_random_forest_classifier, do_pca, plot_components
|
||||||
|
|
||||||
|
import matplotlib.image as mpimg
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
train = pd.read_csv('./data/train.csv')
|
||||||
|
|
||||||
|
# save the labels to a Pandas series target
|
||||||
|
y = train['label']
|
||||||
|
|
||||||
|
# Drop the label feature
|
||||||
|
X = train.drop("label", axis=1)
|
||||||
|
|
||||||
|
def question_two_check(input1, input2):
|
||||||
|
match1 = (input1 == y)
|
||||||
|
match2 = (input2 == X)
|
||||||
|
if all(match1) and all(match2):
|
||||||
|
print("That looks right!")
|
||||||
|
else:
|
||||||
|
print("Oops! That doesn't look like what was expected for X and y. X should be a matrix of only the pixels, and y should only hold the label column.")
|
||||||
|
|
||||||
|
|
||||||
|
def question_3_check(solution_three):
|
||||||
|
a = True
|
||||||
|
b = False
|
||||||
|
c = 6.13
|
||||||
|
d = 'The total amount of variability in the data explained by the first two principal components'
|
||||||
|
e = None
|
||||||
|
my_sol = {
|
||||||
|
'10.42' : d,
|
||||||
|
'The first component will ALWAYS have the most amount of variability explained.': a,
|
||||||
|
'The total amount of variability in the data explained by the first component': c,
|
||||||
|
'The sum of the variability explained by all the components can be greater than 100%': b
|
||||||
|
}
|
||||||
|
|
||||||
|
if my_sol == solution_three:
|
||||||
|
print("Looks good! The amount of variability explained by each principal component gives us an idea of how much of the original variability in the original data is retained by each component. Nice job matching these up!")
|
||||||
|
|
||||||
|
if my_sol['10.42'] != solution_three['10.42']:
|
||||||
|
print("Oops! Looks like you missed the first one. Notice that 9.85 is the sum of the two bars shown in the plot. This means that the total amount of variability explained by the first two principal components is 9.85. 5.74% can be explained by the first component, and the rest is explained by the second component.\n\n")
|
||||||
|
if my_sol['The first component will ALWAYS have the most amount of variability explained.'] != solution_three['The first component will ALWAYS have the most amount of variability explained.']:
|
||||||
|
print("Oops! Looks like you missed the second one. It is actually the case that the first component will ALWAYS be the largest. This is because PCA tries to find the direction of maximum variance first. In fact, the components will always be in order from largest amount of variability explained first to smallest amount of variability explained as the last component.\n\n")
|
||||||
|
if my_sol['The total amount of variability in the data explained by the first component'] != solution_three['The total amount of variability in the data explained by the first component']:
|
||||||
|
print("Oops! Looks like you missed the third one. The amount of variability explained by each component is shown by the bars in the chart. The total amount of variability explained by the combined components up to each component is shown by the line. This gives us an idea of how much is explained so far, and how much each additional component is contributing.\n\n")
|
||||||
|
if my_sol['The sum of the variability explained by all the components can be greater than 100%'] != solution_three['The sum of the variability explained by all the components can be greater than 100%']:
|
||||||
|
print("Oops! The last answer doesn't look right. Your principal components are always reducing the original space of your features until you have as many principal components as you had original features. Therefore, the sum of the amount of variability explained by all the components can never exceep 100%")
|
||||||
|
|
||||||
|
|
||||||
|
def question_5_check(solution_five):
|
||||||
|
|
||||||
|
my_sol = {
|
||||||
|
'This component looks like it will assist in identifying zero': 0,
|
||||||
|
'This component looks like it will assist in identifying three': 3
|
||||||
|
}
|
||||||
|
|
||||||
|
if my_sol == solution_five:
|
||||||
|
print("Nice job! That matches our solution as well! The index of the first principal component appears to have really high weights where a zero would appear. Alternatively, the fourth (third indexed component) appears to downweight where a three would appear to make it stand out.")
|
||||||
|
else:
|
||||||
|
print("Oops! That doesn't look quite right. Please use the indices as numbers for the values, so the first component should be 0, the second component would be 1, and so on.")
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
from sklearn.decomposition import PCA
|
||||||
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
from sklearn.ensemble import RandomForestClassifier
|
||||||
|
from sklearn.model_selection import train_test_split
|
||||||
|
from sklearn.metrics import confusion_matrix, accuracy_score
|
||||||
|
from helper_functions import show_images, show_images_by_digit
|
||||||
|
from helper_functions import fit_random_forest_classifier, do_pca, plot_components
|
||||||
|
|
||||||
|
import matplotlib.image as mpimg
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
def display_gif(fn):
|
||||||
|
return '<img src="{}">'.format(fn)
|
||||||
|
|
||||||
|
|
||||||
|
def check_question_one(solution_1_dict):
|
||||||
|
a = 7
|
||||||
|
b = 66
|
||||||
|
c = 387
|
||||||
|
d = 18
|
||||||
|
e = 0.23
|
||||||
|
f = 0.05
|
||||||
|
|
||||||
|
my_sol = {
|
||||||
|
'The number of cars in the dataset': c,
|
||||||
|
'The number of car features in the dataset': d,
|
||||||
|
'The number of dummy variables in the dataset': a,
|
||||||
|
'The proportion of minivans in the dataset': f,
|
||||||
|
'The max highway mpg for any car': b
|
||||||
|
}
|
||||||
|
|
||||||
|
if my_sol == solution_1_dict:
|
||||||
|
print("Nice job! Looks like your dataset matches what we found!")
|
||||||
|
return display_gif('https://bit.ly/2K9X0gD')
|
||||||
|
|
||||||
|
if my_sol['The number of cars in the dataset'] != solution_1_dict['The number of cars in the dataset']:
|
||||||
|
print("Sorry, but it looks like you missed the first one. The number of cars in the dataset should match the number of rows in the dataset. Try again!\n\n")
|
||||||
|
|
||||||
|
if my_sol['The number of car features in the dataset'] != solution_1_dict['The number of car features in the dataset']:
|
||||||
|
print("Sorry, but it looks like you missed the second one. The number of car features in the dataset should match the number of columns in the dataset. Try again!\n\n")
|
||||||
|
if my_sol['The number of dummy variables in the dataset'] != solution_1_dict['The number of dummy variables in the dataset']:
|
||||||
|
print("Sorry, but it looks like you missed the third one. The dummy variables are columns with only 1 and 0 values in the dataset. Try again!")
|
||||||
|
if my_sol['The proportion of minivans in the dataset'] != solution_1_dict['The proportion of minivans in the dataset']:
|
||||||
|
print("Sorry, but it looks like you missed the fourth one. The proportion of minivans in the dataset can be found by using the describe method on your dataframe or directly on the minivans column of the dataset.")
|
||||||
|
if my_sol['The max highway mpg for any car'] != solution_1_dict['The max highway mpg for any car']:
|
||||||
|
print("Sorry, but it looks like you missed the last one. The max highway mpg in the dataset can be found by using the describe method on your dataframe or using the max function in numpy.")
|
||||||
|
|
||||||
|
if my_sol != solution_1_dict:
|
||||||
|
return display_gif('https://bit.ly/2Hog74V')
|
||||||
|
|
||||||
|
|
||||||
|
def check_question_two(solution_2_dict):
|
||||||
|
a = True
|
||||||
|
b = False
|
||||||
|
|
||||||
|
my_sol = {
|
||||||
|
'The components span the directions of maximum variability.': a,
|
||||||
|
'The components are always orthogonal to one another.': a,
|
||||||
|
'Eigenvalues tell us the amount of information a component holds': a
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
if my_sol == solution_2_dict:
|
||||||
|
print("That's right these are all true. Principal components are orthogonal, span the directions of maximum variability, and the corresponding eigenvalues tell us how much of the original variability is explained by each component.")
|
||||||
|
else:
|
||||||
|
print("Oops! That doesn't look quite right! One or more of the statements you marked False is actually True. Try again!")
|
||||||
|
|
||||||
|
except:
|
||||||
|
print("Oops! That doesn't look quite right! One or more of the statements you marked False is actually True. Try again!")
|
||||||
|
|
||||||
|
|
||||||
|
def check_question_five(solution_5_dict):
|
||||||
|
a = 'car weight'
|
||||||
|
b = 'sports cars'
|
||||||
|
c = 'gas mileage'
|
||||||
|
d = 0.4352
|
||||||
|
e = 0.3061
|
||||||
|
f = 0.1667
|
||||||
|
g = 0.7053
|
||||||
|
|
||||||
|
my_sol = {
|
||||||
|
'The first component positively weights items related to': c,
|
||||||
|
'The amount of variability explained by the first component is': d,
|
||||||
|
'The largest weight of the second component is related to': b,
|
||||||
|
'The total amount of variability explained by the first three components': g
|
||||||
|
}
|
||||||
|
|
||||||
|
if my_sol == solution_5_dict:
|
||||||
|
print("That's right! Looks like you know a lot about PCA!")
|
||||||
|
if my_sol['The first component positively weights items related to'] != solution_5_dict['The first component positively weights items related to']:
|
||||||
|
print("Oops! Looks like you missed the first question. Notice that there are two bars that are large, positive, while the rest are mostly negative. What are the two bars related to?\n\n")
|
||||||
|
|
||||||
|
if my_sol['The amount of variability explained by the first component is'] != solution_5_dict['The amount of variability explained by the first component is']:
|
||||||
|
print("Oops! Looks like you missed the second question. If you look in the table, you will see the variance explained in the first column. Then the principal component is provided as the weights that show up in each associated row.\n\n")
|
||||||
|
|
||||||
|
if my_sol['The largest weight of the second component is related to'] != solution_5_dict['The largest weight of the second component is related to']:
|
||||||
|
print("Oops! Looks like you missed the third question. If you look in the table, you will see the variance explained in the first column. Looking at the bar chart, you can see that the largest weight for the second component is the blue bar on the far left. This is the first column in the original set of features.\n\n")
|
||||||
|
|
||||||
|
if my_sol['The total amount of variability explained by the first three components'] != solution_5_dict['The total amount of variability explained by the first three components']:
|
||||||
|
print("Oops! Looks like you missed the last question. If you add all of the variability explained in the first column of the table, how much is explained by the first component?")
|
||||||
|
|
||||||
|
|
||||||
|
def question_check_six(num_comps):
|
||||||
|
if num_comps == 6:
|
||||||
|
print("Nice job! That's right! With 6 components, you can explain more than 85% of the variability in the original dataset.")
|
||||||
|
return display_gif('https://bit.ly/2cKTiso')
|
||||||
|
else:
|
||||||
|
print("Oops! That doesn't look quite right. Try again.")
|
||||||
|
return display_gif('https://bit.ly/2AC30ww')
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
110
python/Unsupervised Learning/Random Projection and ICA/ica.py
Normal file
110
python/Unsupervised Learning/Random Projection and ICA/ica.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import numpy as np
|
||||||
|
import wave
|
||||||
|
import warnings
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from sklearn.decomposition import FastICA
|
||||||
|
from scipy.io import wavfile
|
||||||
|
|
||||||
|
|
||||||
|
warnings.filterwarnings("ignore")
|
||||||
|
|
||||||
|
# Read the wave file
|
||||||
|
mix_1_wave = wave.open('ICA mix 1.wav', 'r')
|
||||||
|
|
||||||
|
mix_1_wave.getparams()
|
||||||
|
|
||||||
|
length = 264515 / 44100
|
||||||
|
|
||||||
|
# Extract Raw Audio from Wav File
|
||||||
|
signal_1_raw = mix_1_wave.readframes(-1)
|
||||||
|
signal_1 = np.fromstring(signal_1_raw, 'Int16')
|
||||||
|
|
||||||
|
print('length: ', len(signal_1), 'first 100 elements: ', signal_1[:100])
|
||||||
|
|
||||||
|
fs = mix_1_wave.getframerate()
|
||||||
|
timing = np.linspace(0, len(signal_1) / fs, num=len(signal_1))
|
||||||
|
|
||||||
|
|
||||||
|
plt.figure(figsize=(12, 2))
|
||||||
|
plt.title('Recording 1')
|
||||||
|
plt.plot(timing, signal_1, c="#3ABFE7")
|
||||||
|
plt.ylim(-35000, 35000)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
mix_2_wave = wave.open('ICA mix 2.wav', 'r')
|
||||||
|
|
||||||
|
# Extract Raw Audio from Wav File
|
||||||
|
signal_raw_2 = mix_2_wave.readframes(-1)
|
||||||
|
signal_2 = np.fromstring(signal_raw_2, 'Int16')
|
||||||
|
|
||||||
|
|
||||||
|
mix_3_wave = wave.open('ICA mix 3.wav', 'r')
|
||||||
|
|
||||||
|
# Extract Raw Audio from Wav File
|
||||||
|
signal_raw_3 = mix_3_wave.readframes(-1)
|
||||||
|
signal_3 = np.fromstring(signal_raw_3, 'Int16')
|
||||||
|
|
||||||
|
|
||||||
|
plt.figure(figsize=(12, 2))
|
||||||
|
plt.title('Recording 2')
|
||||||
|
plt.plot(timing, signal_2, c="#3ABFE7")
|
||||||
|
plt.ylim(-35000, 35000)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
plt.figure(figsize=(12, 2))
|
||||||
|
plt.title('Recording 3')
|
||||||
|
plt.plot(timing, signal_3, c="#3ABFE7")
|
||||||
|
plt.ylim(-35000, 35000)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
X = list(zip(signal_1, signal_2, signal_3))
|
||||||
|
|
||||||
|
# Let's peak at what X looks like
|
||||||
|
print(X[:10])
|
||||||
|
|
||||||
|
# TODO: Initialize FastICA with n_components=3
|
||||||
|
ica = FastICA(n_components=3)
|
||||||
|
|
||||||
|
# TODO: Run the FastICA algorithm using fit_transform on dataset X
|
||||||
|
ica_result = ica.fit_transform(X)
|
||||||
|
|
||||||
|
print(ica_result.shape)
|
||||||
|
|
||||||
|
result_signal_1 = ica_result[:, 0]
|
||||||
|
result_signal_2 = ica_result[:, 1]
|
||||||
|
result_signal_3 = ica_result[:, 2]
|
||||||
|
|
||||||
|
# Plot Independent Component #1
|
||||||
|
plt.figure(figsize=(12, 2))
|
||||||
|
plt.title('Independent Component #1')
|
||||||
|
plt.plot(result_signal_1, c="#df8efd")
|
||||||
|
plt.ylim(-0.010, 0.010)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
# Plot Independent Component #2
|
||||||
|
plt.figure(figsize=(12, 2))
|
||||||
|
plt.title('Independent Component #2')
|
||||||
|
plt.plot(result_signal_2, c="#87de72")
|
||||||
|
plt.ylim(-0.010, 0.010)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
# Plot Independent Component #3
|
||||||
|
plt.figure(figsize=(12, 2))
|
||||||
|
plt.title('Independent Component #3')
|
||||||
|
plt.plot(result_signal_3, c="#f65e97")
|
||||||
|
plt.ylim(-0.010, 0.010)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
# Convert to int, map the appropriate range, and increase the volume
|
||||||
|
result_signal_1_int = np.int16(result_signal_1 * 32767 * 100)
|
||||||
|
result_signal_2_int = np.int16(result_signal_2 * 32767 * 100)
|
||||||
|
result_signal_3_int = np.int16(result_signal_3 * 32767 * 100)
|
||||||
|
|
||||||
|
|
||||||
|
# Write wave files
|
||||||
|
wavfile.write("result_signal_1.wav", fs, result_signal_1_int)
|
||||||
|
wavfile.write("result_signal_2.wav", fs, result_signal_2_int)
|
||||||
|
wavfile.write("result_signal_3.wav", fs, result_signal_3_int)
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user