def predictions(dataframe,models): """we assume model has been trained; we also assume that the mapper has been under modifys""" mods = dataframe['module_category'].unique() dataframe['predictions']=5 for each_mod in mods: cats = dataframe[dataframe['module_category']==each_mod]['component_category'].unique() for each_cat in cats: key =(each_mod,each_cat) if key in models[0]: A,mu,sigma = models[0][key] #A*np.exp(-(x-mu)**2/(2.*sigma**2)) dataframe[(dataframe['module_category']==each_mod) \ & (dataframe['component_category']==each_cat)]['predictions'] = \ A*np.exp(-(dataframe[(dataframe['module_category']==each_mod) \ & (dataframe['component_category']==each_cat)]['time'] - mu)**2/(2.*sigma**2)) dataframe['predictions'].round() return dataframe
def gauss(x, *p): A, mu, sigma = p return A*np.exp(-(x-mu)**2/(2.*sigma**2))