Pages

Friday, August 5, 2011

Scala-recog: flexibility with logistic regression

In this wiki page I have put some example on the flexibility you can reach using stackable modification.

Indeed my effort on logistic regression on scala-recog was to get the more flexibility without getting rid of the optimizations needed by a training algorithm.

What I would like to reach, anyway, needs an extra effort. I would like a very general library, unaware of the domain.

For example, I would like to write something like this:

import org.scalarecog.logisticregression.SigmoidClassifier._  
val myStuff = List( 
                Stuff(3, 2.1, "just"), 
                Stuff(2, 1.1, "an"), 
                Stuff(3, 1.2, "example") 
              )  
val trainingSet = myStuff toTrainingSet ( 
                   _.number, _.number2), _.classLabel 
                  )           
val classifier = trainingSet.train

But, I would like also to reach this kind of flexibility, with monads:

val classifier = ( 
    for(stuff <- trainingSet; writer <- stuff.toWriter ) 
  ) train  

(classifier.log) foreach(println(_))

Maybe this could be achieved providing a support for monads in training sets, as in this example of Tony Morris.