User Tools

Site Tools


cs401r_w2016:lab2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
cs401r_w2016:lab2 [2016/01/12 15:48]
admin
cs401r_w2016:lab2 [2018/01/22 20:13]
sadler
Line 8: Line 8:
  
 For this lab, you will turn in an ipython notebook that implements the "​Bayesian Concept Learning"​ model from Chapter 3 of MLAPP. For this lab, you will turn in an ipython notebook that implements the "​Bayesian Concept Learning"​ model from Chapter 3 of MLAPP.
 +
 +[[http://​liftothers.org/​courses/​stat_ml/​mlapp_ch3.pdf|Here is a PDF of the relevant chapter.]]
  
 Your notebook should perform the following functions: Your notebook should perform the following functions:
Line 23: Line 25:
  
 {{:​cs401r_w2016:​lab2_pp.png?​direct&​800|}} {{:​cs401r_w2016:​lab2_pp.png?​direct&​800|}}
 +
 +----
 +====Grading standards:​====
 +
 +Your notebook will be graded on the following:
 +
 +  * 10% Correctly formed & normalized prior
 +  * 20% Correctly formed likelihood
 +  * 30% Correctly formed & normalized posterior
 +  * 30% Correctly formed & normalized posterior predictive
 +  * 10% tidy and legible figures, including labeled axes
 +
 +//Remember: correct normalization may mean different things for different distributions! //
  
 ---- ----
 ====Description:​==== ====Description:​====
 +
  
 Following the Bayesian Concept Learning example in Chapter 3 of MLAPP, we're interested in reasoning about the origin of a set of numbers. ​ We'll do this by placing a prior over a set of possible //​concepts//​ (or "​candidate origins"​),​ and then use Bayes' law to construct a posterior distribution over concepts given some data. Following the Bayesian Concept Learning example in Chapter 3 of MLAPP, we're interested in reasoning about the origin of a set of numbers. ​ We'll do this by placing a prior over a set of possible //​concepts//​ (or "​candidate origins"​),​ and then use Bayes' law to construct a posterior distribution over concepts given some data.
  
-For this lab, we will only consider numbers between 0 and 100.+For this lab, we will only consider numbers between 0 and 100, inclusive.
  
 <​del>​Your notebook should construct a set of possible number-game concepts (such as "​even"​ or "​odd"​). ​ These can be any set of concepts you want, but should include at least all of the concepts in the book (see, for example, Fig. 3.2).  You must assign a prior probability to each concept; the prior can be anything you want. </​del>​ <​del>​Your notebook should construct a set of possible number-game concepts (such as "​even"​ or "​odd"​). ​ These can be any set of concepts you want, but should include at least all of the concepts in the book (see, for example, Fig. 3.2).  You must assign a prior probability to each concept; the prior can be anything you want. </​del>​
  
 To make grading easier on our incredible TA, your notebook should construct a set of possible number-game concepts that are the same as the concepts in the book (see Fig. 3.2).  You must assign a prior probability to each concept; to make grading easier, your prior should be: To make grading easier on our incredible TA, your notebook should construct a set of possible number-game concepts that are the same as the concepts in the book (see Fig. 3.2).  You must assign a prior probability to each concept; to make grading easier, your prior should be:
- + 
 +<code python>​ 
 +prior = numpy.ones(len(concepts)) 
 +prior[0] = 5 
 +prior[1] = 5 
 +prior[30] = .01 
 +prior[31] = .01 
 +prior = prior / numpy.sum(prior) 
 +</​code>​
  
 This prior distribution is  This prior distribution is 
Line 44: Line 68:
 $$p(\mathrm{data} | h )$$ $$p(\mathrm{data} | h )$$
  
-**Important:​** you can assume that each number in the data was sampled independently,​ and that each number was sampled uniformly from the set of all possible numbers //in that concept//.+**Important:​** you can assume that each number in the data was sampled ​**independently**, and that each number was sampled ​**uniformly** from the set of all possible numbers //in that concept//.
  
 //Hint: what does that imply about the probability of sampling a given number from a concept with lots of possibilities,​ such as the ''​all''​ concept, vs. a concept with few possibilities,​ such as ''​multiples of 10''?//​ //Hint: what does that imply about the probability of sampling a given number from a concept with lots of possibilities,​ such as the ''​all''​ concept, vs. a concept with few possibilities,​ such as ''​multiples of 10''?//​
Line 63: Line 87:
 ---- ----
 ====Hints:​==== ====Hints:​====
- 
-When using an ipython notebook, it's nice to make your plots show up inline. ​ To do this, add the following lines to the first cell of your notebook: 
- 
-<code python> 
- 
-# this tells seaborn and matplotlib to generate plots inline in the notebook 
-%matplotlib inline  ​ 
- 
-# these two lines allow you to control the figure size 
-%pylab inline 
-pylab.rcParams['​figure.figsize'​] = (16.0, 8.0) 
- 
-</​code>​ 
- 
  
 You may find the following functions useful: You may find the following functions useful:
Line 102: Line 112:
 plt.title plt.title
 plt.xlabel plt.xlabel
 +
 +# changes the xlimits of an axis
 +plt.xlim
 +# changes the ylimits of an axis
 +plt.ylim
  
 </​code>​ </​code>​
cs401r_w2016/lab2.txt · Last modified: 2021/06/30 23:42 (external edit)