-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added empty notebooks for Chapter 4 Linear models
- Loading branch information
1 parent
622b4e0
commit 88abd93
Showing
7 changed files
with
614 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
# Chapter 4 — Linear models | ||
|
||
The notebooks for Chapter 4 are still WIP, | ||
but you can check out the [Chapter 4 outline](https://docs.google.com/document/d/1fwep23-95U-w1QMPU31nOvUnUXE2X3s_Dbk5JuLlKAY/edit#heading=h.9etj7aw4al9w) | ||
in the meantime to know what will be covered. | ||
See the [Chapter 4 outline](https://docs.google.com/document/d/1fwep23-95U-w1QMPU31nOvUnUXE2X3s_Dbk5JuLlKAY/edit#heading=h.9etj7aw4al9w) | ||
for an overview of what is covered in the book | ||
|
||
|
||
## Notebooks | ||
|
||
Each notebook contains the code examples from corresponding section in book. | ||
If you're reading the book, you should follow along by running the commands in the these notebooks, | ||
to check all the probability calculations for yourself. | ||
|
||
- Simple linear regression [41_simple_linear_regression.ipynb](./41_simple_linear_regression.ipynb) | ||
- Multiple linear regression [42_multiple_linear_regression.ipynb](./42_multiple_linear_regression.ipynb) | ||
- Regression with categorical predictors [43_regression_with_categorical_predictors.ipynb](./43_regression_with_categorical_predictors.ipynb) | ||
- Interpreting linear models [44_interpreting_linear_models.ipynb](./44_interpreting_linear_models.ipynb) | ||
- Generalized linear models [45_generalized_linear_models.ipynb](./45_generalized_linear_models.ipynb) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3ec95fa0-da20-41dc-820e-2f33f262f4e2", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"# Section 4.2 — Multiple linear regression\n", | ||
"\n", | ||
"This notebook contains the code examples from [Section 4.2 Multiple linear regression]() from the **No Bullshit Guide to Statistics**." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "eb4d1856-22a1-4634-87d7-5fc091d93e12", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"#### Notebook setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "0003a9e7-21c7-47a5-bdec-3bd3ca2a79f4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# load Python modules\n", | ||
"import os\n", | ||
"import numpy as np\n", | ||
"import pandas as pd\n", | ||
"import seaborn as sns\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "8e67e0e7-4f48-4c48-a49d-3cdf22cbd014", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<Figure size 500x160 with 0 Axes>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"# Figures setup\n", | ||
"plt.clf() # needed otherwise `sns.set_theme` doesn't work\n", | ||
"from plot_helpers import RCPARAMS\n", | ||
"# RCPARAMS.update({'figure.figsize': (10, 3)}) # good for screen\n", | ||
"RCPARAMS.update({'figure.figsize': (5, 1.6)}) # good for print\n", | ||
"sns.set_theme(\n", | ||
" context=\"paper\",\n", | ||
" style=\"whitegrid\",\n", | ||
" palette=\"colorblind\",\n", | ||
" rc=RCPARAMS,\n", | ||
")\n", | ||
"\n", | ||
"# High-resolution please\n", | ||
"%config InlineBackend.figure_format = 'retina'\n", | ||
"\n", | ||
"# Where to store figures\n", | ||
"DESTDIR = \"figures/lm/multiple\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "efc0e89b-72bf-4658-8f8a-a3d85bee00b6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# set random seed for repeatability\n", | ||
"np.random.seed(42)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4d67690c-bc4c-400c-9d49-cb7b3d31c894", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
117 changes: 117 additions & 0 deletions
117
notebooks/43_regression_with_categorical_predictors.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3ec95fa0-da20-41dc-820e-2f33f262f4e2", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"# Section 4.3 — Regression with categorical predictors\n", | ||
"\n", | ||
"This notebook contains the code examples from [Section 4.3 Regression with categorical predictors]() from the **No Bullshit Guide to Statistics**." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "eb4d1856-22a1-4634-87d7-5fc091d93e12", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"#### Notebook setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "0003a9e7-21c7-47a5-bdec-3bd3ca2a79f4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# load Python modules\n", | ||
"import os\n", | ||
"import numpy as np\n", | ||
"import pandas as pd\n", | ||
"import seaborn as sns\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "8e67e0e7-4f48-4c48-a49d-3cdf22cbd014", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<Figure size 500x160 with 0 Axes>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"# Figures setup\n", | ||
"plt.clf() # needed otherwise `sns.set_theme` doesn't work\n", | ||
"from plot_helpers import RCPARAMS\n", | ||
"# RCPARAMS.update({'figure.figsize': (10, 3)}) # good for screen\n", | ||
"RCPARAMS.update({'figure.figsize': (5, 1.6)}) # good for print\n", | ||
"sns.set_theme(\n", | ||
" context=\"paper\",\n", | ||
" style=\"whitegrid\",\n", | ||
" palette=\"colorblind\",\n", | ||
" rc=RCPARAMS,\n", | ||
")\n", | ||
"\n", | ||
"# High-resolution please\n", | ||
"%config InlineBackend.figure_format = 'retina'\n", | ||
"\n", | ||
"# Where to store figures\n", | ||
"DESTDIR = \"figures/lm/categorical\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "efc0e89b-72bf-4658-8f8a-a3d85bee00b6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# set random seed for repeatability\n", | ||
"np.random.seed(42)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4d67690c-bc4c-400c-9d49-cb7b3d31c894", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.