Beispiel #1
0
def image_generation(us_mlp, s, w, h, file_name):    
    in_vect= [0.0, 0.0, 0.0, 0.0]
    out_vect=[0.0,0.0,0.0] 
    
    in_vect[2]= s[0]*(max_0-min_0)+min_0
    in_vect[3]= s[1]*(max_1-min_1)+min_1
    
    svg =  MYSVGWriter(640, 480, 0, 0, w, h)    
    for y in range(h):
        in_vect[1] = 1.0* y/h
        for x in range(w):
            in_vect[0] = 1.0*x/w
            out_vect = us_mlp.predict(in_vect)                    
            svg.rect(x, h - 1 - y, 1, 1, rgbToUint(out_vect[0] * 255, out_vect[1] * 255, out_vect[2] * 255));
    
    svg.svgprint(file_name+'.svg')    
Beispiel #2
0
def plot_intrinsic(X, w, h):    
    svg =  MYSVGWriter(640, 480, -100, -100, 100, 100)    
    x_prev, y_prev = None, None
    for row in X:                
        x= 10**1*row[0] #to scale data
        y= 10**1*row[1] #to scale data        
        svg.dot(x ,y,1, 0x008080)
        if x_prev and y_prev:
            svg.line(x_prev, y_prev, x, y, .05, 0xc0c0c0)        
        x_prev=x
        y_prev=y        
    svg.svgprint("intrinsic.svg")    
Beispiel #3
0

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                

#    print pca02.eigenvalues
    svg.svgprint("plot3.svg")
    
    #plot4.svg
    svg =  MYSVGWriter(500, 500, -100, -100, 110, 110)
    start_position=10
    for i  in range(len( pca02.matrix)):        
        row = pca02.matrix[i]
        reduced= pca02.reduce(row[:len(row)], 2)
        x= 10**17*reduced[0]#to scale data