print "working on example", datum_id if data_iter.next( compute_pattern_times=True, max_template_length=classifier.window[1]): pattern_times = data_iter.pattern_times num_detections = data_iter.E.shape[1] - classifier.window[1] num_frames += data_iter.E.shape[1] scores = -np.inf * np.ones(num_detections) for d in xrange(num_detections): E_segment = data_iter.E[:,d:d+classifier.window[1]].copy() esp.threshold_edgemap(E_segment,.30,edge_feature_row_breaks,report_level=False,abst_threshold=abst_threshold) esp.spread_edgemap(E_segment,edge_feature_row_breaks,edge_orientations,spread_length=3) if classifier_flat.score_no_bg(E_segment[:,:classifier_flat.window[1]]) > flat_threshold: scores[d] = classifier.score_no_bg(E_segment) # now we get the indices sorted indices = cl.remove_overlapping_examples(np.argsort(scores)[::-1], classifier.window[1], int(allowed_overlap*classifier.window[1])) positives, negatives = cl.get_pos_neg_scores(indices,pattern_times, scores,classifier.window[1]) all_positives.extend(positives) all_negatives.extend(negatives) else: break aar_def_roc,aar_def_roc_vals = cl.get_roc(np.sort(all_positives)[::-1], np.sort(all_negatives)[::-1],num_frames) np.save('aar_def_roc_vals052112',aar_def_roc_vals)
classifier.window[1], int(allowed_overlap*classifier.window[1])) neg_idx2 = np.empty(scores.shape[0],dtype=bool) neg_idx2[neg_indices_non_overlap] =True neg_indices_full = np.logical_and(neg_indices,neg_idx2) neg_idx2 = np.empty(scores.shape[0],dtype=bool) neg_idx2[neg_indices_counts_non_overlap] =True neg_indices_coarse = np.logical_and(neg_indices,neg_idx2) all_positive_scores.extend(pos_scores) all_positive_counts.extend(pos_counts) all_negative_scores.extend(scores[neg_indices_full]) all_negative_counts.extend(coarse_scores[neg_indices_coarse]) else: break like_roc = cl.get_roc(np.sort(all_positive_scores)[::-1], np.sort(all_negative_scores)[::-1], num_frames) count_roc = cl.get_roc(np.sort(all_positive_counts)[::-1], np.sort(all_negative_counts)[::-1], num_frames) np.save(root_path+'Experiments/061112/aar_mix2_like_roc061112',count_roc[1]) np.save(root_path+'Experiments/061112/aar_mix2_like_roc061112',like_roc[1]) del bm2 bm4 = bem.Bernoulli_Mixture(2,registered_examples_aar) bm4.data_mat = root_path + 'Experiments/053112/registered_aar060712.npy'
scores_adapt_bg, classifier.window[1]) positives_coarse, negatives_coarse = cl.get_pos_neg_scores(indices_coarse, pattern_times, coarse_scores, classifier.window[1]) all_positives.extend(positives) all_negatives.extend(negatives) all_positives_adapt_bg.extend(positives_adapt_bg) all_negatives_adapt_bg.extend(negatives_adapt_bg) all_positives_coarse.extend(positives_coarse) all_negatives_coarse.extend(negatives_coarse) else: break aar_roc,aar_roc_vals = cl.get_roc(np.sort(all_positives)[::-1], np.sort(all_negatives)[::-1],num_frames) aar_roc_adapt_bg,aar_roc_vals_adapt_bg = cl.get_roc(np.sort(all_positives_adapt_bg)[::-1], np.sort(all_negatives_adapt_bg)[::-1],num_frames) aar_roc_coarse,aar_roc_vals_coarse = cl.get_roc(np.sort(all_positives_coarse)[::-1], np.sort(all_negatives_coarse)[::-1],num_frames) np.save('aar_roc_vals052112',aar_roc_vals) np.save('aar_roc_vals_adapt_bg052112',aar_roc_vals_adapt_bg) np.save('aar_roc_vals_coarse052112',aar_roc_vals_coarse) # threshold is going to be 1000 pos = np.sort(all_positives)[::-1] neg = np.sort(all_negatives)[::-1] num_frames = float(num_frames) roc_vals = np.zeros(len(pos)) cur_neg_idx = 0