Homework /681: Artificial Intelligence (Fall 2017) Out: October 18, 2017 Due: October 29, 2017 at 11:59PM

Similar documents
Self assessment due: Monday 10/29/2018 at 11:59pm (submit via Gradescope)

Homework 1 (a and b) Convex Sets and Convex Functions

Homework 3. Constraint Satisfaction Problems, Optimization problems

15-110: Principles of Computing, Spring 2018

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills

CS 241 Data Organization using C

CS 343: Artificial Intelligence

15-110: Principles of Computing, Spring 2018

CSCI544, Fall 2016: Assignment 2

15-110: Principles of Computing, Spring 2018

CSCI544, Fall 2016: Assignment 1

3. When you process a largest recent earthquake query, you should print out:

HMC CS 158, Fall 2017 Problem Set 3 Programming: Regularized Polynomial Regression

Warm-up as you walk in

Due: March 8, 11:59pm. Project 1

: Principles of Imperative Computation. Fall Assignment 5: Interfaces, Backtracking Search, Hash Tables

6.1 Skip List, Binary Search Tree

Graphical models are a lot like a circuit diagram they are written down to visualize and better understand a problem.

10708 Graphical Models: Homework 2

Bayesian Networks. A Bayesian network is a directed acyclic graph that represents causal relationships between random variables. Earthquake.

CS 188: Artificial Intelligence

Homework #4 RELEASE DATE: 04/22/2014 DUE DATE: 05/06/2014, 17:30 (after class) in CSIE R217

Inference. Inference: calculating some useful quantity from a joint probability distribution Examples: Posterior probability: Most likely explanation:

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Approximate (Monte Carlo) Inference in Bayes Nets. Monte Carlo (continued)

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Fall 2017

CMPSCI 187 / Spring 2015 Sorting Kata

Lecture 1. Course Overview, Python Basics

CMPSCI 187 / Spring 2015 Hanoi

15-213/18-213/15-513, Spring 2018 C Programming Lab: Assessing Your C Programming Skills

Problem Set 2. General Instructions

ECE 467 Section 201 Network Implementation Laboratory

Fall 2017: Numerical Methods I Assignment 1 (due Sep. 21, 2017)

CIS 520, Machine Learning, Fall 2015: Assignment 7 Due: Mon, Nov 16, :59pm, PDF to Canvas [100 points]

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Project 1 (document version 1.3) Process Simulation Framework

Homework 2 (by Ao Zeng) Solutions Due: Friday Sept 28, 11:59pm

COMP 3331/9331: Computer Networks & Applications Programming Assignment 2 for Session 1, 2016

COMP 3331/9331: Computer Networks & Applications. Programming Assignment 2: Link State Routing

Statistical Techniques in Robotics (STR, S15) Lecture#06 (Wednesday, January 28)

6.825 Project 2. Due: Thursday, Nov. 4 at 5PM Submit to: box outside of Tomas office (32-D542)

Project 2 Reliable Transport

To earn the extra credit, one of the following has to hold true. Please circle and sign.

Homework 6: Pose Tracking EE267 Virtual Reality 2018

COSC 115: Introduction to Web Authoring Fall 2013

Review I" CMPSCI 383 December 6, 2011!

Homework Spring 2019

CSE Theory of Computing Fall 2017 Project 3: K-tape Turing Machine

Final Exam. Introduction to Artificial Intelligence. CS 188 Spring 2010 INSTRUCTIONS. You have 3 hours.

Welcome to CS 241 Systems Programming at Illinois

CMSC 132: Object-Oriented Programming II. Administrivia

CMSC 201 Fall 2016 Homework 6 Functions

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

CMPSCI 187 / Spring 2015 Hangman

CS264: Homework #1. Due by midnight on Thursday, January 19, 2017

CS348 FS Solving NP-Complete Light Up Puzzle

CSCI 1301: Introduction to Computing and Programming Spring 2018 Project 3: Hangman 2.0 (A Word Guessing Game)

15-110: Principles of Computing, Spring Problem Set 3 (PS3) Due: Friday, February 9 by 2:30PM on Gradescope

Graphical Models. David M. Blei Columbia University. September 17, 2014

Homework 1: Getting Started with WebGL and Transformations EE267 Virtual Reality 2018

Lecture 1. Course Overview, Python Basics

COSC 115A: Introduction to Web Authoring Fall 2014

CS 323 Lecture 1. Design and Analysis of Algorithms. Hoeteck Wee

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

CS 157 Design and Analysis of Algorithms Valiant. Homework 3

10-701/15-781, Fall 2006, Final

Project 2: Web Security

Due: Fri, Sept 15 th, 5:00 p.m. Parallel and Sequential Data Structures and Algorithms (Fall 17)

ECE573 Introduction to Compilers & Translators

15-122: Principles of Imperative Computation, Spring 2013

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

CS451 - Assignment 3 Perceptron Learning Algorithm

Homework 3: Recursion Due: 11:59 PM, Sep 25, 2018

