i want to normalize these ingredients values to range of 0,1 my question is how to pass how dictionary to function? and recieving as a arguments
sample code
def normalize(d, target=1.0):
raw = sum(d.values())
factor = target/raw
return {key:value*factor for key,value in d.iteritems()}
Use it like this:
>>> data = {'a': 0.2, 'b': 0.3, 'c': 1.5}
>>> normalize(data)
{'b': 0.15, 'c': 0.75, 'a': 0.1}
"""ho wto aplly sample code on my data, i want to normalize these ingredients values to range of 0,1 my question is how to pass how dictionary to function?
Ingredients={}
Ingredients={'Beef':{'Achari Qeema':1000,'Afghani Kebab':1000,'Aloo Gosht':0,'Beef Chilli':500,'Beef Fried Rice':340,'Beef Patties':1000,'Beef Qorma':1000,'Behari Boti':500},
'Rice':{'Beef Fried Rice':200},
'Salt':{'Achari Qeema':10,'Afghani Kebab':17,'Aloo Gosht':17,'Beef Chilli':0,'Beef Fried Rice':0,'Beef Patties':17,'Beef Qorma':17,'Behari Boti':4},
'Oil':{'Afghani Kebab':200,'Aloo Gosht':74,'Beef Chilli':111,'Beef Fried Rice':41,'Beef Patties':41,'Beef Qorma':41,'Behari Boti':41},
'Ghee':{'Achari Qeema':110},
'Garlic':{'Behari Boti':15},
'Onion':{'Achari Qeema':115,'Afghani Kebab':130,'Aloo Gosht':130,'Beef Patties':65,'Beef Qorma':260,'Behari Boti':65},
'eggs':{'Beef Chilli':30,'Beef Fried Rice':50,'Beef Patties':100},
'yogurt':{'Achari Qeema':245,'Beef Qorma':368,'Behari Boti':245},
'ginger':{'Achari Qeema':15,'Aloo Gosht':15,'Beef Chilli':15,'Beef Qorma':15,'Behari Boti':15},
'spring onions':{'Beef Chilli':45,'Beef Fried Rice':30},
'Tomatoes':{'Afghani Kebab':1000},
'Potatoes':{'Aloo Gosht':480,'Beef Patties':1000},
'Green chillies':{'Afghani Kebab':40,'Aloo Gosht':12,'Beef Chilli':80,'Beef Patties':4},
'chicken stock':{'Behari Boti':450}}