/online-random-forest

Online Random Forest http://sensor.informatik.uni-mannheim.de#onlineforest

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

Online Random Forest Classifier (Java)

This is a Java implementation of an online random forest classifier. Online machine learning enables to update an existing classification model continuously without keeping the processed data available or knowing all data a-priori. This implementation relies on the implementation of Amir Saffari (C++). We reimplemented this classifier to use it also on wearable devices, e.g., android platforms.

Releases

Download: latest build (JAR, Build190117)

Usage

DataSet dsTrain = new ARFF();
dsTrain.load(new FileInputStream(new File("data/data_train.arff")));
DataSet dsTest = new ARFF();
dsTest.load(new FileInputStream(new File("data/data_test.arff")));

Config config = new Config();
RandomForest rf = new RandomForest(config, dsTrain.getNumOfClasses(), dsTrain.getNumOfFeatures(), dsTrain.getMinFeatRange(), dsTrain.getMaxFeatRange());

for (int nEpoch = 0; nEpoch < config.numEpochs; nEpoch++) { // train
  dsTrain.randomize();
  for (Sample sample : dsTrain.getSamples()) {
    rf.update(sample);
  }
}

for (Sample sample : dsTest.getSamples()) { // test
  Result result = new Result(dsTrain.getNumOfClasses());
  rf.eval(sample, result);
  results.put(result, sample.getLabel());
}

Please also consider the complete example

Documentation

Documentation (JavaDoc) is coming soon . If you have any issues, feel free to contact me