diff --git a/notebooks/B3. Logistic Regression - Analysis.ipynb b/notebooks/B3. Logistic Regression - Analysis.ipynb index 4fdac2f..4b4e076 100755 --- a/notebooks/B3. Logistic Regression - Analysis.ipynb +++ b/notebooks/B3. Logistic Regression - Analysis.ipynb @@ -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" @@ -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": {}, @@ -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": {}, @@ -471,7 +471,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "pz(720,10000,coeff)" + "pz(720, 10000, coeff)" ], "language": "python", "metadata": {}, @@ -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 " ] }, { @@ -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": {}, @@ -563,7 +563,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "pz(820,63000,coeff)" + "pz(820, 63000, coeff)" ], "language": "python", "metadata": {}, @@ -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", @@ -611,7 +611,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "pz(820,50000,coeff)" + "pz(820, 50000, coeff)" ], "language": "python", "metadata": {},