Menu

[Solved]Question 7 7 Marks Algorithm Analyzes Image Produces Aprediction List Probability Values H Q37248296

Python
Question 7. (7 marks) An algorithm analyzes an image and produces aprediction: a list of probability values that the handwritQuestion 7. (7 marks) An algorithm analyzes an image and produces aprediction: a list of probability values that the handwritten digit is a number 0 to 9. For example: Input prediction [0.06, 0.01, 0.02, 0.01,0.5, 0.05, 0.01, 0.01,0.08, 0.3] → The list above indicates that the predicted digit is a 4 with a probability of 0.5 (the highest probability in the list). To determine whether the algorithm produced the correct prediction, we compare the list prediction with the correct label for the image: a list with all the values 0 except the index corresponding to the correct digit. If the label provided for the above example is [0, 0, 0, 0, 0, 0, 0, 0, 0, , then the correct digit is 9 and so the algorithm has not classified the image correctly The algorithm makes a correct classification when its highest probability digit is the same as the correct digit in the label. If there is more than one maximum probability value (i.e., there is a tie), the entry with the lowest index is assumed to be the prediction from the algorithm. a) 13 marks] Write the function is_correct which takes lists prediction and label and returns True if and only if the prediction correctly classified the digit. You are only allowed to use Python’s built-in functions (i.e. you cannot import modules) def is_correct (prediction, label): ‘”(list, list)->bool Input: two lists, prediction and label, of floating point numbers representing probability values corresponding to digits 09 Output: True only if most probable digit in prediction matches label. False, otherwise. Start here and continue on the next page Show transcribed image text Question 7. (7 marks) An algorithm analyzes an image and produces aprediction: a list of probability values that the handwritten digit is a number 0 to 9. For example: Input prediction [0.06, 0.01, 0.02, 0.01,0.5, 0.05, 0.01, 0.01,0.08, 0.3] → The list above indicates that the predicted digit is a 4 with a probability of 0.5 (the highest probability in the list). To determine whether the algorithm produced the correct prediction, we compare the list prediction with the correct label for the image: a list with all the values 0 except the index corresponding to the correct digit. If the label provided for the above example is [0, 0, 0, 0, 0, 0, 0, 0, 0, , then the correct digit is 9 and so the algorithm has not classified the image correctly The algorithm makes a correct classification when its highest probability digit is the same as the correct digit in the label. If there is more than one maximum probability value (i.e., there is a tie), the entry with the lowest index is assumed to be the prediction from the algorithm. a) 13 marks] Write the function is_correct which takes lists prediction and label and returns True if and only if the prediction correctly classified the digit. You are only allowed to use Python’s built-in functions (i.e. you cannot import modules) def is_correct (prediction, label): ‘”(list, list)->bool Input: two lists, prediction and label, of floating point numbers representing probability values corresponding to digits 09 Output: True only if most probable digit in prediction matches label. False, otherwise. Start here and continue on the next page

Expert Answer


Answer to Question 7. (7 marks) An algorithm analyzes an image and produces aprediction: a list of probability values that the han… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *