Exemplo n.º 1
0
#!/usr/bin/env python
'''
Created on Aug 31, 2012

@author: masumadmin
'''
from PCA import PCA
from Utility import read_data

if __name__ == '__main__':    
    pca= PCA(3)    
    pca.train(read_data('data/iris_sans_class.arff'))   
    
    print "ev1: ",pca.eigenvalues[0]
    print "ev2: ",pca.eigenvalues[1]
    print "ev3: ",pca.eigenvalues[2] 
    print pca.principal_components
    print pca.reduce([0.36158967923198376, -0.08226888783524387, 0.8565721047950943, 0.35884392603772075])
    print pca.expand([1.0, -7.091680853665849e-10, -1.7341683644644945e-13])
    print "OK"
Exemplo n.º 2
0
'''
Created on Sep 11, 2012

@author: masumadmin
'''

from Utility import read_data
from LinearRegression import LinearRegression

if __name__ == '__main__':    
    lr= LinearRegression()    
    lr.train(read_data('data/linear_in.arff'), read_data('data/linear_out.arff'))   
    y = lr.predict([1,1,1])
    print "y1: ", y[0]
    print "y2: ", y[1]
    
    
Exemplo n.º 3
0
'''
Created on Sep 18, 2012

@author: masumadmin
'''
from Utility import read_data
from NFoldValidation import NFoldValidation
from PCA02 import PCA02
from MYSVGWriter import MYSVGWriter



if __name__ == '__main__':
    matrix, cat_cols, nom_cols = read_data('data/credit-a.arff')
    
    num_folds=3    
    nfold = NFoldValidation(matrix, cat_cols, nom_cols,num_folds)
    print 'total error in linear regression:', nfold.run()
    
    components=5
    pca02= PCA02(matrix, cat_cols, nom_cols, components)
    pca02.train()
        
    
    #plot3.svg
    svg =  MYSVGWriter(500, 500, 0, 0, 100, 100)
    start_position=4
    for i in range(len( pca02.eigenvalues)):        
        svg.rect(start_position, 0, 3, 27*pca02.eigenvalues[i] , 0x008080)
        start_position+= 4