<jupyter_start><jupyter_text>Results: Musk2 Scaled  MIL   stratified k fold Validation  is performed.Metrics:     - AUC     - Accuracie  Import Libraries<jupyter_code>import sys,os
import warnings
os.chdir('/Users/josemiguelarrieta/Documents/MILpy')
sys.path.append(os.path.realpath('..'))
from sklearn.utils import shuffle
import random as rand
import numpy as np
from data import load_data
warnings.filterwarnings('ignore')
from MILpy.functions.mil_cross_val import mil_cross_val

#Import Algorithms 
from MILpy.Algorithms.simpleMIL import simpleMIL
from MILpy.Algorithms.MILBoost import MILBoost
from MILpy.Algorithms.maxDD import maxDD
from MILpy.Algorithms.CKNN import CKNN
from MILpy.Algorithms.EMDD import EMDD
from MILpy.Algorithms.MILES import MILES
from MILpy.Algorithms.BOW import BOW<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>bags,labels,X = load_data('Musk2_scaled')
folds = 5
runs = 5<jupyter_output><empty_output><jupyter_text>Simple MIL [max]<jupyter_code>SMILa = simpleMIL()
parameters_smil = {'type': 'max'}
print '\n========= SIMPLE MIL RESULT [MAX] ========='
AUC = []
ACCURACIE=[]
for i in range(runs):
    print '\n run #'+ str(i)
    #Shuffle Data
    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=SMILa, folds=folds, parameters=parameters_smil, 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))<jupyter_output>========= SIMPLE MIL RESULT [MAX] =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 68.3608058608
Accuracie: 70.4461152882
Elapsed: 0.05

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 64.9221611722
Accuracie: 68.3834586466
Elapsed: 0.03

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 67.9075091575
Accuracie: 69.5889724311
Elapsed: 0.03

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 71.4652014652
Accuracie: 74.5939849624
Elapsed: 0.03

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 68.2005494505
Accuracie: 70.8947368421
Elapsed: 0.02

 MEAN AUC: 68.1712454212
 MEAN ACCURACIE: 70.7814536341<jupyter_text>Simple MIL [min]<jupyter_code>parameters_smil = {'type': 'min'}
print '\n========= SIMPLE MIL RESULT [MIN] ========='
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=SMILa, folds=folds,parameters=parameters_smil, 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))<jupyter_output>========= SIMPLE MIL RESULT [MIN] =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 68.2463369963
Accuracie: 71.64160401
Elapsed: 0.03

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 77.1611721612
Accuracie: 79.5614035088
Elapsed: 0.03

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 70.6181318681
Accuracie: 73.2556390977
Elapsed: 0.03

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 72.7655677656
Accuracie: 75.4035087719
Elapsed: 0.03

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 75.4441391941
Accuracie: 77.4035087719
Elapsed: 0.03

 MEAN AUC: 72.8470695971
 MEAN ACCURACIE: 75.4531328321<jupyter_text>Simple MIL [extreme]<jupyter_code>parameters_smil = {'type': 'extreme'}
print '\n========= SIMPLE MIL RESULT [MIN] ========='
AUC = []
ACCURACIE=[]
for i in range(runs):
    print '\n run #'+ str(i)
    #Shuffle Data
    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=SMILa, folds=folds,parameters=parameters_smil, 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))<jupyter_output>========= SIMPLE MIL RESULT [MIN] =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 76.510989011
Accuracie: 78.007518797
Elapsed: 0.05

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 81.6987179487
Accuracie: 82.5664160401
Elapsed: 0.05

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 77.8159340659
Accuracie: 79.3609022556
Elapsed: 0.05

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 80.8608058608
Accuracie: 82.313283208
Elapsed: 0.05

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 82.5915750916
Accuracie: 82.1654135338
Elapsed: 0.06

 MEAN AUC: 79.8956043956
 MEAN ACCURACIE: 80.8827067669<jupyter_text>Simple MIL [average]<jupyter_code>parameters_smil = {'type': 'average'}
