コード例 #1
0
ファイル: fun_aux.py プロジェクト: jcarlosorte/pyMIL-BNF
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
コード例 #2
0
ファイル: IPF.py プロジェクト: jcarlosorte/pyMIL-BNF
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
コード例 #3
0
 #        AUC.append(auc)
 #        ACCURACIE.append(accuracie)
 #    print '\n MEAN AUC: '+ str(np.mean(AUC)) + '\n MEAN ACCURACIE: '+ str(np.mean(ACCURACIE))
 #    maxDD_classifier = maxDD()
 #    print '\n========= DIVERSE DENSITY 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.ravel(), model=maxDD_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))
 emdd_classifier = EMDD()
 print '\n========= EM-DD 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.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)
コード例 #4
0
ファイル: example.py プロジェクト: jcarlosorte/pyMIL-BNF
#######
#MAXDD#
#######
maxdd_classifier = maxDD()
maxdd_classifier.fit(train_bags=train_bags,
                     train_labels=train_labels)  #Train Classifier
predictions, out = maxdd_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, out, pos_label=1.)
metrics.auc(fpr, tpr)

######
#EMDD#
######
emdd_classifier = EMDD()
emdd_classifier.fit(train_bags=train_bags,
                    train_labels=train_labels)  #Train Classifier
predictions, out = emdd_classifier.predict(test_bags)
#Metrics
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