
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)
