How to use the genetic algorithm to predict

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 /

+8
r genetic-algorithm
source share
1 answer

Genetic algorithms are for optimization, not classification. Therefore, there is no forecasting method. Your resume was close to work.

 cat(summary(GAmodel)) GA Settings Type = binary chromosome Population size = 200 Number of Generations = 100 Elitism = TRUE Mutation Chance = 0.01 Search Domain Var 1 = [,] Var 0 = [,] GA Results Best Solution : 1 1 0 0 0 0 1 

Some additional information is available from Imperial College London.

Refresh in response to an updated question:

I see from the article that you mentioned how this makes sense. The idea is to use a genetic algorithm to optimize weights for a neural network, and then use a neural network for classification. That would be a big task, too big to answer here.

+4
source share

All Articles