## ## ## Not run: #We use the iris dataset for this example #We need to convert the output in a numeric format. data(iris) library(fugeR) ## Start input data load("iris.5f.RData") tra.iris.1 <- data.frame(iris.5.1.tra) tra.iris.2 <- data.frame(iris.5.2.tra) tra.iris.3 <- data.frame(iris.5.3.tra) tra.iris.4 <- data.frame(iris.5.4.tra) tra.iris.5 <- data.frame(iris.5.5.tra) tst.iris.1 <- data.frame(iris.5.1.tst[, 1 : 4]) tst.iris.2 <- data.frame(iris.5.2.tst[, 1 : 4]) tst.iris.3 <- data.frame(iris.5.3.tst[, 1 : 4]) tst.iris.4 <- data.frame(iris.5.4.tst[, 1 : 4]) tst.iris.5 <- data.frame(iris.5.5.tst[, 1 : 4]) real.iris.1 <- data.frame(matrix(iris.5.1.tst[, 5], ncol = 1)) real.iris.2 <- data.frame(matrix(iris.5.2.tst[, 5], ncol = 1)) real.iris.3 <- data.frame(matrix(iris.5.3.tst[, 5], ncol = 1)) real.iris.4 <- data.frame(matrix(iris.5.4.tst[, 5], ncol = 1)) real.iris.5 <- data.frame(matrix(iris.5.5.tst[, 5], ncol = 1)) #Launch the evolution, fugeR.run will return #the best fuzzy system found during the evolution ## 1 fuzzySystem.1 <- fugeR.run(tra.iris.1[, 1:4], tra.iris.1[, 5, drop = FALSE], generation=100, # Increase the number of generation for a better accuracy population=100, elitism=20, verbose=TRUE, threshold=NA, sensiW=0.0, speciW=0.0, accuW=0.0, rmseW=1.0, maxRules=10, maxVarPerRule=2, labelsMf=3 ) ## 2 fuzzySystem.2 <- fugeR.run( tra.iris.2[, 1:4], tra.iris.2[, 5, drop = FALSE], generation=100, # Increase the number of generation for a better accuracy population=100, elitism=20, verbose=TRUE, threshold=NA, sensiW=0.0, speciW=0.0, accuW=0.0, rmseW=1.0, maxRules=10, maxVarPerRule=2, labelsMf=3 ) ## 3 fuzzySystem.3 <- fugeR.run( tra.iris.3[, 1:4], tra.iris.3[, 5, drop = FALSE], generation=100, # Increase the number of generation for a better accuracy population=100, elitism=20, verbose=TRUE, threshold=NA, sensiW=0.0, speciW=0.0, accuW=0.0, rmseW=1.0, maxRules=10, maxVarPerRule=2, labelsMf=3 ) ## 4 fuzzySystem.4 <- fugeR.run( tra.iris.4[, 1:4], tra.iris.4[, 5, drop = FALSE], generation=100, # Increase the number of generation for a better accuracy population=100, elitism=20, verbose=TRUE, threshold=NA, sensiW=0.0, speciW=0.0, accuW=0.0, rmseW=1.0, maxRules=10, maxVarPerRule=2, labelsMf=3 ) ## 5 fuzzySystem.5 <- fugeR.run( tra.iris.5[, 1:4], tra.iris.5[, 5, drop = FALSE], generation=100, # Increase the number of generation for a better accuracy population=100, elitism=20, verbose=TRUE, threshold=NA, sensiW=0.0, speciW=0.0, accuW=0.0, rmseW=1.0, maxRules=10, maxVarPerRule=2, labelsMf=3 ) #Plot the predicton given by the best fuzzy system found during the evolution pred.1 <- round(fugeR.predict(fuzzySystem.1, tst.iris.1)) pred.2 <- round(fugeR.predict(fuzzySystem.2, tst.iris.2)) pred.3 <- round(fugeR.predict(fuzzySystem.3, tst.iris.3)) pred.4 <- round(fugeR.predict(fuzzySystem.4, tst.iris.4)) pred.5 <- round(fugeR.predict(fuzzySystem.5, tst.iris.5)) err.1 = 100*sum(real.iris.1!=pred.1)/nrow(real.iris.1) err.2 = 100*sum(real.iris.2!=pred.2)/nrow(real.iris.2) err.3 = 100*sum(real.iris.3!=pred.3)/nrow(real.iris.3) err.4 = 100*sum(real.iris.4!=pred.4)/nrow(real.iris.4) err.5 = 100*sum(real.iris.5!=pred.5)/nrow(real.iris.5) err.aver <- (err.1 + err.2 + err.3 + err.4 +err.5)/5 print(err.aver)