## ## ## Not run: #We use the wine dataset for this example #We need to convert the output in a numeric format. ## Start input data library(fugeR) ## Start input data load("wine.5f.RData") tra.wine.1 <- data.frame(wine.5.1.tra) tra.wine.2 <- data.frame(wine.5.2.tra) tra.wine.3 <- data.frame(wine.5.3.tra) tra.wine.4 <- data.frame(wine.5.4.tra) tra.wine.5 <- data.frame(wine.5.5.tra) tst.wine.1 <- data.frame(wine.5.1.tst[, 1 : 13]) tst.wine.2 <- data.frame(wine.5.2.tst[, 1 : 13]) tst.wine.3 <- data.frame(wine.5.3.tst[, 1 : 13]) tst.wine.4 <- data.frame(wine.5.4.tst[, 1 : 13]) tst.wine.5 <- data.frame(wine.5.5.tst[, 1 : 13]) real.wine.1 <- data.frame(matrix(wine.5.1.tst[, 14], ncol = 1)) real.wine.2 <- data.frame(matrix(wine.5.2.tst[, 14], ncol = 1)) real.wine.3 <- data.frame(matrix(wine.5.3.tst[, 14], ncol = 1)) real.wine.4 <- data.frame(matrix(wine.5.4.tst[, 14], ncol = 1)) real.wine.5 <- data.frame(matrix(wine.5.5.tst[, 14], ncol = 1)) #Launch the evolution, fugeR.run will return #the best fuzzy system found during the evolution ## 1 fuzzySystem.1 <- fugeR.run( tra.wine.1[, 1:13], tra.wine.1[, 14, 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.wine.2[, 1:13], tra.wine.2[, 14, 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.wine.3[, 1:13], tra.wine.3[, 14, 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.wine.4[, 1:13], tra.wine.4[, 14, 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.wine.5[, 1:13], tra.wine.5[, 14, 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 <- matrix(round(fugeR.predict(fuzzySystem.1, tst.wine.1)), ncol=1) pred.2 <- matrix(round(fugeR.predict(fuzzySystem.2, tst.wine.2)), ncol = 1) pred.3 <- matrix(round(fugeR.predict(fuzzySystem.3, tst.wine.3)), ncol = 1) pred.4 <- matrix(round(fugeR.predict(fuzzySystem.4, tst.wine.4)), ncol = 1) pred.5 <- matrix(round(fugeR.predict(fuzzySystem.5, tst.wine.5)), ncol=1) err.1 = 100*sum(real.wine.1!=pred.1)/nrow(real.wine.1) err.2 = 100*sum(real.wine.2!=pred.2)/nrow(real.wine.2) err.3 = 100*sum(real.wine.3!=pred.3)/nrow(real.wine.3) err.4 = 100*sum(real.wine.4!=pred.4)/nrow(real.wine.4) err.5 = 100*sum(real.wine.5!=pred.5)/nrow(real.wine.5) err.aver <- (err.1 + err.2 + err.3 + err.4 +err.5)/5 print(err.aver)