R 使用 rgp symbolicRegression 进行方程发现

R using rgp symbolicRegression for equation discovery

我正在尝试使用包 rgp 来发现方程

library(rgp)
x = c (1:100)
y =  5*x+3*sin(x)+4*x^2+75
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")
model <- result1$population[[which.min(result1$fitnessValues)]]

但是,我一直收到错误消息message.I非常感谢您帮助指出我在上面犯的错误。

有用的参考资料(如果在 R 中有这个就好了):

https://www.researchgate.net/publication/237050734_Improving_Genetic_Programming_Based_Symbolic_Regression_Using_Deterministic_Machine_Learning

问题在于 Rx 向量视为整数,并且在类型方面存在一些问题。尝试将类型 x 专门用于数字:

x <- as.numeric(1:100)

它对我有用。