[mlpack] r^2 for linear regression

Michael Bane M.Bane at mmu.ac.uk
Thu May 5 06:26:37 EDT 2022


Hi all, I've just (happily!) discovered mlpack so please excuse any newbie questions. I had a quick look in the docs but couldn't find what i am looking for. NB I'm a C programmer trying to get by with C++ but really starting off with the CLI to see how things work and to do initial data exploration, with the C++ coding to follow.

Specifically, I am looking at the linear regression and have CLI working fine for my input matrix (X,Y), where X has ~20 cols and there are ~4000 rows) and can obtain a model and also predict new Y' for new X'. This data enables me to use gnuplot to draw a graph such as below. However, what I am looking for is an "r squared" value to quantify how good the fit is. I have seen there is a member function "computeError" but how would I access this from the command line?



NB I'm not sure why I get a warning with this invocation - it seems to follow the documentation and it does actually produce "newPredicts.csv" with the Y' values:
mkb at hec003-ssd ~/EEC/mlpack-examples$ mlpack_linear_regression -v --training_file newTrain.csv --test_file newTest.csv  -o newPredicts.csv

[WARN ] '--output_predictions_file (-o)' ignored because '--test_file (-T)' is specified!

[INFO ] Loading 'newTrain.csv' as CSV data.  Size is 48 x 3322.

[INFO ] Loading 'newTest.csv' as CSV data.  Size is 47 x 833.

[INFO ] Saving CSV data to 'newPredicts.csv'.



gnuplot
f(x)=x
plot "<paste newActual.csv newPredicts.csv", f(x) w l



[cid:image001.png at 01D86072.656D74C0]

"Before acting on this email or opening any attachments you should read the Manchester Metropolitan University email disclaimer available on its website http://www.mmu.ac.uk/emaildisclaimer "
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://knife.lugatgt.org/pipermail/mlpack/attachments/20220505/d2b99ab4/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 29809 bytes
Desc: image001.png
URL: <http://knife.lugatgt.org/pipermail/mlpack/attachments/20220505/d2b99ab4/attachment-0001.png>


More information about the mlpack mailing list