Example #1
0
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
Example #2
0
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
Example #3
0
 for i in range(runs):
     #        print '\n run #'+ str(i)
     bags, labels = shuffle(bags, labels, random_state=rand.randint(0, 100))
     accuracie, results_accuracie, auc, results_auc, elapsed = mil_cross_val(
         bags=bags,
         labels=labels.ravel(),
         model=emdd_classifier,
         folds=folds,
         parameters={},
         timer=True)
     #        print '\n'+'AUC: ' + str(auc)+'\n'+'Accuracie: '+ str(accuracie)+'\n'+'Elapsed: '+ str(round(elapsed,2))
     AUC.append(auc)
     ACCURACIE.append(accuracie)
 print '\n MEAN AUC: ' + str(np.mean(AUC)) + '\n MEAN ACCURACIE: ' + str(
     np.mean(ACCURACIE))
 milboost_classifier = MILBoost()
 print '\n========= MILBOOST RESULT ========='
 AUC = []
 ACCURACIE = []
 for i in range(runs):
     #        print '\n run #'+ str(i)
     bags, labels = shuffle(bags, labels, random_state=rand.randint(0, 100))
     accuracie, results_accuracie, auc, results_auc, elapsed = mil_cross_val(
         bags=bags,
         labels=labels,
         model=milboost_classifier,
         folds=folds,
         parameters={},
         timer=True)
     #        print '\n'+'AUC: ' + str(auc)+'\n'+'Accuracie: '+ str(accuracie)+'\n'+'Elapsed: '+ str(round(elapsed,2))
     AUC.append(auc)
Example #4
0
accuracie = np.average(test_labels.T == np.sign(predictions))
print '\n Accuracy: %.2f%%' % (100 * accuracie)
fpr, tpr, thresholds = metrics.roc_curve(test_labels, 1 - out, pos_label=1.)
metrics.auc(fpr, tpr)

##########
#MILBoost#
##########
#Nota Importante:  Solo Funciona Con musk1 original.
#Load Data
bags, labels, _ = load_data('musk1_original')  #Musk1 Original
seed = 90
train_bags, test_bags, train_labels, test_labels = cross_validation.train_test_split(
    bags, labels, test_size=0.1, random_state=seed)

milboost_classifier = MILBoost()
milboost_classifier.fit(train_bags, train_labels)
out = milboost_classifier.predict(test_bags)
fpr, tpr, thresholds = metrics.roc_curve(test_labels, out, pos_label=1.)
metrics.auc(fpr, tpr)

#######
#MILES#
#######
bags, labels, _ = load_data('data_gauss')  #Gaussian data
seed = 66
train_bags, test_bags, train_labels, test_labels = cross_validation.train_test_split(
    bags, labels, test_size=0.1, random_state=seed)

#Miles, sobre el entrenaod y probado en el training bueno,
#Me hace pensar que depende mucho de datos de entrenamiento