INFS 2150 (Section A) Fall 2018

Unit: Rational Number Lesson 3.1: What is a Rational Number? Objectives: Students will compare and order rational numbers.

Distributed: Monday, Nov. 30, Due: Monday, Dec. 7 at midnight

Data Structures and Algorithms

BigML homework 6: Efficient Approximate PageRank

Introduction to Algorithms: Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4

CS264: Homework #4. Due by midnight on Wednesday, October 22, 2014

Data Structure and Algorithm Homework #3 Due: 1:20pm, Thursday, May 16, 2017 TA === Homework submission instructions ===

10605 BigML Assignment 1(b): Naive Bayes with Hadoop API

You must pass the final exam to pass the course.

CSE100 Principles of Programming with C++

General Instructions. Questions

San José State University Computer Science Department CS49J, Section 3, Programming in Java, Fall 2015

Data Structures and OO Development II

15-122: Principles of Imperative Computation, Spring 2018

EECE.2160: ECE Application Programming Spring 2019

CS2630: Computer Organization Project 2, part 1 Register file and ALU for MIPS processor Due July 25, 2017, 11:59pm

Homework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018

1 Lab + Hwk 5: Particle Swarm Optimization

CSCI4211: Introduction to Computer Networks Fall 2017 Homework Assignment 1

15-110: Principles of Computing, Spring Problem Set 2 (PS2) Due: Friday, February 2 by 2:30PM on Gradescope

San José State University Department of Computer Science CS049J, Programming in Java, Section 2, Fall, 2016

CMPE012 Computer Engineering 12 (and Lab) Computing Systems and Assembly Language Programming. Summer 2009

Homework 3: Relational Database Design Theory (100 points)

Project #1: Tracing, System Calls, and Processes

Transcription:

Homework 2 15-381/681: Artificial Intelligence (Fall 2017) Out: October 18, 2017 Due: October 29, 2017 at 11:59PM Homework Policies Homework is due on Autolab by the posted deadline. Assignments submitted past the deadline will incur the use of late days. You have 6 late days, but cannot use more than 2 late days per homework. No credit will be given for homework submitted more than 2 days after the due date. After your 6 late days have been used you will receive 20% off for each additional day late. You can discuss the exercises with your classmates, but you should write up your own solutions. If you find a solution in any source other than the material provided on the course website or the textbook, you must mention the source. All homeworks (programming and theoretical) are always submitted individually. Strict honor code with severe punishment for violators. CMUs academic integrity policy can be found here. You may discuss assignments with other students as you work through them, but writeups must be done alone. No downloading / copying of code or other answers is allowed. If you use a string of at least 5 words from some source, you must cite the source. Submission For the written portion, please submit your solutions as a pdf to Gradescope. For the programming portion, please create a tar archive containing just sampling.py, and submit it to Autolab. The programming portion will be autograded. 1 Part 1: Written [50 Points] 1.1 Hosting Tournament [7 Points] You are hosting a tournament with n players in a circle. You want to make a binary random generator that gives X belonging to X {left, right}. Each round, every person in the circle will simultaneously flip the random generator and turn to their X side. A match happens when two players are facing each other. For each match, the person who flipped right will leave the circle. Then, the next round begins. The tournament continues until there is only 1 player left. 1. What s the probability you want to assign to X if you want the tournament to end fast? Explain. (Hint: you want to maximize the expected number of matches). 1

1.2 Bayes Net Independence [9 Points] Using the above Bayes net, determine whether the following statement is True or False. Explain your answers. 1. P (A, F C, H, K) = P (A C, H, K)P (F C, H, K) 2. P (E, F D, I, J) = P (E D, I, J)P (F D, I, J) 3. P (E, F B, I, K) = P (E B, I, K)P (F B, I, K) 1.3 The Burglar Scenario [14 Points] 1. (8 points) Enumerate all the 2 5 joint probabilities of the five variables in the above Burglary/Earthquake Bayes Net. Compute conditional probabilities P (b, e a), P (b, e a), P (b a), P (e a) and marginals P (A), P (M), P (J), where capital letter means Variable, and small letter means the variable is True (e.g. A = a) or False (e.g. A = a). 2. (6 points) Consider the Burglary/Earthquake Bayes Net given, when no evidence is given, the Burglary and Earthquake variables are independent. However, if we observe Alarm = true, things change. In particular, Burglary and Earthquake are no longer conditionally independent. Explain why. Justify your answer by computing the appropriate probabilities involved. For example, you may want to evaluate P (B, E a), P (B a), P (E a). 2

