def scoreClassifications(self): total = 0 scores = [] for uid, actual in self.hand_classified_set.iteritems(): guess = self.algo_classified_set[uid] scores.append(util.score_prediction(guess, actual)) total = sum(scores) max_potential = len(self.hand_classified_set.keys()) * 6.0 unique, counts = np.unique(scores, return_counts=True) frequencies = np.asarray((unique, counts)).T return total, max_potential, frequencies
def getPredictionScoreOfTrainingSet(): """ Returns the score of the classifications on the validation set. """ hand_classified_set = loader.get_hand_classifiedset() algo_classified_set = loader.get_algo_classifiedset() total = 0 scores = [] for uid, actual in hand_classified_set.iteritems(): guess = algo_classified_set[uid] scores.append(util.score_prediction(guess, actual)) total = sum(scores) max_potential = len(hand_classified_set.keys()) * 6 return total / float(max_potential)
test = pd.read_csv(pred_file, dtype=np.int32) test['pred'] = test['ad_id'].map(ad_pos_cnt).fillna(0) / ( test['ad_id'].map(ad_cnt).fillna(0) + reg) return test ## Validating print "Running on validation split..." pred = fit_predict(val_split[0], val_split[1]) print "Scoring..." present_score, future_score, total_score = score_prediction(pred) name = gen_prediction_name('ad-mean', total_score) print " Present score: %.5f" % present_score print " Future score: %.5f" % future_score print " Total score: %.5f" % total_score pred[['display_id', 'ad_id', 'pred']].to_pickle('preds/%s-val.pickle' % name) ## Predicting print "Running on full split..." pred = fit_predict(full_split[0], full_split[1]) pred[['display_id', 'ad_id', 'pred']].to_pickle('preds/%s-test.pickle' % name)