Skip to content
/ blom Public

A library to train, evaluate and make inference using random forests.

License

Notifications You must be signed in to change notification settings

ngendah/blom

Repository files navigation

Blom

Blom is a subset of YDF(Yggdrasil Decision Forests) that runs the following algorithms:

  1. CART
  2. Decision Tree
  3. Random Forest

Specifically, Blom aims to be a library that can be easily compiled for both ARM and Android with minimal setup.

Getting started

Linux

There are various ways to get started with Blom:

  1. on the command-line with vim(or its variants).

  2. using an IDE such as Visual studio code(with CMake plugins) or JetBrains CLion.

  3. using Docker with the enclosed Dockerfile. Ideal if you need an isolated build environment and have some knowledge of Docker.

Prequisites:

If you opt to use docker, you can safely skip installing the prequisites and go to step 4.

  1. CMake

  2. Ninja

  3. Build-essentials i.e c++, make e.tc

Steps:

  1. Configure the project
    cmake --preset=linux.x64-debug -S .
  1. Build the project
    cmake --build --preset=linux.x64-debug
  1. Run example executable;
cd builds/linux.x64-debug/example
./example
  1. Docker only steps:

    a. Build the image

     docker build -t blom .
    

    b. Run the image

     docker run -v $(pwd):/home/workspace/blom -u $(id -u):$(id -g) -it blom /bin/bash
    

    c. On the container prompt, build the project

     cmake --preset=linux.x64-debug -S . && cmake --build --preset=linux.x64-debug
    

Windows

I would recommend using Visual studio.

Prequisites:
  1. Visual Studio 22 community or pro.

  2. Visual studio "Desktop Development with c++" workload installed. This is available as part of the installer. The workload will enable support for CMake projects.

Steps:
  1. Start Visual studio and select "Open a local folder".

  2. Select folder where you have cloned the project.

  3. Wait for Visual studio to setup the project dependencies.

  4. On project menu "build all"

  5. On folder view change, select "CMake target view" to select targets. Search for "example" executable and set as default.

For more information refer to Visual Studio documentation on CMake.

Troubleshooting:
  1. Not all project dependencies were downloaded:

    Go to project menu and "Delete cache and Reconfigure".

  2. Test discovery timeout:

    Go to test menu options and adjust the timeout for Google test discovery.

  3. If issues still persist:

    (re)configure and build the project manually by going to "view menu", opening a terminal and running the following commands.

    a. Check your terminal prompt has the project directory set as the default directory.

    b. Check cmake is installed;

     cmake --version
    

    c. Remove the "builds" directory, if it exists.

    d. Configure the project;

     cmake --preset=windows.x64-debug -S .
    

    e. Build example;

     cmake --build --preset=windows.x64-debug --target example
    

    f. Or build all;

     cmake --build --preset=windows.x64-debug
    

Cross-compiling

You can cross-compile the Blom for ARM or Android; however only the Android configurations are provided.

Prequisites:

  1. Android NDK OR

  2. ARM GCC cross-compiler

  3. To cross compile for ARM you will also need to create a CMakeUserPreset.json and a toolchain file. CMake documentation is an excellent resource.

Steps for Android:

  1. Add to the environment the variable CMAKE_ANDROID_NDK pointing to the root directory of Android NDK.

    Without this environment variable CMake will not enable the Android presets.

  2. Phase 1: build all, in this case on a linux host.

     cmake --preset=linux.x64-debug -S . && cmake --build --preset=linux.x64-debug
    

    If on windows replace linux with windows.

    This step is necessary in order to generate the required protocol buffer C++ source files.

  3. Phase 2: build for Android

     cmake --preset=android.v8a-debug -S . && cmake --build --preset=android.v8a-debug
    

For more options, review projects preset file.