1 / 28

Homework 3: Solutions

CS4445/B12 Provided by: Kenneth J. Loomis. Homework 3: Solutions. Topology of the Network. This is the naïve topology, we can easily construct the graph for this dataset. likes. genre. critics-reviews. rating. IMAX.

season
Download Presentation

Homework 3: Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS4445/B12 Provided by: Kenneth J. Loomis Homework 3: Solutions

  2. Topology of the Network • This is the naïve topology, we can easily construct the graph for this dataset. likes genre critics-reviews rating IMAX • Then we need to calculate the conditional probability tables for each of the nodes in this network. • This will be shown in three steps for each node: • Build a frequency table • Add 1 to account for “fake” instances that prevent zero probability. • Convert the frequency table to a conditional probability table.

  3. Likes: Calculate Frequencies likes genre critics-reviews rating IMAX • Notice that there are no parents for this node.

  4. Likes: Include “fake” instances likes genre critics-reviews rating IMAX • Add 1 to each of the frequency counts.

  5. Likes: Convert to CPT likes genre critics-reviews rating IMAX • Notice that we add two “fake” instances, so we add 2 to the total number of instance:

  6. Genre: Calculate Frequencies likes genre critics-reviews rating IMAX • Notice that there is a parent for this node.

  7. Genre: Include “fake” instances likes genre critics-reviews rating IMAX • Add 1 to each of the frequency counts.

  8. Genre: Convert to CPT likes genre critics-reviews rating IMAX • Notice that there are • 5+3=8 “noes” and • 9+3=12 “yesses”.

  9. Critics-Reviews: Calculate Frequencies likes genre critics-reviews rating IMAX • Notice that there is a parent for this node.

  10. Critics-Reviews: Include “fake” instances likes genre critics-reviews rating IMAX • Add 1 to each of the frequency counts.

  11. Critics-Reviews: Convert to CPT likes genre critics-reviews rating IMAX • Notice that there are • 5+3=8 “noes” and • 9+3=12 “yesses”.

  12. Rating: Calculate Frequencies likes genre critics-reviews rating IMAX • Notice that there is a parent for this node.

  13. Rating : Include “fake” instances likes genre critics-reviews rating IMAX • Add 1 to each of the frequency counts.

  14. Rating : Convert to CPT likes genre critics-reviews rating IMAX • Notice that there are • 5+2=7 “noes” and • 9+2=11 “yesses”.

  15. IMAX: Calculate Frequencies likes genre critics-reviews rating IMAX • Notice that there is a parent for this node.

  16. IMAX: Include “fake” instances likes genre critics-reviews rating IMAX • Add 1 to each of the frequency counts.

  17. IMAX: Convert to CPT likes genre critics-reviews rating IMAX • Notice that there are • 5+2=7 “noes” and • 9+2=11 “yesses”.

  18. Topology of the Network • This is the network with the Conditional Probability Tables likes genre critics-reviews rating IMAX

  19. Classification • Classify • genre = action, • critics-reviews = neutral, • rating = R, • IMAX = TRUE, • likes = ? likes genre critics-reviews rating IMAX

  20. Classification • Classify • genre = action, • critics-reviews = neutral, • rating = R, • IMAX = TRUE, • likes = ? • Recall how we classify using a Bayesian network. • Find the argument (yes or no) that maximizes the probability. • argmax( Pr(yes), Pr(no) ) • = argmax( Pr (genre = action, critics-reviews = neutral, rating = R, IMAX = TRUE | likes = yes ), • Pr (genre = action, critics-reviews = neutral, rating = R, IMAX = TRUE | likes = no ) • = argmax( ( Pr (genre = action | likes = yes) * Pr(critics-reviews = neutral | likes = yes) * • Pr (rating = R | likes = yes) * Pr (IMAX = TRUE | likes = yes) * Pr (likes = yes) ) , • ( Pr(genre = action | likes = no) * Pr (critics-reviews = neutral | likes = no ) * • Pr (rating = R| likes = no) * Pr (IMAX = TRUE | likes = no ) * Pr (likes= no) ) )

  21. Classification • Pr(yes) • =Pr(genre = action, critics-reviews = neutral, rating = R, IMAX = TRUE | likes = yes ) • = Pr(genre = action | likes = yes) * Pr(critics-reviews = neutral | likes = yes) * • Pr (rating = R | likes = yes) * Pr (IMAX = TRUE | likes = yes) * Pr (likes = yes) • = likes genre critics-reviews rating IMAX

  22. Classification • Pr(no) • =Pr(genre = action, critics-reviews = neutral, rating = R, IMAX = TRUE | likes = no ) • = Pr(genre = action | likes = no) * Pr(critics-reviews = neutral | likes = no) * • Pr (rating = R | likes = no) * Pr (IMAX = TRUE | likes = no) * Pr (likes = no) • = * * * ≈ 0.021524 likes genre critics-reviews rating IMAX

  23. Classification • Thus we have the following: • argmax( Pr(yes), Pr(no) ) = argmax( 0.008609, 0.021524) • And the highest probability is for likes = no. • Classified as • genre = action, • critics-reviews = neutral, • rating = R, • IMAX = TRUE, • likes = no

  24. Classifying instances with missing values Notice we have missing values this time… We could calculate the probability of the missing values thusly: Pr(IMAX = ? | likes = no) = Pr(IMAX = FALSE | likes = no) + Pr(IMAX = TRUE | likes = no) = Since this will always be 1 (which will not alter the product we can ignore them). • Classify • genre = action, • critics-reviews = ?, • rating = R, • IMAX = ?, • likes = ? • argmax( Pr(yes), Pr(no) ) • = argmax( Pr (genre = action, rating = R | likes = yes), Pr (genre = action, rating = R | likes = no)) • = argmax( ( Pr (genre = action | likes = yes) * Pr (rating = R | likes = yes) * Pr (likes = yes) ) , • ( Pr(genre = action | likes = no) * Pr (rating = R| likes = no) * Pr (likes= no) ) ) • = argmax( , = ) = argmax( 0.056818, 0.100446 ) • Hence this instance is classified as likes = no

  25. CPT: Critics-Reviews likes genre • Notice that we have a two parents for critics-reviews: • likes • genre • The conditional probability table must reflect this. critics-reviews IMAX rating

  26. Critics-Reviews: Calculate Frequencies Ordered from left-to-right, top-to-bottom Notice that we have 2x3 number of possible parent values.

  27. Critics-Reviews: Include “fake” instances Ordered from left-to-right, top-to-bottom Add 1 to every recorded frequency.

  28. Critics-Reviews: Convert to CPT Ordered from left-to-right, top-to-bottom

More Related