---
date: "2015-05-01T17:00:00Z"
title: Using Weka in Go
description: "Weka bindings for Go"
tags: [weka, golang, machinelearning, technology]
---

A couple of years ago I wrote a [blog post](/blog/13/6/12/wekapy) about wrapping some of [Weka](http://www.cs.waikato.ac.nz/ml/weka)'s classification functionality to allow it to be used programmatically in Python programs. A small project I'm currently working on at home is around taking some of the later research from my PhD work to see if it can be expressed and used as a simple web-app.

I began development in [Go](https://golang.org) as I hadn't yet spent much time working with the language. The research work involves using a Bayesian network classifier to help infer a [tweet's interestingness](http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=6686092&tag=1), and while Go machine-learning toolkits do [exist](http://biosphere.cc/software-engineering/go-machine-learning-nlp-libraries), I wanted to use my existing models that were serialized in Java by Weka.

I started working on [WekaGo](https://github.com/willwebberley/WekaGo), which is able to programmatically support simple classification tasks within a Go program. It essentially just manages the model, abstracts the generation of [ARFF](http://www.cs.waikato.ac.nz/ml/weka/arff.html) files, and executes the necessary Java to make it quick and easy to train and classify data:

```
model := wekago.NewModel("bayes.BayesNet")
...
model.AddTrainingInstance(train_instance1)
...
model.Train()
model.AddTestingInstance(train_instance1)
...
model.Test()
```

Results from the classification can then be examined, as [described](https://github.com/willwebberley/WekaGo/blob/master/README.md).
