 |
Symbolic regression solver based on genetic programming (GAP) in 2D case
Source code name: "symb_regression_gap2D.py"
Programming language: Python
Topic: Artificial Intelligence/genetic programming
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/symb_regression_gap2D_8584.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from java.awt import Color,Font
from jhplot import *
from jhpro.sregression import *
import urllib
# get local file
wfile="gelman.conf"
#wfile=SystemDir+fSep+"macros"+fSep+"examples"+fSep+"data"+fSep+wfile
# get from the web
urllib.urlretrieve ("http://datamelt.org/examples/data/"+wfile,wfile)
js=SymRegression(wfile)
js.run()
# create a tree as image
# IView("/home/sergei/a.png")
print "Best solution=",js.getBestSolution()
# js.createTree("/home/sergei/a.png")
data=js.getDataPND()
print data.toString()
#val=js.getValidationPND()
#print val.toString()
c1 = HPlot("Canvas")
c1.setGTitle("Symbolic regression in 2D")
c1.visible(1)
c1.setAutoRange()
#f1=F1D(js.getBestSolution(),-5,6)
#f1.setTitle("best analytic solution")
# c1.draw(f1)
r12=data.getP1D(0,1)
r12.setColor(Color.blue)
c1.draw(r12)
You see the box below because you did not login.