Skip to content

Commit bc062af

Browse files
Merge branch 'master' of github.com:CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers
2 parents 80cb0e4 + 956adee commit bc062af

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@
10381038
"input": [
10391039
"## Enter code here\n",
10401040
"import scipy.stats as stats\n",
1041-
"exp = stats.expon( 4 )\n",
1041+
"exp = stats.expon( scale=4 )\n",
10421042
"N = 1e5\n",
10431043
"X = exp.rvs( N )\n",
10441044
"## ..."
@@ -1170,4 +1170,4 @@
11701170
"metadata": {}
11711171
}
11721172
]
1173-
}
1173+
}

Chapter5_LossFunctions/LossFunctions.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
"\n",
209209
"subplot(313)\n",
210210
"x = np.linspace(0, 25000, 200)\n",
211-
"plt.fill_between(x , 0, norm_pdf( x, 12000, 3000), \n",
211+
"sp3 = plt.fill_between(x , 0, norm_pdf( x, 12000, 3000), \n",
212212
" color = \"#7A68A6\", lw = 3, alpha = 0.6,\n",
213213
" label = \"Trip price guess\")\n",
214214
"plt.autoscale( tight=True)\n",
@@ -357,9 +357,10 @@
357357
"def showdown_loss( guess, true_price, risk = 80000):\n",
358358
" loss = np.zeros_like( true_price )\n",
359359
" ix = true_price < guess\n",
360-
" loss[ix] = risk\n",
361360
" loss[~ix] = np.abs( guess - true_price[~ix] )\n",
362-
" loss[ abs( true_price - guess) <= 250 ] = -2*true_price\n",
361+
" close_mask = [ abs( true_price - guess) <= 250 ]\n",
362+
" loss[close_mask] = -2*true_price[close_mask]\n",
363+
" loss[ix] = risk\n",
363364
" return loss\n",
364365
"\n",
365366
"\n",

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ Interactive notebooks + examples can be downloaded by cloning! )
3232
* [**Prologue:**](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Prologue/Prologue.ipynb) Why we do it.
3333

3434
* [**Chapter 1: Introduction to Bayesian Methods**](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter1_Introduction/Chapter1_Introduction.ipynb)
35-
Introduction to the philosophy and practice of Bayesian methods and answering the question "What is probabilistic programming?" Examples include:
36-
- Inferring human behaviour changes from text message rates.
35+
Introduction to the philosophy and practice of Bayesian methods and answering the question, "What is probabilistic programming?" Examples include:
36+
- Inferring human behaviour changes from text message rates
3737

3838
* [**Chapter 2: A little more on PyMC**](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter2_MorePyMC/MorePyMC.ipynb)
3939
We explore modeling Bayesian problems using Python's PyMC library through examples. How do we create Bayesian models? Examples include:
40-
- Detecting the frequency of cheating students, while avoiding liars.
41-
- Calculating probabilities of the Challenger space-shuttle disaster.
40+
- Detecting the frequency of cheating students, while avoiding liars
41+
- Calculating probabilities of the Challenger space-shuttle disaster
4242

4343
* [**Chapter 3: Opening the Black Box of MCMC**](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter3_MCMC/IntroMCMC.ipynb)
4444
We discuss how MCMC operates and diagnostic tools. Examples include:
@@ -50,21 +50,21 @@ Interactive notebooks + examples can be downloaded by cloning! )
5050
- How to sort Reddit comments from best to worst (not as easy as you think)
5151

5252
* [**Chapter 5: Would you rather lose an arm or a leg?**](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter5_LossFunctions/LossFunctions.ipynb)
53-
The introduction of Loss functions and their (awesome) use in Bayesian methods. Examples include:
54-
- Solving the Price is Right's Showdown
53+
The introduction of loss functions and their (awesome) use in Bayesian methods. Examples include:
54+
- Solving the *Price is Right*'s Showdown
5555
- Optimizing financial predictions
56-
- Winning solution to the Kaggle Dark World's competition.
56+
- Winning solution to the Kaggle Dark World's competition
5757

5858
* [**Chapter 6: Getting our *prior*-ities straight**](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter6_Priorities/Priors.ipynb)
5959
Probably the most important chapter. We draw on expert opinions to answer questions. Examples include:
6060
- Multi-Armed Bandits and the Bayesian Bandit solution.
61-
- what is the relationship between data sample size and prior?
62-
- estimating financial unknowns using expert priors.
61+
- What is the relationship between data sample size and prior?
62+
- Estimating financial unknowns using expert priors
6363

64-
We explore useful tips to be objective in analysis, and common pitfalls of priors.
64+
We explore useful tips to be objective in analysis as well as common pitfalls of priors.
6565

