5

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")
sean
  • 1,632
  • 2
  • 15
  • 34
  • Please make your example self-contained and [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Show the code you've written to do the regression. – MrFlick Jan 29 '15 at 22:32

2 Answers2

5

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

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

Richard Border
  • 3,209
  • 16
  • 30
0

I have tried quite a few symbolic regression implementations, including rgp, gplearn and a Python tool called fast-symbolic-regression. None of these was nearly comparable to Eureqa, a symbolic regression tool that I first used in 2015 and that left the market in 2017.

Recently a new symbolic regression tool called TuringBot was developed, and it was shown in arXiv:2010.11328 to be more efficient than Eureqa at finding formulas. So I would recommend TuringBot for symbolic regression in 2020.

bluewhale
  • 167
  • 3
  • 13