1.4 Approximate Inference of the Bayes Nets [20 Points] The objective is to experiment with the sampling algorithms you implemented in Part 2 so as to understand their utilities, strengths and limitations. You can work on this section concurrently as you work on the programming assignment the solutions here can help you check your work. Mid-term Net Consider the Bayes Net you have considered in the midterm. The conditional tables of the mid-term net has been coded in the required input format for you in Part 2 so that you can apply the appropriate sampling algorithms to perform approximate inference. 1. (5 points) Compute the probabilities of P (d c), P (b c), and P (d a, b) by enumeration. Then, employ rejection sampling, likelihood weighting, and Gibb s sampling to approximate them. Use 1000 samples, and document your results below. How do the approximations and the actual values compare? 2. (5 points) Next, we focus on P (d c). We know that the accuracy of the approximation depends on the number of samples used. For each of the three sampling methods, plot the probability as a function of the number of samples used. Do you notice large differences in the convergence rates among the methods? 3. (5 points) Construct a query on this Bayes Net such that the convergence and effectiveness of rejection sampling is noticeably worse than that of likelihood weighting and Gibb s sampling. List the query you are using, and provide the probability plot as a function of samples used. Why is it the case that rejection sampling is noticeably worse for this query? Burglary Net Consider the Burglary Net from Question 1.3 above. 1. (5 points) Code the Burglary Bayes Net conditional tables into the required input format for Part 2 s program. Employ rejection sampling, likelihood weighting, and Gibb s sampling to approximate P (e A), P (b a), and P (A). Use 1000 samples, and document your results below. How do the approximations and the actual values compare? 3

2 Part 2: Sampling: Programming [50 Points] 2.1 The Problem Your task here is to implement three types of sampling techniques to perform approximate inference on any given Bayes Net: Rejection Sampling, Likelihood Sampling, and Gibbs Sampling. You will employ these algorithms to answer the written Question 1.4 above. An example Bayes Net is given in the midterm, which we called Midterm Net: You will develop codes to compute conditional probabilities, such as P (d), P (d c), P (b c), or P (d a, b), where d = (D=T) = (+D) in our convention. Note that we only have one query variable, and an arbitrary number of evidence variables. 2.2 Format Please use Python 2.7 to complete this assignment, in a file named sampling.py. We have given you some starter code (in the Autolab handout) that provides a working solution for direct sampling (ignores evidence variables). In this file, please fill in the three methods, one for each sampling technique. The specifics of what each line of the input and output should be is described below. 2.2.1 Input The format of the input file is as follows: 1. The first line of every file contains the names of all nodes in the graph, in topological (& lexicographical) order. 2. The lines that follow until the first blank line contain conditional probabilities to describe the local tables of the Bayes Net. These will always be given to describe the distribution in topological (lexicographical) order. Each line contains zero or more conditions (denoted by a +/- followed by a variable name, then a space), the dependent variable (denoted with just the variable name and a space), then the probability as a float. 3. Finally, after a single empty line, the file will contain a single query, which asks the probability of a particular variable, given the evidence that follows. For example, the input file for the above (midterm) example would look like the following: A B C D A 0.0 B 0.9 +A +B C 0.2 +A -B C 0.6 4

-A +B C 0.5 -A -B C 0.0 +B +C D 0.75 +B -C D 0.1 -B +C D 0.5 -B -C D 0.2 D +C The sign of the variable that you have to compute is al- Note that the query corresponds to P (D C). ways positive. 2.2.2 Output Please print your output to stdout. For each test case, print a single floating point number. corresponding test case. This number should represent the value of the 2.3 Method Please refer to the textbook or lectures for implementation details with regards to each sampling technique. If needed, you can compute the conditional probability of a variable given its Markov blanket using the following equation (taken from 14.12 in the book): P (x i mb(x i)) = αp (x i parents(x i)) Y j Children(X i) P (y j parents(y j )) In each sampling method, make sure to follow the topological variable order. A specific random.seed(10000) has been provided in the starter code, please keep this seed when you are submitting to autolab. Additionally, you should only generate random assignments using the sample function provided; this is to help ensure the random samples generated will be identical to that of the autograder. For Gibb s sampling, please initialize all non-evidence variables to True. 2.4 Testing You are encouraged to manually test your code with the results you calculate from problem 1.4. To run your code, you should run python sampling.py <filename> <trials> <sampling type>. trials refers to the number of samples you want to generate, and sampling type can be 0,1,2, or 3 depending on which sampling method you want to use. When you submit to Autolab, we will compare your results with the results generated from the reference solution on several different Bayes Nets and queries. Because we have provided the specific random seed, we expect the output to be nearly identical to the reference output (we will check up to 5 decimal places). If you find that your code seems to be working correctly (i.e. correct answers from section 1.4) but the autograder is not passing, be sure that you are looping through the variables in topological order. If you think it is some precision error in Python, please post on Piazza. The Autolab tests will generate your final score. There are currently no restrictions on the number of Autolab submissions. 2.5 Submission Please submit to Autolab a tar file that contains the file named sampling.py and README.txt. The README.txt file should contain anyone that you ve collaborated with in this assignment. To create a tar file, you may run the following command on the same directory as your sampling.py and README.txt files: tar cvzf handin.tar sampling.py README.txt Please submit your written section to Gradescope. 5