A Scala wrapper around Weka Machine Learning java library.
This is currently a very preliminary development. It is just a wrapper around the main classification features that I personally need to help perform predictions from scala code.
The current code already tries to simplify the use of Weka by adding more type safety and making the code more straightforward to code. As it's a light wrapper around Weka features, even if it tries to make things more immutable and "pure", there are loads of scary bits in it.
The scala syntax already simplifies the use of Weka in your core quite a lot. This is an example based on the Weka Programmatic Use example:
- Create a problema define the prediction label and dataset attributes:
val pbl = Problem("test", NominalAttribute('color, Seq('red, 'blue, 'green))) withAttributes(NumericAttribute('size), NumericAttribute('weight))
- Load some data for the problem:
val train = pbl withInstances (
Instance(
'size -> 10.0,
'weight -> 10,
'color -> 'blue),
Instance(
'size -> 11.0,
'weight -> 10,
'color -> 'red),
Instance(
'size -> 11.0,
'weight -> 15,
'color -> 'red),
Instance(
'size -> 11.0,
'weight -> 20,
'color -> 'red),
Instance(
'size -> 10.0,
'weight -> 50,
'color -> 'green),
Instance(
'size -> 10.0,
'weight -> 55,
'color -> 'green))
- Train a Classifier
val model = Classifier(new NaiveBayes()) train (train)
- Try to predict the label of a new instance (
model
is anOption
)
val pred = model map { cl =>
cl.classifyInstance(Instance('size -> 10,
'weight -> 50))
}
println(pred)
For more basic examples, see wela.examples.MyApp
.
The project follows the git flow organization for branching. If you want to participate, check out how it works.
Following WEKA's GPL licence, this project is also under the GNU General Public Licence V3.