Question: + Code Exercise 3 (2 points). Complete the function, def ingredient_vector(a, rules): so that it returns the ingredient vector for the ingredient named a, using
+ Code Exercise 3 (2 points). Complete the function, def ingredient_vector(a, rules): so that it returns the ingredient vector for the ingredient named a, using the confidence rules in rules. For example, assert ingredient_vector('lemon', rules) - { 'white wine': 0.027093596059113302, salmon fillets': 0.0090311986863711, 'pesto': 0.004105090311986864, saffron': 0.010673234811165846, {'graham cracker crumbs': 0.1, } # 45 key-value pairs If there are no rules conf(a => b), then the function should return an empty dictionary. def ingredient_vector(a, rules): from collections import defaultdict assert isinstance(a, str) assert isinstance(rules, dict) or isinstance (rules, defaultdict) *** YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
