Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ spaces around operators #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions notebooks/B3. Logistic Regression - Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"collapsed": false,
"input": [
"# we add a column which indicates (True/False) whether the interest rate is <= 12 \n",
"dfr['TF']=dfr['Interest.Rate']<=12\n",
"dfr['TF'] = dfr['Interest.Rate'] <= 12\n",
"# inspect again\n",
"dfr.head()\n",
"# we see that the TF values are False as Interest.Rate is higher than 12 in all these cases"
Expand Down Expand Up @@ -355,9 +355,9 @@
"# statsmodels requires us to add a constant column representing the intercept\n",
"dfr['intercept']=1.0\n",
"# identify the independent variables \n",
"ind_cols=['FICO.Score','Loan.Amount','intercept']\n",
"ind_cols = ['FICO.Score', 'Loan.Amount', 'intercept']\n",
"logit = sm.Logit(dfr['TF'], dfr[ind_cols])\n",
"result=logit.fit()"
"result = logit.fit()"
],
"language": "python",
"metadata": {},
Expand Down Expand Up @@ -449,10 +449,10 @@
"collapsed": false,
"input": [
"def pz(fico,amt,coeff):\n",
" # compute the linear expression by multipyling the inputs by their respective coefficients.\n",
" # note that the coefficient array has the intercept coefficient at the end\n",
" z = coeff[0]*fico + coeff[1]*amt + coeff[2]\n",
" return 1/(1+exp(-1*z))"
" # compute the linear expression by multipyling the inputs by their respective coefficients.\n",
" # note that the coefficient array has the intercept coefficient at the end\n",
" z = coeff[0] * fico + coeff[1] * amt + coeff[2]\n",
" return 1 / (1 + exp(-1 * z))"
],
"language": "python",
"metadata": {},
Expand All @@ -471,7 +471,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"pz(720,10000,coeff)"
"pz(720, 10000, coeff)"
],
"language": "python",
"metadata": {},
Expand Down Expand Up @@ -499,11 +499,11 @@
"source": [
"Now we are going to try (fico, amt) pairs as follows:\n",
"\n",
"* 720,20000\n",
"* 720,30000\n",
"* 820,10000\n",
"* 820,20000 \n",
"* 820,30000 "
"* 720, 20000\n",
"* 720, 30000\n",
"* 820, 10000\n",
"* 820, 20000 \n",
"* 820, 30000 "
]
},
{
Expand All @@ -513,17 +513,17 @@
"print(\"Trying multiple FICO Loan Amount combinations: \")\n",
"print('----')\n",
"print(\"fico=720, amt=10,000\")\n",
"print(pz(720,10000,coeff))\n",
"print(pz(720, 10000, coeff))\n",
"print(\"fico=720, amt=20,000\")\n",
"print(pz(720,20000,coeff))\n",
"print(pz(720, 20000, coeff))\n",
"print(\"fico=720, amt=30,000\")\n",
"print(pz(720,30000,coeff))\n",
"print(pz(720, 30000, coeff))\n",
"print(\"fico=820, amt=10,000\")\n",
"print(pz(820,10000,coeff))\n",
"print(pz(820, 10000, coeff))\n",
"print(\"fico=820, amt=20,000\")\n",
"print(pz(820,20000,coeff))\n",
"print(pz(820, 20000, coeff))\n",
"print(\"fico=820, amt=30,000\")\n",
"print(pz(820,30000,coeff))\n"
"print(pz(820, 30000, coeff))\n"
],
"language": "python",
"metadata": {},
Expand Down Expand Up @@ -563,7 +563,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"pz(820,63000,coeff)"
"pz(820, 63000, coeff)"
],
"language": "python",
"metadata": {},
Expand Down Expand Up @@ -593,14 +593,14 @@
"Try the following pairs of (fico, amt) values and plug them into the pz() function mimicing the syntax below. What insight does this give you?\n",
"\n",
"\n",
"* 820,50000\n",
"* 820,60000\n",
"* 820,70000\n",
"* 820,63000\n",
"* 820,65000\n",
"* 820, 50000\n",
"* 820, 60000\n",
"* 820, 70000\n",
"* 820, 63000\n",
"* 820, 65000\n",
"\n",
"Place your cursor on the cell below. Hit shift-enter to recreate the result. \n",
"Then click Insert->Cell Below via the Insert menu dropdown. This creates a new empty cell.\n",
"Then click Insert -> Cell Below via the Insert menu dropdown. This creates a new empty cell.\n",
"Now enter the pz() function with the next pair of values. Hit shift-enter.\n",
"Repeat this till the end of the list of values.\n",
"Answer the question above, if possible.\n",
Expand All @@ -611,7 +611,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"pz(820,50000,coeff)"
"pz(820, 50000, coeff)"
],
"language": "python",
"metadata": {},
Expand Down