def cla_filter(): aux = [] resul1 = [[], [], [], [], [], [], []] resul2 = [[], [], [], [], [], [], []] resul3 = [[], [], [], [], [], [], []] resul4 = [[], [], [], [], [], [], []] resul5 = [[], [], [], [], [], [], []] resul6 = [[], [], [], [], [], [], []] resul7 = [[], [], [], [], [], [], []] resul8 = [[], [], [], [], [], [], []] resul9 = [[], [], [], [], [], [], []] roc_m_1 = [[], [], [], [], [], [], []] roc_m_2 = [[], [], [], [], [], [], []] roc_m_3 = [[], [], [], [], [], [], []] roc_m_4 = [[], [], [], [], [], [], []] roc_m_5 = [[], [], [], [], [], [], []] roc_m_6 = [[], [], [], [], [], [], []] roc_m_7 = [[], [], [], [], [], [], []] roc_m_8 = [[], [], [], [], [], [], []] roc_m_9 = [[], [], [], [], [], [], []] SMILaMax = [simpleMIL(), {'type': 'max'}, 'MIL max', resul1, roc_m_1] SMILaMin = [simpleMIL(), {'type': 'min'}, 'MIL min', resul2, roc_m_2] SMILaExt = [ simpleMIL(), { 'type': 'extreme' }, 'MIL Extreme', resul3, roc_m_3 ] BOW_clas = [ BOW(), { 'k': 90, 'covar_type': 'diag', 'n_iter': 20 }, 'BOW', resul4, roc_m_4 ] CKNN_cla = [ CKNN(), { 'references': 3, 'citers': 5 }, 'CKNN', resul5, roc_m_5 ] maxDD_cl = [maxDD(), {}, 'DIVERSE DENSITY', resul6, roc_m_6] EMDD_cla = [EMDD(), {}, 'EM-DD', resul7, roc_m_7] MILB_cla = [MILBoost(), {}, 'MILBOOST', resul8, roc_m_8] MILES_cl = [MILES(), {}, 'MILES', resul9, roc_m_9] aux.append(SMILaMax) # aux.append(SMILaMin) # aux.append(SMILaExt) aux.append(BOW_clas) # aux.append(CKNN_cla) aux.append(maxDD_cl) # aux.append(EMDD_cla) # aux.append(MILB_cla) # aux.append(MILES_cl) return aux
def cla_filter_ipf(): aux = [] resul1 = [[],[],[],[],[],[],[]] roc_m_1 = [[],[],[],[],[],[],[]] SMILaMax = [simpleMIL(),{'type': 'max'},'MIL max',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] SMILaMin = [simpleMIL(),{'type': 'min'},'MIL min',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] SMILaExt = [simpleMIL(),{'type': 'extreme'},'MIL Extreme',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] BOW_clas = [BOW(),{'k':90,'covar_type':'diag','n_iter':20},'BOW',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] CKNN_cla = [CKNN(),{'references': 3, 'citers': 5},'CKNN',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] maxDD_cl = [maxDD(),{},'DIVERSE DENSITY',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] EMDD_cla = [EMDD(),{},'EM-DD',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] MILB_cla = [MILBoost(),{},'MILBOOST',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] # MILES_cl = [MILES(),{},'MILES',copy.deepcopy(resul1),copy.deepcopy(roc_m_1)] aux.append(SMILaMax) aux.append(SMILaMin) aux.append(SMILaExt) aux.append(BOW_clas) aux.append(CKNN_cla) aux.append(maxDD_cl) aux.append(EMDD_cla) aux.append(MILB_cla) # aux.append(MILES_cl) return aux
#Load Data #bags,labels,_ = load_data('musk1_scaled') #bags,labels,_ = load_data('musk2_scaled') #bags,labels,_ = load_data('fox_scaled') #bags,labels,_ = load_data('tiger_scaled') #bags,labels,_ = load_data('elephant_scaled') bags, labels, _ = load_data('data_gauss') #Shuffle Data bags, labels = shuffle(bags, labels, random_state=rand.randint(0, 100)) #Number of Folds folds = 5 bow_classifier = BOW() #parameters_bow = {'k':100,'covar_type':'diag','n_iter':20} parameters_bow = {'k': 10, 'covar_type': 'diag', 'n_iter': 20} accuracie, results_accuracie, auc, results_auc = mil_cross_val( bags=bags, labels=labels, model=bow_classifier, folds=folds, parameters=parameters_bow) SMILa = simpleMIL() parameters_smil = {'type': 'max'} #En este me funciono maxDD porque no tiene problem con parametros accuracie, results_accuracie, auc, results_auc, elapsed = mil_cross_val( bags=bags, labels=labels,
seed = 66 #seed = 70 #Split Data #seed= 90 #Shuffle Data bags, labels = shuffle(bags, labels, random_state=rand.randint(0, 100)) train_bags, test_bags, train_labels, test_labels = cross_validation.train_test_split( bags, labels, test_size=0.1, random_state=seed) ################ #Bags Of Words # ################ bow_classifier = BOW() #bow_classifier.fit(train_bags, train_labels,k=100,covar_type = 'diag',n_iter = 20) bow_classifier.fit(train_bags, train_labels, k=10, covar_type='diag', n_iter=20) predictions = bow_classifier.predict(test_bags) accuracie = np.average(test_labels.T == np.sign(predictions)) print '\n Accuracy: %.2f%%' % (100 * accuracie) fpr, tpr, thresholds = metrics.roc_curve(test_labels, predictions, pos_label=1.) metrics.auc(fpr, tpr) #####################