Reputation: 3075
I am trying out dlib for a problem. Given the area of house and no of trees in the locality, the price of the house is provided. We wish to predict the price of the house using krr trainer for a given area and no Of Trees
area , noOfTrees, priceOFHouse
100 , 10 , 400
100 ,50, 2000
200 , 1,200
.... lots more
I planned to use kernel ridge regression
typedef matrix<double, 2, 1> sample_type;
typedef radial_basis_kernel<sample_type> kernel_type;
krr_trainer<kernel_type> trainer;
// i took trainign data and put htose data in 2 vectors
// std::vector<std::vector<double> > feactureVector;
// std::vector<double> resultVector;
populateTrainigData(feactureVector, resultVector) ;
// so featurevector[0] is {100,10} resultvector[0] is 400
decision_function<kernel_type> test = trainer.train(feactureVector, resultVector);
sample_type m;
m(0, 0) = 100; // area of house is 100
m(1, 0) = 25; // no of treess in neighbourhood is 25
double result = test(m);
At line decision_function<kernel_type> test
it gives compile error .
d:\dlib-19.15\dlib\svm\krr_trainer.h(300): error C2664: 'const dlib::matrix<double,0,1,dlib::default_memory_manager,dlib::row_major_layout> &dlib::empirical_kernel_map<dlib::radial_basis_kernel<sample_type>>::project(const dlib::matrix<T,2,1,dlib::default_memory_manager,dlib::row_major_layout> &,double &) const': cannot convert argument 1 from 'const std::vector<double,std::allocator<_Ty>>' to 'const dlib::matrix<T,2,1,dlib::default_memory_manager,dlib::row_major_layout> &'
1>
Can someone point me in the right direction where I can solve this problem as the example on the dlib site shows only a single dimension example. I am using that as a reference guide and the error & system is strange to me.
Upvotes: 0
Views: 101
Reputation: 351
I think you got an error because of this line:
std::vector<std::vector<double> > feactureVector;
your features should be a vector of sample_type
like this:
std::vector< sample_type > feactureVector;
like in this example: http://dlib.net/krr_regression_ex.cpp.html
Upvotes: 0
Reputation: 4791
It doesn't support doing that. You should instead call .train() once for each of your outputs. That is, train separate predictors for each output variable.
Upvotes: 0