Exemple #1
0
def callback(population):
    plot = pv.Plot(xrange=[0, 10], yrange=[0, 10])
    pts = [[each[1][0].value, each[1][1].value] for each in population]
    #pts = [ pv.Point(each[1][0],each[1][1]) for each in population ]
    #print pts
    plot.points(pts)
    plot.show(delay=10)
Exemple #2
0
 def plotConvergence(self):
     plot = pv.Plot(title="Population Statistics",xlabel="Iteration",ylabel="Score")
     data = [ [i,self.bests[i]] for i in range(len(self.bests)) ]
     plot.lines(data,width=3,color='green')
     data = [ [i,self.history[i]] for i in range(len(self.bests)) ]
     plot.points(data,shape=16,color='blue',size=2)
     data = [ [i,self.worsts[i]] for i in range(len(self.bests)) ]
     plot.lines(data,width=3,color='red')
     return plot
Exemple #3
0
 def testPlot(self):
     roc = pv.ROC(self.match, self.nonmatch, is_distance=True)
     plot = pv.Plot()
     roc.plot(plot, method=ROC_PRECISE_SAMPLED, color="red", width=5)
     roc.plot(plot, method=ROC_PRECISE_ALL, color='black')
     plot.lines([[0, 1], [1, 0]])
     eer = roc.getEER()
     plot.point([eer, 1 - eer])
     plot.asImage()
Exemple #4
0
    def addIndividual(self,score,args,kwargs,ilog=None):
        # This try block allows multiple values to be returned by the fitness function. 
        # Everything except the score will be stored in extra and should be picklible.
        extras = []
        try:
            extras = score[1:]
            score = score[0]
        except:
            # this means score must be a single value
            pass
        
        if not np.isfinite(score):
            return
        
        if score < self.best_score:
            self.best_score = score
            if ilog != None:
                # Print data
                print "New Best Score:",score
                
                for i in range(len(args)):
                    print "    arg%02d"%i,args[i]
                keys = list(kwargs.keys())
                keys.sort()
                for key in keys:
                    print "    %10s:"%key,kwargs[key]
                
        self.population.append([score,args,kwargs])
        self.population.sort(lambda x,y: cmp(x[0],y[0]))
        self.population = self.population[:self.population_size]

        self.history.append(score)
        self.bests.append(self.population[0][0])
        self.worsts.append(self.population[-1][0])
        
        self.iter += 1

        if ilog != None:    
            self.printPopulation()
            
            ilog.pickle([score,args,kwargs],"Fitness_%0.8f"%score)
            for i in xrange(len(extras)):
                extra = extras[i]
                if isinstance(extra,pv.Image):
                    ilog(extra,"extra_%02d_%0.8f"%(i,score))
                else:
                    ilog.pickle(extra,"extra_%02d_%0.8f"%(i,score))
                
            if self.iter % 25 == 0:
                plot = pv.Plot(title="Population Statistics",xlabel="Iteration",ylabel="Score")
                data = [ [i,self.bests[i]] for i in range(len(self.bests)) ]
                plot.lines(data,width=3,color='green')
                data = [ [i,self.history[i]] for i in range(len(self.bests)) ]
                plot.points(data,shape=16,color='blue',size=2)
                data = [ [i,self.worsts[i]] for i in range(len(self.bests)) ]
                plot.lines(data,width=3,color='red')
                ilog(plot,"PopulationData")
Exemple #5
0
def createData():
    data = np.random.normal(size=(20, 3))
    mult = np.random.normal(size=(3, 3))

    data = np.dot(data, mult)

    xy = pv.Plot(title="X vs Y", x_range=(-5, 5), y_range=(-5, 5))
    xy.points(data[:, [0, 1]])
    xy.show(window='X vs Y', delay=1)

    xy = pv.Plot(title="X vs Z",
                 x_range=(-5, 5),
                 y_range=(-5, 5),
                 ylabel="Z Axis")
    xy.points(data[:, [0, 2]])
    xy.show(window='X vs Z')

    print(repr(data))

    return data
