[mlpack] How to do linear regression?
Ryan Curtin
ryan at ratml.org
Tue Jun 12 11:52:17 EDT 2018
On Tue, Jun 12, 2018 at 11:46:09PM +0800, Jason Liu wrote:
> Hi,
>
> I copy-pasted some code from mlpack doc
>
> ...
>
> Unfortunately it gives me
>
>
> error: Mat::init(): requested size is not compatible with row vector layout
>
> The exception was thrown at the LinearRegression ctor.
>
> What does the error message mean?
>
> What did I do wrong?
Ah! I think the tutorial was not updated when the LinearRegression API
changed. Try changing the line
arma::vec responses;
to
arma::rowvec responses;
And then it will need to be filled differently:
responses << 1.0 << 2.0 << 3.0 << 4.0 << 5.0;
(Instead of the several lines that each end with arma::endr.)
If that fixes your problem, I'll update the tutorials. Sorry for the
error!
--
Ryan Curtin | "You got to stick with your principles."
ryan at ratml.org | - Harry Waters
More information about the mlpack
mailing list