I am trying to use a genetic algorithm for a classification problem. However, I was unable to get a resume for the model or a prediction for a new data frame. How can I get a summary and prediction for a new dataset? Here is my toy example:
library(genalg) dat <- read.table(text = " cats birds wolfs snakes 0 3 9 7 1 3 8 7 1 1 2 3 0 1 2 3 0 1 2 3 1 6 1 1 0 6 1 1 1 6 1 1 ", header = TRUE) evalFunc <- function(x) { if (dat$cats < 1) return(0) else return(1) } iter = 100 GAmodel <- rbga.bin(size = 7, popSize = 200, iters = iter, mutationChance = 0.01, elitism = T, evalFunc = evalFunc) ###########summary try############# cat(summary.rbga(GAmodel)) # Error in cat(summary.rbga(GAmodel)) : # could not find function "summary.rbga" ############# prediction try########### dat$pred<-predict(GAmodel,newdata=dat) # Error in UseMethod("predict") : # no applicable method for 'predict' applied to an object of class "rbga"
Update: After reading the answer and reading this link: Predicting patterns using the genetic algorithm I wonder how I can programmatically use GA as part of the prediction mechanism? According to the text of the link, you can use GA to optimize regression or NN, and then use the forecast function provided by them /
r genetic-algorithm
mql4beginner
source share