def callback(population):
    plot = pv.Plot(x_range=[0, 10], y_range=[0, 10], title='Search Space')

    plot.point(pv.Point(3, 4), size=20, shape=16, color='gray')
    plot.point(pv.Point(8, 2), size=10, shape=16, color='gray')
    plot.point(pv.Point(5, 9), size=40, shape=16, color='gray')

    pts = [[each[1][0].value, each[1][1].value] for each in population]

    #pts = [ pv.Point(each[1][0],each[1][1]) for each in population ]
    #print pts
    plot.points(pts, color='red')
    plot.show(delay=10, window='Search Space')
Exemple #7
0
    def addIndividual(self, score, args, kwargs, ilog=None):
        if score == np.inf:
            return

        if score < self.best_score:
            self.best_score = score
            if ilog != None:
                # Print data
                print "New Best Score:", score

                for i in range(len(args)):
                    print "    arg%02d" % i, args[i]
                keys = list(kwargs.keys())
                keys.sort()
                for key in keys:
                    print "    %10s:" % key, kwargs[key]

        self.population.append([score, args, kwargs])
        self.population.sort(lambda x, y: cmp(x[0], y[0]))
        self.population = self.population[:self.population_size]

        self.history.append(score)
        self.bests.append(self.population[0][0])
        self.worsts.append(self.population[-1][0])

        self.iter += 1

        if ilog != None:
            self.printPopulation()

            ilog.pickle([score, args, kwargs], "Fitness_%0.8f" % score)

            if self.iter % 25 == 0:
                plot = pv.Plot(title="Population Statistics",
                               xlabel="Iteration",
                               ylabel="Score")
                data = [[i, self.bests[i]] for i in range(len(self.bests))]
                plot.lines(data, width=3, color='green')
                data = [[i, self.history[i]] for i in range(len(self.bests))]
                plot.points(data, shape=16, color='blue', size=2)
                data = [[i, self.worsts[i]] for i in range(len(self.bests))]
                plot.lines(data, width=3, color='red')
                ilog(plot, "PopulationData")
Exemple #8
0
'''
Created on Oct 17, 2010

@author: bolme
'''

import pyvision as pv
import numpy as np

if __name__ == "__main__":
    ilog = pv.ImageLog()

    plot = pv.Plot(size=(600, 600),
                   title="Test Plot 1",
                   xrange=(0, 25),
                   yrange=(0, 25))

    plot.label([0, 25], "Shapes (Size=7)", align='right')
    for i in range(0, 26):
        plot.point((i, 24), shape=i, size=7, color='red')

    plot.label([0, 23], "Shapes (Size=5)", align='right')
    for i in range(0, 26):
        plot.point((i, 22), shape=i, size=5, color='red')

    plot.label([0, 21], "Shapes (Size=3)", align='right')
    for i in range(0, 26):
        plot.point((i, 20), shape=i, size=3, color='red')

    plot.label([0, 19], "Upper Case Alphabet Large (Size=7)", align='right')
    for i in range(0, 26):
import pyvision as pv

ilog = pv.ImageLog()
im = pv.Image("baboon.jpg")
ilog(im,"Baboon")

table = pv.Table()
table[1,"image"] = im.filename
table[1,"width"] = im.size[0]
table[1,"height"] = im.size[1]
ilog(table,"ImageData")
print(table)

plot = pv.Plot(title="Some Dots and Lines");
plot.points([[3.5,7.1],[1,1],[5.5,2]],shape=2)
plot.lines([[5.5,7.5],[2,3],[3.3,7]])
ilog(plot,"MyPlot")

ilog.show()
Exemple #10
0
def callback(population):
    plot = pv.Plot(x_range=[0, 10], y_range=[0, 10])
    pts = [[each[1][0].value, each[1][1].value] for each in population]
    plot.points(pts)