Exemple #1
0
# coding: utf-8
import numpy as np
from runner import Runner
from mlcin.prototypes.rps import RandomPrototypeSelection
from mlcin.utils.keel import load_dataset
from mlcin.utils.graphics import plot_and_save




if __name__ == '__main__':

    # creating prototype generation object
    rps = RandomPrototypeSelection()

    datasets = ['banana', 'normal', 'normal_multimodal']
    for dataset in datasets:
        X_orig, y_orig = load_dataset('datasets/artificial/' + dataset + '.data')
        y_orig = np.asarray(y_orig, dtype=int)
        
        rps.fit(X_orig, y_orig)
        X, y = rps.reduce_data()

        print dataset + '\treduction: %.2f' % (1.0 - float(y.shape[0])/len(y_orig))
        plot_and_save(X_orig, y_orig, title='ORIGINAL', filename='images/ORIG_' + dataset + '.png')
        plot_and_save(X, y, title='RSP', filename='images/RSP_' + dataset + '.png')
    

Exemple #2
0
        X_orig, y_orig = load_dataset('datasets/artificial/' + dataset + '.data')
        y_orig         = np.asarray(y_orig, dtype=int)
        
        
        for iteration in iterations:

            enpc = ENPC( X_orig, y_orig, 3, iteration )
            enpc.run_ENPC()
            X, y = enpc.getResult()
    
    
            path = '../images'
            if not os.path.exists( path ):
                os.mkdir( path )
    
            path = '../images/' + dataset
            if not os.path.exists( path ):
                os.mkdir( path )
    
            path = '../images/' + dataset + '/iterations ' + str( iteration )
            if not os.path.exists( path ):
                os.mkdir( path )
    
            f = open( path + '/reduction.txt', 'w' )
            f.write( dataset + '\treduction: %.2f' % ( 1.0 - float(y.shape[0])/len(y_orig) ) )
            f.close()
            
            plot_and_save(X_orig, y_orig, title='ORIGINAL', filename=path + '/ORIG_' + dataset + '.png')
            plot_and_save(X     , y     , title='ENPC'    , filename=path + '/ENPC_' + dataset + '.png')

Exemple #3
0
from mlcin.prototypes.sgp import SGP
from mlcin.prototypes.tomek_links import TomekLinks





if __name__ == '__main__':


    datasets = ['banana', 'normal', 'normal_multimodal']
    for dataset in datasets:
        X_orig, y_orig = load_dataset('datasets/artificial/' + dataset + '.data')
        y_orig = np.asarray(y_orig, dtype=int)
        
        plot_and_save(X_orig, y_orig, title='ORIGINAL', filename='images/ORIG_' + dataset + '.png')
            # creating prototype generation object
            
        for mode in range(1,3):
            title = ""
            if mode == 1:
                rps = ReductionBySpacePartitioning1(b=30)
                title = "ReductionBySpacePartitioning 1 - b =30"
            elif mode == 2:
                rps = ReductionBySpacePartitioning2(b=30)
                title = "ReductionBySpacePartitioning 2 - b =30"
            elif mode == 3:
                rps = ReductionBySpacePartitioning3()  
                title = "ReductionBySpacePartitioning  3"
            elif mode == 4:
                rps = CNN()
Exemple #4
0
import numpy as np
from runner import Runner
from mlcin.prototypes.rps import RandomPrototypeSelection
from mlcin.utils.keel import load_dataset
from mlcin.utils.graphics import plot_and_save

if __name__ == '__main__':

    # creating prototype generation object
    rps = RandomPrototypeSelection()

    datasets = ['banana', 'normal', 'normal_multimodal']
    for dataset in datasets:
        X_orig, y_orig = load_dataset('datasets/artificial/' + dataset +
                                      '.data')
        y_orig = np.asarray(y_orig, dtype=int)

        rps.fit(X_orig, y_orig)
        X, y = rps.reduce_data()

        print dataset + '\treduction: %.2f' % (1.0 -
                                               float(y.shape[0]) / len(y_orig))
        plot_and_save(X_orig,
                      y_orig,
                      title='ORIGINAL',
                      filename='images/ORIG_' + dataset + '.png')
        plot_and_save(X,
                      y,
                      title='RSP',
                      filename='images/RSP_' + dataset + '.png')