Skip to content

Commit 97d8d7d

Browse files
committed
next pylab update
1 parent 87a7569 commit 97d8d7d

File tree

29 files changed

+14961
-9867
lines changed

29 files changed

+14961
-9867
lines changed

notebooks/.ipynb_checkpoints/D3. K-Means Clustering Analysis-checkpoint.ipynb

Lines changed: 419 additions & 0 deletions
Large diffs are not rendered by default.

notebooks/.ipynb_checkpoints/WA1. Linear Regression Overview Worksheet-checkpoint.ipynb

Lines changed: 391 additions & 0 deletions
Large diffs are not rendered by default.

notebooks/.ipynb_checkpoints/WA2. Linear Regression - Data Exploration - Lending Club Worksheet-checkpoint.ipynb

Lines changed: 372 additions & 0 deletions
Large diffs are not rendered by default.

notebooks/ZZZ1. Recording test.ipynb renamed to notebooks/.ipynb_checkpoints/WA3. Linear Regression - Analysis Worksheet-checkpoint.ipynb

Lines changed: 56 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,64 @@
11
{
22
"cells": [
33
{
4-
"cell_type": "markdown",
5-
"metadata": {},
6-
"source": [
7-
"Logistic Regression - Overview\n",
8-
"===========\n",
9-
"***\n",
10-
"\n",
11-
"###What are the odds that an event will happen? Answering yes/no questions.\n",
12-
"\n"
13-
]
14-
},
15-
{
16-
"cell_type": "markdown",
17-
"metadata": {},
18-
"source": [
19-
"<img src=\"files/images/b1fig1_nfloutcomes.png\" />"
20-
]
21-
},
22-
{
23-
"cell_type": "markdown",
24-
"metadata": {},
25-
"source": [
26-
"<img src=\"files/images/b1fig2_nfloutcomes_withline.png\" />"
27-
]
28-
},
29-
{
30-
"cell_type": "markdown",
31-
"metadata": {},
32-
"source": [
33-
"\n",
34-
"<img src=\"files/images/standardSigmoidFunction.png\" />\n",
35-
"\n"
36-
]
37-
},
38-
{
39-
"cell_type": "markdown",
40-
"metadata": {},
41-
"source": [
42-
"\n",
43-
"\n",
44-
"\n"
45-
]
46-
},
47-
{
48-
"cell_type": "markdown",
49-
"metadata": {},
50-
"source": [
51-
"A function that has the above shape is:\n",
52-
"\n",
53-
"\n",
54-
"$$P(x) = \\frac{1}{1 + e^{b_0 + b_1x}}$$\n",
55-
"\n",
56-
"---\n",
57-
"where P(x) is the probability of a score of x leading to a win. \n",
58-
"$b_0, b_1$ are parameters that we will estimate, so the curve fits our data.\n",
59-
"\n",
60-
"\n",
61-
"\n",
62-
"\n"
63-
]
64-
},
65-
{
66-
"cell_type": "markdown",
67-
"metadata": {},
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [
10+
{
11+
"name": "stdout",
12+
"output_type": "stream",
13+
"text": [
14+
"Populating the interactive namespace from numpy and matplotlib\n",
15+
"Coefficients: [ 72.88279832 -0.08844242]\n",
16+
"Intercept: 0.000210747768548\n",
17+
"P-Values: [ 0.00000000e+000 0.00000000e+000 5.96972978e-203]\n",
18+
"R-Squared: 0.656632624649\n"
19+
]
20+
}
21+
],
6822
"source": [
69-
"---\n",
70-
"\n",
71-
"\n",
72-
"\n",
73-
"\n",
74-
"\n",
75-
"\n",
76-
"\n",
77-
"\n",
78-
"\n",
79-
"\n",
80-
"---\n",
81-
"\n",
82-
"\n",
83-
"\n",
84-
"\n",
85-
"\n",
86-
"\n",
87-
"\n",
88-
"\n",
89-
"\n",
90-
"\n",
91-
"\n",
92-
"\n",
93-
"\n",
94-
"\n",
95-
"\n"
23+
"%pylab inline\n",
24+
"import pylab as pl\n",
25+
"import numpy as np\n",
26+
"#from sklearn import datasets, linear_model\n",
27+
"import pandas as pd\n",
28+
"import statsmodels.api as sm\n",
29+
"\n",
30+
"# import the cleaned up dataset\n",
31+
"df = pd.read_csv('../datasets/loanf.csv')\n",
32+
"\n",
33+
"intrate = df['Interest.Rate']\n",
34+
"loanamt = df['Loan.Amount']\n",
35+
"fico = df['FICO.Score']\n",
36+
"\n",
37+
"# reshape the data from a pandas Series to columns \n",
38+
"# the dependent variable\n",
39+
"y = np.matrix(intrate).transpose()\n",
40+
"# the independent variables shaped as columns\n",
41+
"x1 = np.matrix(fico).transpose()\n",
42+
"x2 = np.matrix(loanamt).transpose()\n",
43+
"\n",
44+
"# put the two columns together to create an input matrix \n",
45+
"# if we had n independent variables we would have n columns here\n",
46+
"x = np.column_stack([x1,x2])\n",
47+
"\n",
48+
"# create a linear model and fit it to the data\n",
49+
"X = sm.add_constant(x)\n",
50+
"model = sm.OLS(y,X)\n",
51+
"f = model.fit()\n",
52+
"\n",
53+
"print 'Coefficients: ', f.params[0:2]\n",
54+
"print 'Intercept: ', f.params[2]\n",
55+
"print 'P-Values: ', f.pvalues\n",
56+
"print 'R-Squared: ', f.rsquared\n"
9657
]
9758
},
9859
{
9960
"cell_type": "code",
100-
"execution_count": 3,
61+
"execution_count": 1,
10162
"metadata": {
10263
"collapsed": false
10364
},
@@ -167,27 +128,15 @@
167128
"</script>"
168129
],
169130
"text/plain": [
170-
"<IPython.core.display.HTML at 0x109391790>"
131+
"<IPython.core.display.HTML at 0x10931ba90>"
171132
]
172133
},
173-
"execution_count": 3,
134+
"execution_count": 1,
174135
"metadata": {},
175136
"output_type": "execute_result"
176137
}
177138
],
178139
"source": [
179-
"\n",
180-
"\n",
181-
"\n",
182-
"\n",
183-
"\n",
184-
"\n",
185-
"\n",
186-
"\n",
187-
"\n",
188-
"\n",
189-
"\n",
190-
"\n",
191140
"from IPython.core.display import HTML\n",
192141
"def css_styling():\n",
193142
" styles = open(\"../styles/custom.css\", \"r\").read()\n",
@@ -197,7 +146,7 @@
197146
},
198147
{
199148
"cell_type": "code",
200-
"execution_count": 3,
149+
"execution_count": null,
201150
"metadata": {
202151
"collapsed": false
203152
},

0 commit comments

Comments
 (0)