Shark-ML / Shark

The Shark Machine Leaning Library. See more:
http://shark-ml.github.io/Shark/
GNU Lesser General Public License v3.0
493 stars 130 forks source link

argument list for class template "shark::RFClassifier" is missing #264

Open cydcydcyd opened 5 years ago

cydcydcyd commented 5 years ago

Hi, I download shark4.0 from https://github.com/Shark-ML/Shark/tree/4.0 I compile the library and try to use RFTrainer, and I get some errors like: Severity Code Description Project File Line Suppression State Error (active) argument list for class template "shark::RFClassifier" is missing forestCounting c:\Users\chenyuduo\Desktop\forestCounting\forestCounting\forestCounting\main.cpp 64

Severity Code Description Project File Line Suppression State Error (active) argument list for class template "shark::RFTrainer" is missing forestCounting c:\Users\chenyuduo\Desktop\forestCounting\forestCounting\forestCounting\main.cpp 65
Can you help me solve it?thanks

Ulfgard commented 5 years ago

Have you followed the tutorials?

http://www.shark-ml.org/sphinx_pages/build/html/rest_sources/tutorials/algorithms/rf.html

There is also a random forest example: https://github.com/Shark-ML/Shark/blob/master/examples/Supervised/RFTutorial.tpp

Ulfgard commented 5 years ago

I am not seeing your code, so i can only guess. Please note that examples, especially the ones i linkred, required you to define the template arguments:

RFClassifier model; RFTrainer trainer;

cydcydcyd commented 5 years ago

@Ulfgard Thank you. I read examples to solve the problem. Another problem is that RFTrainer is still slow in debug mode. Did you speed up?

Ulfgard commented 5 years ago

yeah, try it in release mode and allow your compiler to optimize the code.


From: cydcydcyd [notifications@github.com] Sent: Monday, February 25, 2019 1:55 AM To: Shark-ML/Shark Cc: Oswin Krause; Mention Subject: Re: [Shark-ML/Shark] argument list for class template "shark::RFClassifier" is missing (#264)

@Ulfgardhttps://github.com/Ulfgard Thank you. I read examples to solve the problem. Another problem is that RFTrainer is still slow in debug mode. Did you speed up?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Shark-ML/Shark/issues/264#issuecomment-466837436, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AOWTBkB1G9G4nG9yG_y6nFKQeqKAMYjLks5vQzSBgaJpZM4bIzmc.

cydcydcyd commented 5 years ago

hello,I try to use RFTrainer as regression, but the result is different from sklearn. here is some of my codes: data.shuffle(); data.makeIndependent(); RFTrainer<RealVector> trainer(false,false); trainer.setMaxDepth(10); trainer.setMinSplit(20); RFClassifier<RealVector> model; trainer.train(model, data); Data<RealVector> testInputs = createTestInputs(fMat); Data<RealVector> pred = model(testInputs);

Ulfgard commented 5 years ago

It is different implementations, therefore the result can be different. Also the whole algorithm is stochastic, meaning every run will lead to different results.

How different is it? Are you sure, all parameters are the same?


From: cydcydcyd [notifications@github.com] Sent: Tuesday, February 26, 2019 9:14 AM To: Shark-ML/Shark Cc: Oswin Krause; Mention Subject: Re: [Shark-ML/Shark] argument list for class template "shark::RFClassifier" is missing (#264)

hello,I try to use RFTrainer as regression, but the result is different from sklearn. here is some of my codes: data.shuffle(); data.makeIndependent(); RFTrainer trainer(false,false); trainer.setMaxDepth(10); trainer.setMinSplit(20); RFClassifier model; trainer.train(model, data); Data testInputs = createTestInputs(fMat); Data pred = model(testInputs);

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Shark-ML/Shark/issues/264#issuecomment-467340040, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AOWTBq0mSlRjOBwSZzSmvixpQL-3ZgFVks5vROzlgaJpZM4bIzmc.

cydcydcyd commented 5 years ago

The results are quite different and I'm not sure if I missed the key steps. I need to use OpenCV to calculate the feature of the images and the features in cv::Mat will be converted into shark::RealVector. LabeledData<RealVector, RealVector> labeleddata = createLabeledDataFromRange(inputs, outputs); WeightedLabeledData<RealVector, RealVector> data(labeleddata, 1.0f); I set weight of each feature to 1.

Ulfgard commented 5 years ago

so what are the results? just for comparison. You don't have to use wieghts, you can just use the labeleddata


From: cydcydcyd [notifications@github.com] Sent: Tuesday, February 26, 2019 9:38 AM To: Shark-ML/Shark Cc: Oswin Krause; Mention Subject: Re: [Shark-ML/Shark] argument list for class template "shark::RFClassifier" is missing (#264)

The results are quite different and I'm not sure if I missed the key steps. I need to use OpenCV to calculate the feature of the images and the features in cv::Mat will be converted into shark::RealVector. LabeledData<RealVector, RealVector> labeleddata = createLabeledDataFromRange(inputs, outputs); WeightedLabeledData<RealVector, RealVector> data(labeleddata, 1.0f); I set the all weights of features to 1.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Shark-ML/Shark/issues/264#issuecomment-467347456, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AOWTBiqBqa6F4yR2myAJngGToxd_GV0Oks5vRPKhgaJpZM4bIzmc.

cydcydcyd commented 5 years ago

My input feature is 637 dimensions, and the output tag is 49 dimensions. There are 2000 data in total. It takes 15sec to train with RFTrainer. Is this normal speed? I use release mode. image The parameter type of the train function is WeightedLabeledData < RealVector, RealVector >. I don't know how to do without weights.