Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Now that we have defined the similarity between two stimuli, we can take a look at the equation for the context model. In the definition
Now that we have defined the similarity between two stimuli, we can take a look at the equation for the context model. In the definition below, you can think of category A as being the safe buttons, and category B as being the unsafe buttons The context model, which gives the probability that a novel stimulus x belongs to category A (as opposed to category B) is given by: where S , a) s the sum over the s milarity of x to all exemplars a n category A all exemplars b in category B and S(x, b) is the sum over the similarity of x to beB Note that because PAlx) is a probability, we can easily compute from it the probability that x belongs to category B. The stimulus must belong to one of the two categories, thus PB1x) = 1-PAlx) Let's work through an example of this. Suppose there is one test stimulus x = [ 1.0. I l. and four exemplars al 10.001 and a2-10.0. I ] (which have category labels of A) and bl = [1, 1, 1 ] and = [0.1, 1] (which have category labels of B). Then: S(x, a S(x, a2) PAIX) = where S is the similarity function that we defined above and implemented in calculate_similarity Write code that uses your function calculate similarity to implement a version of the context model (i.e., computes the Complete the function context model with your solution. In [ def context_model(test stimuli, exemplars, exemplar categories, theta-0.1) ""Computes the probability that each test stimulus belongs to category A Note: your solution can be done in 7 lines of code, including the return statement Parameters test_stimulinumpy array with shape (n, m) n stimuli, each with m features, to be classified (i.e compute P(Ax) for each x) k exemplars, each with m features Categories for the k exemplars. You can assume the values of exemplars numpy array with shape (k, m) exemplar_categories numpy string array with shape (k,) exemplar_categories will always be either be "A" or "B" theta:(optional) float A parameter to pass to the similarity function Returns numpy array with shape (n,) such that the ith element corresponds to P(Altest stimulifi]) # YOUR CODE HERE Now that we have defined the similarity between two stimuli, we can take a look at the equation for the context model. In the definition below, you can think of category A as being the safe buttons, and category B as being the unsafe buttons The context model, which gives the probability that a novel stimulus x belongs to category A (as opposed to category B) is given by: where S , a) s the sum over the s milarity of x to all exemplars a n category A all exemplars b in category B and S(x, b) is the sum over the similarity of x to beB Note that because PAlx) is a probability, we can easily compute from it the probability that x belongs to category B. The stimulus must belong to one of the two categories, thus PB1x) = 1-PAlx) Let's work through an example of this. Suppose there is one test stimulus x = [ 1.0. I l. and four exemplars al 10.001 and a2-10.0. I ] (which have category labels of A) and bl = [1, 1, 1 ] and = [0.1, 1] (which have category labels of B). Then: S(x, a S(x, a2) PAIX) = where S is the similarity function that we defined above and implemented in calculate_similarity Write code that uses your function calculate similarity to implement a version of the context model (i.e., computes the Complete the function context model with your solution. In [ def context_model(test stimuli, exemplars, exemplar categories, theta-0.1) ""Computes the probability that each test stimulus belongs to category A Note: your solution can be done in 7 lines of code, including the return statement Parameters test_stimulinumpy array with shape (n, m) n stimuli, each with m features, to be classified (i.e compute P(Ax) for each x) k exemplars, each with m features Categories for the k exemplars. You can assume the values of exemplars numpy array with shape (k, m) exemplar_categories numpy string array with shape (k,) exemplar_categories will always be either be "A" or "B" theta:(optional) float A parameter to pass to the similarity function Returns numpy array with shape (n,) such that the ith element corresponds to P(Altest stimulifi]) # YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started