[mlpack] Multiclass classification

Ryan Curtin ryan at ratml.org
Mon Feb 8 09:59:04 EST 2016


On Sun, Feb 07, 2016 at 06:23:28PM -0800, Mani Amoozadeh wrote:
> Hi,
> 
> I have installed mlpack from github and I am trying to find a simple
> multiclass classification C++ code that can classify input into more than 2
> categories.
> Can you please guild me on how to find a simple/skeleton program on this?
> Thanks!

Hi Mani,

You could use the mlpack_softmax_regression program to do multiclass
classification.  You can run `mlpack_softmax_regression -h` to get
detailed documentation.

A simple example might look like this...

$ mlpack_softmax_regression -t training_data.csv -l training_labels.csv
  -T test_data.csv -p predictions.csv -v

That will train a softmax regression classifier on the data and labels
in training_data.csv and training_labels.csv respectively, and then the
classifier will be run on the data in test_data.csv, with class
predictions output into predictions.csv.

I hope this is helpful... if you are trying to do the same thing in C++,
you could just use the SoftmaxRegression class; you can find some
documentation here:

http://mlpack.org/docs/mlpack-2.0.1/doxygen.php?doc=classmlpack_1_1regression_1_1SoftmaxRegression.html

(You can also look in the source files.)

All you'll need to do is create the class, call Train(), then you can
call Predict() to get your class predictions on some test data.

Let me know if I can clarify anything.

Thanks!

Ryan

-- 
Ryan Curtin    | "Avoid the planet Earth at all costs."
ryan at ratml.org |   - The President



More information about the mlpack mailing list