コード例 #1
0
#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,
    model=SMILa,
    folds=folds,
    parameters=parameters_smil,
    timer=True)

parameters_smil = {'type': 'min'}
コード例 #2
0
 #        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)
     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))
コード例 #3
0
ファイル: prueba2.py プロジェクト: jcarlosorte/pyMIL-BNF
from MILpy.Algorithms.EMDD import EMDD
from MILpy.Algorithms.MILES import MILES
from MILpy.Algorithms.BOW import BOW

bags, labels, X = load_data('musk2_scaled')
folds = 5
runs = 1
print(labels)

cknn_classifier = CKNN()
parameters_cknn = {'references': 3, 'citers': 5}
print '\n========= CKNN 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=cknn_classifier,
        folds=folds,
        parameters=parameters_cknn,
        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))