Unable to perform any symbolic regression with rgp

I have this simple code:

library(rgp) df1 <- data.frame(x=1:10, y=sin(1:10)) grp.model <- symbolicRegression(y ~ x, df1, functionSet=functionSet("sin")) 

When I execute, I get an error

 STARTING genetic programming evolution run (Age/Fitness/Complexity Pareto GP search-heuristic) ... Error in mse(x, y) : Argument 's_y' is not a real vector. 

I tried the examples from https://cran.r-project.org/web/packages/rgp/vignettes/rgp_introduction.pdf , but all the examples give me meaningless constant functions.

What am I doing wrong?

I am using R version 3.1.2 with rgp_0.4-1.

Greetings.

+7
r
source share
1 answer

I get the same error too. The documentation for the error function mse states that its argument requires a "numeric vector or list".

Running the str command to view the structure of the data frame indicates that x is an integer type.

 > str(df1) 'data.frame': 10 obs. of 2 variables: $ x: int 1 2 3 4 5 6 7 8 9 10 $ y: num 0.841 0.909 0.141 -0.757 -0.959 ... 

Try using as.numeric () for vector x:

 library(rgp) df1 <- data.frame(x=as.numeric(1:10), y=sin(1:10)) grp.model <- symbolicRegression(y ~ x, df1, functionSet=functionSet("sin")) 
+6
source share

All Articles