deconstructing data science
play

Deconstructing Data Science David Bamman, UC Berkeley Info 290 - PowerPoint PPT Presentation

Deconstructing Data Science David Bamman, UC Berkeley Info 290 Lecture 8: Probabilistic models: Naive Bayes Feb 9, 2017 elements of probability in many of these methods Linear regression Decision trees Ordinal regression


  1. 
 Deconstructing Data Science David Bamman, UC Berkeley 
 Info 290 
 Lecture 8: Probabilistic models: Naive Bayes Feb 9, 2017

  2. elements of probability in many of these methods Linear regression Decision trees Ordinal regression Probabilistic graphical models Random forests Logistic regression Topic models Survival models K-means clustering Neural networks Perceptron

  3. Random variable • A variable that can take values within a fixed set (discrete) or within some range (continuous). X ∈ { 1 , 2 , 3 , 4 , 5 , 6 } X ∈ { the, a, dog, cat, runs, to, store }

  4. P ( X = x ) Probability that the random variable X takes the value x (e.g., 1) X ∈ { 1 , 2 , 3 , 4 , 5 , 6 } Two conditions: 0 ≤ P ( X = x ) ≤ 1 1. Between 0 and 1: X 2. Sum of all probabilities = 1 P ( X = x ) = 1 x

  5. Fair dice fair 0.5 0.4 X ∈ { 1 , 2 , 3 , 4 , 5 , 6 } 0.3 0.2 0.1 0.0 1 2 3 4 5 6

  6. Weighted dice not fair 0.5 0.4 X ∈ { 1 , 2 , 3 , 4 , 5 , 6 } 0.3 0.2 0.1 0.0 1 2 3 4 5 6

  7. Inference X ∈ { 1 , 2 , 3 , 4 , 5 , 6 } We want to infer the probability distribution that generated the data we see. fair not fair 0.5 0.5 0.4 0.4 0.3 0.3 ? 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  8. 0.0 0.1 0.2 0.3 0.4 0.5 1 2 3 fair 4 Probability 5 6 0.0 0.1 0.2 0.3 0.4 0.5 1 2 3 not fair 4 5 6

  9. Probability fair not fair 0.5 0.5 2 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  10. Probability 2 fair not fair 0.5 0.5 6 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  11. Probability 2 6 fair not fair 0.5 0.5 6 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  12. Probability 2 6 6 fair not fair 0.5 0.5 1 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  13. Probability 2 6 6 1 fair not fair 0.5 0.5 6 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  14. Probability 2 6 6 1 6 fair not fair 0.5 0.5 3 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  15. Probability 2 6 6 1 6 3 fair not fair 0.5 0.5 6 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  16. Probability 2 6 6 1 6 3 6 fair not fair 0.5 0.5 6 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  17. Probability 2 6 6 1 6 3 6 6 fair not fair 0.5 0.5 3 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  18. Probability 2 6 6 1 6 3 6 6 3 fair not fair 0.5 0.5 6 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6

  19. Probability 2 6 6 1 6 3 6 6 3 6 fair not fair 0.5 0.5 ? 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 1 2 3 4 5 6 1 2 3 4 5 6 1 15,625

  20. Independence • Two random variables are independent if: P ( A , B ) = P ( A ) × P ( B ) • In general: N P ( x 1 , . . . , x n ) = � P ( x i ) i = 1 • Information about one random variable (B) gives no information about the value of another (A) P ( A ) = P ( A | B ) P ( B ) = P ( B | A )

  21. Data Likelihood fair 0.5 0.4 0.3 0.2 =.17 x .17 x .17 
 P( | ) 2 6 6 0.1 = 0.004913 0.0 1 2 3 4 5 6 not fair 0.5 0.4 = .1 x .5 x .5 
 P( | ) 0.3 2 6 6 = 0.025 0.2 0.1 0.0 1 2 3 4 5 6

  22. Data Likelihood • The likelihood gives us a way of discriminating between possible alternative parameters, but also a strategy for picking a single best* parameter among all possibilities

  23. Unigram probability X ∈ { the, a, dog, cat, runs, to, store } 0.4 0.2 0.0 the a dog cat runs to store How do we calculate this?

  24. In a few days Mr. Bingley returned Mr. Bennet's visit, and sat about ten minutes with him in his library. He had entertained hopes of being admitted to a sight of the young ladies, of whose beauty he had heard much; but he saw only the father. The ladies were somewhat more fortunate, for they had the advantage of ascertaining from an upper window that he wore a blue coat, and rode a black horse. An invitation to dinner was soon afterwards dispatched; and already had Mrs. Bennet planned the courses that were to do credit to her housekeeping, when an answer arrived which deferred it all. Mr. Bingley was obliged to be in town the following day, and, consequently unable to accept the honour of their invitation, etc. Mrs. Bennet was quite disconcerted. She could not imagine what business he could have in town so soon after his arrival in Hertfordshire; and she began to fear that he might be always flying about from one place to another, and never settled at Netherfield as he ought to be. Lady Lucas quieted her fears a little by starting the idea of his being gone to London only to get a large party for the ball; and a eport soon followed that Mr. Bingley was to bring twelve ladies and seven gentlemen with him to the assembly The girls grieved over such a number of ladies, but were comforted the day before the ball by hearing, that instead of twelve he brought only six with him from London--his five sisters and a cousin. And when the party entered the assembly room it consisted of only five altogether--Mr. Bingley, his two sisters, the husband of the eldest, and another young man. Mr. Bingley was good-looking and gentlemanlike; he had a pleasant countenance, and easy fected manners. His sisters were fine women, with an air of decided fashion. His brother-in-law, Mr. Hurst, P(X=“the”) = 28/536 = .052 ely looked the gentleman; but his friend Mr. Darcy soon drew the attention of the room by his fine, tall person, handsome features, noble mien, and the report which was in general circulation within five minutes after his entrance, of his having ten thousand a year. The gentlemen pronounced him to be a fine figure of a man, the ladies declared he was much handsomer than Mr. Bingley, and he was looked at with great admiration for about half the evening, till his manners gave a disgust which turned the tide of his popularity; for he was discovered to be pr to be above his company, and above being pleased; and not all his large estate in Derbyshire could then save him om having a most forbidding, disagreeable countenance, and being unworthy to be compared with his friend. . Bingley had soon made himself acquainted with all the principal people in the room; he was lively and eserved, danced every dance, was angry that the ball closed so early, and talked of giving one himself at Netherfield. Such amiable qualities must speak for themselves. What a contrast between him and his friend! Mr cy danced only once with Mrs. Hurst and once with Miss Bingley, declined being introduced to any other lady and spent the rest of the evening in walking about the room, speaking occasionally to one of his own party. His character was decided. He was the proudest, most disagreeable man in the world, and everybody hoped that he would never come there again. Amongst the most violent against him was Mrs. Bennet, whose dislike of his general behaviour was sharpened into particular resentment by his having slighted one of her daughters.

  25. Maximum Likelihood Estimate • This is a maximum likelihood estimate for P(X); the parameter values for which the data we observe (X) is most likely.

  26. Maximum Likelihood Estimate 2 6 6 1 6 3 6 6 3 6 0.6 0.5 0.4 0.3 0.2 0.1 0.0 1 2 3 4 5 6

  27. 2 6 6 1 6 3 6 6 3 6 0.6 0.5 0.4 P(X | θ 1 ) = 0.0000311040 θ 1 0.3 0.2 0.1 0.0 1 2 3 4 5 6 0.5 0.4 P(X | θ 2 ) = 0.0000000992 
 0.3 θ 2 0.2 (313x less likely) 0.1 0.0 1 2 3 4 5 6 0.5 0.4 P(X | θ 3 ) = 0.0000031250 
 0.3 θ 3 (10x less likely) 0.2 0.1 0.0 1 2 3 4 5 6

  28. Conditional Probability P ( X = x | Y = y ) • Probability that one random variable takes a particular value given the fact that a different variable takes another P ( X i = dog | X i − 1 = the )

  29. Conditional Probability P ( X i = dog | X i − 1 = the ) 0.5 0.4 0.3 0.2 0.1 0.0 the a dog cat runs to store

  30. Conditional Probability P ( X i = x | X i − 1 = the ) 0.5 0.4 0.3 0.2 0.1 0.0 the a dog cat runs to store P ( X i = x ) 0.4 0.2 0.0 the a dog cat runs to store

Recommend


More recommend