Skip to content

Commit

Permalink
remove unneeded files
Browse files Browse the repository at this point in the history
  • Loading branch information
ravill2 committed Nov 9, 2017
1 parent 9e1d06b commit 141b27e
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 665 deletions.
171 changes: 19 additions & 152 deletions week1/Exercise2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -85,35 +85,9 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" population householdsize racepctblack racePctWhite racePctAsian \\\n",
"9 103590 2.62 23.14 67.60 0.92 \n",
"13 57140 2.74 53.52 45.65 0.49 \n",
"17 180038 2.62 1.30 74.02 14.14 \n",
"19 261721 2.60 8.41 82.64 3.92 \n",
"21 7322564 2.60 28.71 52.26 7.00 \n",
"\n",
" racePctHisp agePct12t21 agePct12t29 agePct16t24 agePct65up \n",
"9 16.35 19.88 34.55 21.62 13.12 \n",
"13 0.43 16.51 28.17 14.68 13.38 \n",
"17 20.96 12.04 26.68 12.37 11.54 \n",
"19 8.91 14.18 32.78 15.14 4.58 \n",
"21 24.36 13.06 27.46 13.09 11.62 \n",
"9 26.88\n",
"13 27.26\n",
"17 5.02\n",
"19 2.39\n",
"21 26.59\n",
"Name: murdPerPop, dtype: float64\n"
]
}
],
"outputs": [],
"source": [
"def printDataSet():\n",
" (X_crime,y_crime) = get_crime_dataset()\n",
Expand All @@ -126,20 +100,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.59690236423467447, 0.67949819476183415)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"#perform linear regression\n",
"def ex1():\n",
Expand All @@ -161,20 +124,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.78061368287329047, -0.055156513114217542)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"#perform polynomial regression of degree 2\n",
"def ex1a():\n",
Expand All @@ -196,20 +148,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.7577837996817649, 0.42712193149261213)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# to avoid the problems of overfitting polynomial regression of higher degrees, we put a penalty on the\n",
"# coefficients that are large.\n",
Expand All @@ -236,20 +177,9 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.56772731184584013, 0.65054477060117732)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# when features vary wildly, e.g when calculating the price of the house: the square footage is in the thousands\n",
"# and number of bedrooms is in the single digits, it's best to normalize the data to values \n",
Expand Down Expand Up @@ -280,30 +210,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Alpha = 0.00\n",
"r-squared training: 1.00, r-squared test: -1485.23\n",
"Alpha = 1.00\n",
"r-squared training: 0.68, r-squared test: 0.65\n",
"Alpha = 10.00\n",
"r-squared training: 0.62, r-squared test: 0.67\n",
"Alpha = 20.00\n",
"r-squared training: 0.60, r-squared test: 0.67\n",
"Alpha = 50.00\n",
"r-squared training: 0.58, r-squared test: 0.65\n",
"Alpha = 100.00\n",
"r-squared training: 0.55, r-squared test: 0.63\n",
"Alpha = 1000.00\n",
"r-squared training: 0.27, r-squared test: 0.30\n"
]
}
],
"outputs": [],
"source": [
"# use min max scaler and ridge regressor with alpha values in [0, 1, 10, 20, 50, 100, 1000] with a polynomial\n",
"# of degree 3\n",
Expand Down Expand Up @@ -340,34 +249,9 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Alpha = 0.10\n",
"r-squared training: 0.63, r-squared test: 0.69\n",
"Alpha = 0.50\n",
"r-squared training: 0.53, r-squared test: 0.62\n",
"Alpha = 1.00\n",
"r-squared training: 0.43, r-squared test: 0.52\n",
"Alpha = 2.00\n",
"r-squared training: 0.16, r-squared test: 0.19\n",
"Alpha = 3.00\n",
"r-squared training: 0.00, r-squared test: -0.00\n",
"Alpha = 5.00\n",
"r-squared training: 0.00, r-squared test: -0.00\n",
"Alpha = 10.00\n",
"r-squared training: 0.00, r-squared test: -0.00\n",
"Alpha = 20.00\n",
"r-squared training: 0.00, r-squared test: -0.00\n",
"Alpha = 50.00\n",
"r-squared training: 0.00, r-squared test: -0.00\n"
]
}
],
"outputs": [],
"source": [
"# Lasso Regression\n",
"# another way of doing regularization is using the Lasso Regression, which also penalizes the coeficients\n",
Expand Down Expand Up @@ -406,17 +290,9 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.48715114223 0.562719985433\n"
]
}
],
"outputs": [],
"source": [
"# Support Vector Machines transform of the data before finding a match \n",
"def ex5():\n",
Expand All @@ -443,18 +319,9 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'C': 100.0}\n",
"0.561732591767 0.639787265159\n"
]
}
],
"outputs": [],
"source": [
"# Use GridSearchCV to run SVR with different parameters \n",
"def ex6():\n",
Expand Down
98 changes: 0 additions & 98 deletions week1/ex1data1.txt

This file was deleted.

48 changes: 0 additions & 48 deletions week1/ex1data2.txt

This file was deleted.

Loading

0 comments on commit 141b27e

Please sign in to comment.