Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the function result from Symbolic Regression with R

Tags:

r

First, please excuse my ignorance because I've just started learning R today.

I have a data frame of two variables (x, y) as follows: (1,0), (2,26), (3,88), (4,186), (5,320), (6,490), (7,541). I want to use Symbolic Regression to find a function f such that y = f(x).

Following the tutorial here, I can have a plot of f(x), which is closed to what I expect. However, I don't know how to print out the function f(x).

I tried with another tool called Eurequa. It is pretty easy to use, and gives me (a lot of) functions. But I can't use a commercial tool for my project. Thank you.


UPDATE

Here is my code to compute Symbolic Regression and plot the function. I enter the command one by one in R environment.

x = c (1, 2, 3, 4, 5, 6, 7)
y = c (0, 26, 88, 186, 320, 490, 541)
data1 = data.frame(x,y)
newFuncSet <- functionSet("+","-","*")
result1 <- symbolicRegression(y ~ x, data = data1, functionSet = newFuncSet, stopCondition = makeStepsStopCondition(2000))
plot(data1$y, col=1, type="l"); points(predict(result1, newdata = data1), col=2, type="l")
like image 766
sean Avatar asked Jan 29 '15 21:01

sean


1 Answers

model <- result1$population[[which.min(result1$fitnessValues)]]

An introduction to the rgp package with many examples can be found here.

like image 165
Richard Border Avatar answered Oct 11 '22 18:10

Richard Border