Skip to content

Commit 2afa147

Browse files
author
Qiuping Xu
committed
update Chapter3
1 parent 7ca4f15 commit 2afa147

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Chapter_3_sec_6.1_6.7.ipynb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"metadata": {},
2121
"outputs": [],
2222
"source": [
23-
"# In Python, module can be imported by a command similar to 'import numpy as np'. \n",
24-
"# It is a good practice to maintain a section at the beginning of the notebook to import all necessary modules.\n",
23+
"# in Python, module can be imported by a command similar to 'import numpy as np'. \n",
24+
"# it is a good practice to maintain a section at the beginning of the notebook to import all necessary modules.\n",
2525
"# for new module, could use pip to install it. \n",
2626
"# for example 'pip install numpy'\n",
2727
"import numpy as np\n",
@@ -110,7 +110,7 @@
110110
"metadata": {},
111111
"outputs": [],
112112
"source": [
113-
"# Use dir() to get a list of all the attributes an object has\n",
113+
"# use dir() to get a list of all the attributes an object has\n",
114114
"dir(lm)"
115115
]
116116
},
@@ -190,7 +190,7 @@
190190
"metadata": {},
191191
"outputs": [],
192192
"source": [
193-
"# As mentioned above. For machine learning models, sklearn is the most common used module, but sklearn is a little bit less on statistics.\n",
193+
"# as mentioned above. For machine learning models, sklearn is the most common used module, but sklearn is a little bit less on statistics.\n",
194194
"x = pd.DataFrame(Boston.lstat)\n",
195195
"y = Boston.medv\n",
196196
"print(x.shape)\n",
@@ -235,7 +235,7 @@
235235
"metadata": {},
236236
"outputs": [],
237237
"source": [
238-
"# If we want to use all the variable. We can use the following trick to manually construct the list. In Python, most of time, you have to manully construct the variable list.\n",
238+
"# if we want to use all the variable. We can use the following trick to manually construct the list. In Python, most of time, you have to manully construct the variable list.\n",
239239
"all_columns = \"+\".join(Boston.columns.difference([\"medv\"]))\n",
240240
"my_formula = \"medv~\" + all_columns\n",
241241
"lm = smf.ols(my_formula, data=Boston).fit()\n",
@@ -345,10 +345,10 @@
345345
"metadata": {},
346346
"outputs": [],
347347
"source": [
348-
"# There is anova function built in already in statsmodels. \n",
349-
"# If you know what to do, use the key words to google it and likely you will find a very good answer. \n",
350-
"# Here we compare the models with one order of stat and two orders of stats. \n",
351-
"# By looking at the p value that will reject the null hypothesis that the coefficent of lstat**2 equals 0.\n",
348+
"# there is anova function built in already in statsmodels. \n",
349+
"# if you know what to do, use the key words to google it and likely you will find a very good answer. \n",
350+
"# here we compare the models with one order of stat and two orders of stats. \n",
351+
"# by looking at the p value that will reject the null hypothesis that the coefficent of lstat**2 equals 0.\n",
352352
"table = sm.stats.anova_lm(lm_order1, lm_order2)\n",
353353
"print(table)"
354354
]
@@ -456,7 +456,7 @@
456456
"metadata": {},
457457
"outputs": [],
458458
"source": [
459-
"# Then the model buliding will be the same with all numerrical variables.\n",
459+
"# then the model buliding will be the same with all numerrical variables.\n",
460460
"lm_carseats_dummy = smf.ols('Sales ~ Income + Advertising + Price + Age + ShelveLoc_Good + ShelveLoc_Medium', \n",
461461
" data = Carseats_dummy).fit()"
462462
]
@@ -467,7 +467,7 @@
467467
"metadata": {},
468468
"outputs": [],
469469
"source": [
470-
"# The interpretation of the coefficients are holding everything fixed, Medium shelve location is associated with an average\n",
470+
"# the interpretation of the coefficients are holding everything fixed, Medium shelve location is associated with an average\n",
471471
"# increase of sale around 2.0046. \n",
472472
"lm_carseats_dummy.summary() "
473473
]
@@ -499,9 +499,9 @@
499499
"metadata": {},
500500
"outputs": [],
501501
"source": [
502-
"# Let us write a simple function to print current time. \n",
503-
"# The key word in Python for user defined function is 'def'. \n",
504-
"# Pay attention to the ':'. The difference betwwen R (others) and Python is that Python \n",
502+
"# let us write a simple function to print current time. \n",
503+
"# yhe key word in Python for user defined function is 'def'. \n",
504+
"# pay attention to the ':'. The difference betwwen R (others) and Python is that Python \n",
505505
"# forces you to obey its indentation rules. For example, the following function won't work because of the extra space in front of 'print'.\n",
506506
"def print_current_time_wrong():\n",
507507
" from datetime import datetime # this is very bad practice !!! \n",
@@ -559,7 +559,7 @@
559559
"name": "python",
560560
"nbconvert_exporter": "python",
561561
"pygments_lexer": "ipython3",
562-
"version": "3.5.6"
562+
"version": "3.6.2"
563563
}
564564
},
565565
"nbformat": 4,

0 commit comments

Comments
 (0)