Exemple #1
0
// function to plot target curve
func plotTarget(trainSet []Point) func(gp.Population) stats.Plot {
	return func(pop gp.Population) stats.Plot {
		plot := stats.NewPlot("Target", len(trainSet))
		plot.Color = "#00ff00"
		for i, pt := range trainSet {
			plot.Data[i][0], plot.Data[i][1] = pt.x, pt.y
		}
		return plot
	}
}
Exemple #2
0
// function to plot best individual
func plotBest(trainSet []Point) func(gp.Population) stats.Plot {
	return func(pop gp.Population) stats.Plot {
		plot := stats.NewPlot("Best", len(trainSet))
		plot.Color = "#ff0000"
		code := pop.Best().Code
		for i, pt := range trainSet {
			plot.Data[i][0] = pt.x
			plot.Data[i][1] = float64(code.Eval(num.V(pt.x)).(num.V))
		}
		return plot
	}
}