learning with uncertainty learnem py -(continued def em_step(selforig_class_countsorig_feature_counts)"""updates the model ""class_counts [ ]*self num_classes feature_counts [{val:[ ]*self num_classes for val in feat frangefor feat in self dataset input_featuresfor tple in self dataset trainif orig_class_countsa model exists tpl_class_dist self prob(tpleorig_class_countsorig_feature_countselseinitiallywith no modelreturn random distribution tpl_class_dist random_dist(self num_classesfor cl in range(self num_classes)class_counts[cl+tpl_class_dist[clfor (ind,featin enumerate(self dataset input_features)feature_counts[ind][feat(tple)][cl+tpl_class_dist[clreturn class_countsfeature_counts prob computes the probability of class for tuple tplgiven the current statistics ( tplep(cp(xi =tple(ici class counts[cfeature counts[ ][feati (tple)][clen(self datasetclass counts[ci feature counts[ ][feati (tple)][cclass counts[ ]|feats|- the last step is because len(self datasetis constant (independent of cclass counts[ccan be taken out of the productbut needs to be raised to the power of the number of featuresand one of them cancels learnem py -(continued def prob(selftpleclass_countsfeature_counts)"""returns distribution over the classes for tuple tple in the model defined by the counts ""feats self dataset input_features unnorm [prod(feature_counts[ ][feat(tple)][cfor ( ,featin enumerate(feats)/(class_counts[ ]**(len(feats)- )for in range(self num_classes)thesum sum(unnormreturn [un/thesum for un in unnormlearn does steps of emlearnem py -(continuedversion june