print '\n========= SIMPLE MIL RESULT [AVERAGE] ========='
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=SMILa, folds=folds,parameters=parameters_smil, 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))<jupyter_output>========= SIMPLE MIL RESULT [AVERAGE] =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 76.3873626374
Accuracie: 78.1553884712
Elapsed: 0.05

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 80.1373626374
Accuracie: 82.2180451128
Elapsed: 0.03

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 81.2133699634
Accuracie: 82.2130325815
Elapsed: 0.03

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 80.8608058608
Accuracie: 82.4135338346
Elapsed: 0.03

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 72.7793040293
Accuracie: 74.350877193
Elapsed: 0.02

 MEAN AUC: 78.2756410256
 MEAN ACCURACIE: 79.8701754386<jupyter_text>Bag of Words<jupyter_code>bow_classifier = BOW() 
parameters_bow = {'k':100,'covar_type':'diag','n_iter':20}
print '\n========= BAG OF WORDS 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=bow_classifier, folds=folds,parameters=parameters_bow, 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))<jupyter_output>========= BAG OF WORDS RESULT =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 65.7417582418
Accuracie: 69.335839599
Elapsed: 31.72

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 67.5412087912
Accuracie: 70.7418546366
Elapsed: 42.54

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 65.5677655678
Accuracie: 69.7368421053
Elapsed: 55.75

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 72.4633699634
Accuracie: 75.4987468672
Elapsed: 62.19

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 70.7967032967
Accuracie: 74.5989974937
Elapsed: 49.78

 MEAN AUC: 68.4221611722
 MEAN ACCURACIE: 71.9824561404<jupyter_text>Citation KNN<jupyter_code>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))<jupyter_output>========= CKNN RESULT =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 76.0989010989
Accuracie: 78.3609022556
Elapsed: 11592.75

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 80.7967032967
Accuracie: 83.4661654135
Elapsed: 20601.28

 run #2
Fold# 0...Fold# 1...Fold# 2...<jupyter_text>Diverse Density<jupyter_code>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))<jupyter_output>========= DIVERSE DENSITY RESULT=========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 51.25
Accuracie: 62.7268170426
Elapsed: 132.95

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 52.2115384615
Accuracie: 62.7268170426
Elapsed: 417.98

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 50.0
Accuracie: 61.7744360902
Elapsed: 434.17

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 52.4542124542
Accuracie: 61.8746867168
Elapsed: 727.4

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 52.3901098901
Accuracie: 61.7318295739
Elapsed: 154.61

 MEAN AUC: 51.6611721612
 MEAN ACCURACIE: 62.1669172932<jupyter_text>EM-DD<jupyter_code>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))<jupyter_output>========= EM-DD RESULT =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 82.1932234432
Accuracie: 79.3082706767
Elapsed: 244.04

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 80.2380952381
Accuracie: 77.5037593985
Elapsed: 227.54

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 85.4807692308
Accuracie: 82.5614035088
Elapsed: 233.21

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 82.0146520147
Accuracie: 79.2080200501
Elapsed: 226.89

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 85.0
Accuracie: 81.4085213033
Elapsed: 226.29

 MEAN AUC: 82.9853479853
 MEAN ACCURACIE: 79.9979949875<jupyter_text>MILBoost<jupyter_code>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)
    ACCURACIE.append(accuracie)
print '\n MEAN AUC: '+ str(np.mean(AUC)) + '\n MEAN ACCURACIE: '+ str(np.mean(ACCURACIE))<jupyter_output>========= MILBOOST RESULT =========

 run #0
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 61.095467033
Accuracie: 39.3828443289
Elapsed: 349.56

 run #1
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 59.4963369963
Accuracie: 39.3828443289
Elapsed: 320.16

 run #2
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 77.2355769231
Accuracie: 39.3828443289
Elapsed: 302.44

 run #3
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 71.5750915751
Accuracie: 39.3828443289
Elapsed: 488.84

 run #4
Fold# 0...Fold# 1...Fold# 2...Fold# 3...Fold# 4...
AUC: 70.2220695971
Accuracie: 39.3828443289
Elapsed: 311.0

 MEAN AUC: 67.9249084249
 MEAN ACCURACIE: 39.3828443289<jupyter_text>Miles<jupyter_code>#Pending<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.206459312299545, 'fraction_numerical': 0.12269709853061833, 'mean_word_length': 4.123423767672908, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '285225', 'license': 'FSFAP', 'n_tokens_mistral': 7136, 'n_tokens_neox': 5681, 'n_words': 1185, 'path': 'results/.ipynb_checkpoints/Musk2_Results-checkpoint.ipynb', 'repo_name': 'jmarrietar/MILpy', 'size': '13407'}