/ORandForest

A pure OCaml implementation of a random forest classifier based on OC4.5.

Primary LanguageOCamlGNU Lesser General Public License v3.0LGPL-3.0

ORandForest

A pure OCaml implementation of a random forest classifier based on OC4.5. See Wikipedia for more information.

OC4.5 is an implementation of C4.5 that can be found here.

Compiling

This project uses dune. In order to compile and install from sources, run:

    opam install dune # If you don't have it yet
    ./build.sh

There is an opam package also, if you want to install automatically.

   opam install orandforest

Documentation

You can generate the documentation by running ocamldoc. However, you can have a quick glance at the not necessarily up-to-date precompiled documentation here. Same goes for OC4.5 here.

Basic usage example

Assuming you're using integers (if not, use Oc45.FloatOc45 and ORandForest.FloatRandForest or reimplement the needed functions to functorize ORandForest.ORandForest with your datatype, a basic session would look like the following

  • First generate a dataset;
    let trainSet = Oc45.IntOc45.emptyTrainSet
        nbFeatures nbCategories featuresContinuity in
    Oc45.IntOc45.addDataList trainDataPoints trainSet
  • then tweak the dataset to your needs;

  • then turn it into a random forest;

    let forest = ORandForest.IntRandForest.genRandomForest nbTrees trainSet in
  • then classify
    let categories = List.map
        (ORandForest.IntRandForest.classify forest) testDataPoints in