Comparing algorithms

Package visualpred can help to visualize at a glance the behaviour of different machine learning algorithms. As returned values are often ggplot objects, ggplot options can be used to remove legends. A title is given, and title2 is set to two blank spaces .

Next plot shows the behaviour of different algorithms for classification. Although svm seems to be most accurate in this example, all algorithm parameters need some tuning.

require(egg)
library(visualpred)
dataf<-spiral
listconti<-c("x1","x2")
  listclass<-c("")
  vardep<-"clase"
  result<-famdcontour(dataf=spiral,listconti=listconti,listclass=listclass,vardep=vardep,
  title="GLM",title2="  ",selec=0,modelo="glm",classvar=0)
    g1<-result[[2]]+theme(legend.position = "none")
    result<-famdcontour(dataf=spiral,listconti=listconti,listclass=listclass,vardep=vardep,
title="NNET",title2="  ",selec=0,modelo="nnet",classvar=0)
    g2<-result[[2]]+theme(legend.position = "none")
    result<-famdcontour(dataf=spiral,listconti=listconti,listclass=listclass,vardep=vardep,
title="RF",title2="  ",selec=0,modelo="rf",classvar=0)
    g3<-result[[2]]+theme(legend.position = "none")
    result<-famdcontour(dataf=spiral,listconti=listconti,listclass=listclass,vardep=vardep,
title="GBM",title2="  ",selec=0,modelo="gbm",classvar=0)
    g4<-result[[2]]+theme(legend.position = "none")
  result<-famdcontour(dataf=spiral,listconti=listconti,listclass=listclass,vardep=vardep,title="SVM",
title2="  ",selec=0,modelo="svm",classvar=0)
    g5<-result[[2]]+theme(legend.position = "none")

  ggarrange(g1,g2,g3,g4,g5,ncol =2,nrow=3)

plot of chunk unnamed-chunk-2

Tuning representation

Next plot illustrates the effects of different tuning settings for a neural network modeling of the spiral dataset.

plot of chunk unnamed-chunk-3

Real dataset fitting under different algorithms

Next example applies the same schema to a real dataset. With default parameter values, SVM seems to overfit; other values are tried to avoid it but without success for this algorithm.

plot of chunk unnamed-chunk-4