Hi,

I copy-pasted some code from mlpack doc

#include <mlpack/methods/linear_regression/linear_regression.hpp>

#include <mlpack/core.hpp>

#include <armadillo>

#include <iostream>


using namespace mlpack::regression;

using namespace std;


int main(int argc, char *argv[]) {


    //The dataset itself.

    arma::mat data;

    data<<1.0<<arma::endr

        <<2.0<<arma::endr

        <<3.0<<arma::endr

        <<4.0<<arma::endr

        <<5.0<<arma::endr;

    cout<<data<<endl;


    //The responses, one row for each row in data.

    arma::vec responses;

    responses<<1.0<<arma::endr

             <<2.0<<arma::endr

             <<3.0<<arma::endr

             <<4.0<<arma::endr

             <<5.0<<arma::endr;

    cout<<responses<<endl;


    //Regress.

    LinearRegression lr(data, responses);


    //Get the parameters, or coefficients.

    arma::vec parameters = lr.Parameters();


    cout << parameters << endl;

    return 0;

}


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?


Thanks.



Kind Regards

Jason
_______________________________________________
mlpack mailing list
mlpack@lists.mlpack.org
http://knife.lugatgt.org/cgi-bin/mailman/listinfo/mlpack

Reply via email to