6666
* **Chapter X1: Bayesian methods in Machine Learning and Model Validation**
67-
We explore how to resolve the overfitting problem plus popular ML methods. Also included are probablistic explainations of Ridge Regression and LASSO Regression.
67+
We explore how to resolve the overfitting problem plus popular ML methods. Also included are probablistic explainations of ridge regression and LASSO regression.
6868
- Tim Saliman's winning solution to Kaggle's *Don't Overfit* problem
6969

7070
* **Chapter X2: More PyMC Hackery**
@@ -85,21 +85,21 @@ The book can be read in three different ways, starting from most recommended to
8585
1. The most recommended option is to clone the repository to download the .ipynb files to your local machine. If you have IPython installed, you can view the
8686
chapters in your browser *plus* edit and run the code provided (and try some practice questions). This is the preferred option to read
8787
this book, though it comes with some dependencies.
88-
- IPython 0.13 is a requirement to view the ipynb files. It can be downloaded [here](http://ipython.org/)
89-
- For Linux users, you should not have a problem installing Numpy, Scipy, Matplotlib and PyMC. For Windows users, check out [pre-compiled versions](http://www.lfd.uci.edu/~gohlke/pythonlibs/) if you have difficulty.
88+
- IPython v0.13 (or greater) is a requirement to view the ipynb files. It can be downloaded [here](http://ipython.org/)
89+
- For Linux users, you should not have a problem installing NumPy, SciPy, Matplotlib and PyMC. For Windows users, check out [pre-compiled versions](http://www.lfd.uci.edu/~gohlke/pythonlibs/) if you have difficulty.
9090
- In the styles/ directory are a number of files (.matplotlirc) that used to make things pretty. These are not only designed for the book, but they offer many improvements over the default settings of matplotlib and the IPython notebook.
91-
- while technically not required, it may help to run the IPython notebook with `--pylab inline` if you encounter runtime errors.
91+
- while technically not required, it may help to run the IPython notebook with `ipython notebook --pylab inline` flag if you encounter io errors.
9292
2. The second, preferred, option is to use the nbviewer.ipython.org site, which display IPython notebooks in the browser ([example](http://nbviewer.ipython.org/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter1_Introduction/Chapter1_Introduction.ipynb)).
9393
The contents are updated synchronously as commits are made to the book. You can use the Contents section above to link to the chapters.
9494

95-
3. **PDF versions are coming.** PDFs are the least-prefered method to read the book, as pdf's are static and non-interactive. If PDFs are desired, they can be created dynamically using Chrome's builtin print-to-pdf feature.
95+
3. **PDF versions are coming.** PDFs are the least-prefered method to read the book, as pdf's are static and non-interactive. If PDFs are desired, they can be created dynamically using Chrome's builtin print-to-pdf feature or using the [nbconvert](https://github.com/ipython/nbconvert) utility.
9696

9797

9898
Installation and configuration
9999
------
100100
If you would like to run the IPython notebooks locally, (option 1. above), you'll need to install the following:
101101
- IPython 0.13 is a requirement to view the ipynb files. It can be downloaded [here](http://ipython.org/ipython-doc/dev/install/index.html)
102-
- For Linux users, you should not have a problem installing Numpy, Scipy and PyMC. For Windows users, check out [pre-compiled versions](http://www.lfd.uci.edu/~gohlke/pythonlibs/) if you have difficulty.
102+
- For Linux users, you should not have a problem installing NumPy, SciPy and PyMC. For Windows users, check out [pre-compiled versions](http://www.lfd.uci.edu/~gohlke/pythonlibs/) if you have difficulty.
103103
- also recommended, for data-mining exercises, are [PRAW](https://github.com/praw-dev/praw) and [requests](https://github.com/kennethreitz/requests).
104104

105105
- In the styles/ directory are a number of files that are customized for the notebook.
@@ -120,11 +120,11 @@ Authors submit content or revisions using the GitHub interface.
120120

121121
- The current chapter list is not finalized. If you see something that is missing (MCMC, MAP, Bayesian networks, good prior choices, Potential classes etc.),
122122
feel free to start there.
123-
- Cleaning up Python code and making code more PyMC-esque.
123+
- Cleaning up Python code and making code more PyMC-esque
124124
- Giving better explanations
125125
- Spelling/grammar mistakes
126126
- Suggestions
127-
- Contributing to the IPython notebook styles.
127+
- Contributing to the IPython notebook styles
128128

129129

130130
####Commiting

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ipython>=0.13.2
2+
matplotlib>=1.2.1
3+
numpy>=1.7.1
4+
pymc>=2.2
5+
pyzmq>=13.1.0
6+
scipy>=0.12.0
7+
tornado>=3.0.2
8+
wsgiref>=0.1.2

0 commit comments

Comments
 (0)