Shark Random Forest vs Weka - slow and low accuracy issue

469 views Asked by At

I wanted to get a much faster random forest classifier than the one from Weka, so I just tried Shark (I can't use a commercial one like wiseRF). I know there is an alternative RF classifier on Weka but I expected far better results using this renowned C++ fast library. My first results on my set are:

Training time: Weka > 170s VS Shark > 168s
Prediction results on the same test set: Weka > 90,1% correctly classified VS Shark > accuracy of 0.510824 (!!!!)

This sounds crazy so I am sure there must be a lot to improve those results.

I get the recommended code to use shark like this:

svn co https://svn.code.sf.net/p/shark-project/code/trunk/Shark
sudo apt-get install cmake cmake-curses-gui libatlas-base-dev libboost-all-dev

I successfully ran the cmake with the suggested options:

cmake -DOPT_ENABLE_ATLAS=ON -DOPT_ENABLE_OPENMP=ON

I used the base example from doc "RFTutorial.cpp" and just added "trainer.setNTrees(100);" in order to get the same number of forests than in my Weka test.

I used the basic Makefile suggested and added :

SHARK_ROOT = /home/doxav/Shark
CPPFLAGS   =  -I${BOOST_ROOT} -I${SHARK_ROOT}/include -Wall
CPPFLAGS  += -DNDEBUG -DBOOST_UBLAS_NDEBUG  -O3
LDFLAGS   += -L${SHARK_ROOT}/lib/ -L${BOOST_ROOT}/lib
LDLIBS     = -lshark -lgomp
LDLIBS    += -lboost_serialization -lboost_system -lboost_filesystem -lboost_program_options
CC         =  g++

When running my makefile, I get the following command line for g++:

g++  -I -I/home/xavier/Shark/include -Wall -DNDEBUG -DBOOST_UBLAS_NDEBUG  -O3 -L/home/xavier/Shark/lib/ -L/lib  RFTest.cpp  -lshark -lgomp -lboost_serialization -lboost_system -lboost_filesystem -lboost_program_options -o RFTest

I had to adapt my CSV file from the one used in Weka to make it work on Shark as it apparently does not accept strings:

Weka =>
225,#225,138.6,-648,225,0.410451,#2,0,0,0.0256,0.0256,0.15411,?,?,0.045524,0.006503,0.002223,0.782222,1.328889,?,1.017778,0.617778,0,-11,?,-6,-5,176,116,-1430,0,0,0.170455,0.170455,0.136174,?,?,0.041649,0.00595,0.001192,299,269,-659,0,0,0.006689,-0.143509,0.23395,?,?,0.015899,-0.005781,0.002956,?,?,?,?,?,?,?,?,?,?,?,?,?,229,139,-653,0,0,0.026201,0.026201,0.093029,?,?,0.047562,0.006795,0.000937,139,79,-13945,0,0,0,0,-0.094604,?,?,?,?,0.001049,#225

Shark (I removed ? (used for unknown values) and # (I use it to force Weka to interpret some numeric values as nominal out of the box)) =>
225,225,138.6,-648,225,0.410451,2,0,0,0.0256,0.0256,0.15411,,,0.045524,0.006503,0.002223,0.782222,1.328889,,1.017778,0.617778,0,-11,,-6,-5,176,116,-1430,0,0,0.170455,0.170455,0.136174,,,0.041649,0.00595,0.001192,299,269,-659,0,0,0.006689,-0.143509,0.23395,,,0.015899,-0.005781,0.002956,,,,,,,,,,,,,,229,139,-653,0,0,0.026201,0.026201,0.093029,,,0.047562,0.006795,0.000937,139,79,-13945,0,0,0,0,-0.094604,,,,,0.001049,225
0

There are 0 answers