Hi, Thanks for having a look.
I have read [2] and, as far as I understand, the discussion is about the updating of the parameters in the GUI after the learning, but not about whether the optimization is really done or not. I will fill a bug report so that the issue is tracked. Thank you. Jordi Julien Michel <[email protected]> wrote: > > Hi Jordi and Benjamin, > > If you read it in the code, then it must be true ... I am pretty sure > we had this tested but it seems not according to [1]. I remember > discussions about this when we developed the OpenCV ML models, and I > found the following Jira task and discussion about it [2]. > > But I would need some hint from the development team on this issue. > > Whatever comes out, this is at least worth a bug report. > > Regards, > > Julien > > [1] > http://hg.orfeo-toolbox.org/OTB/file/9890c6c5f335/Testing/Code/Learning/otbTrainMachineLearningModel.cxx > [2] http://scrum.orfeo-toolbox.org/jira/browse/OTB-454 > > Le 25/03/2014 15:37, Jordi Inglada a écrit : >> Jordi Inglada >> <jordi.inglada-L4RxXcqyP7Z0EDqhht/[email protected]> >> wrote: >>> Hi, >>> >>> I have had a look at the code, and in otbSVMMachineLearningModel.txx (about >>> line 79) we have this: >>> // Train the SVM >>> if (!m_ParameterOptimization) >>> { >>> m_SVMModel->train(samples, labels, cv::Mat(), cv::Mat(), params); >>> } >>> else >>> { >>> //Trains SVM with optimal parameters. >>> //train_auto(const Mat& trainData, const Mat& responses, const Mat& >>> varIdx, const Mat& sampleIdx, >>> //CvSVMParams params, int k_fold=10, CvParamGrid >>> Cgrid=CvSVM::get_default_grid(CvSVM::C), >>> //CvParamGrid gammaGrid=CvSVM::get_default_grid(CvSVM::GAMMA), >>> //CvParamGrid pGrid=CvSVM::get_default_grid(CvSVM::P), CvParamGrid >>> nuGrid=CvSVM::get_default_grid(CvSVM::NU), >>> //CvParamGrid coeffGrid=CvSVM::get_default_grid(CvSVM::COEF), >>> CvParamGrid degreeGrid=CvSVM::get_default_grid(CvSVM::DEGREE), >>> //bool balanced=false) >>> //We used default parameters grid. If not enough, those grids should >>> be expose to the user. >>> m_SVMModel->train_auto(samples, labels, cv::Mat(), cv::Mat(), params); >>> } >>> >>> So the train_auto method is called and it should work. However, reading the >>> OpenCV documentation >>> (http://docs.opencv.org/modules/ml/doc/support_vector_machines.html#cvsvm) >>> I see this: >>> >>> >>> "If there is no need to optimize a parameter, the corresponding grid step >>> should be set to any value less than or equal to 1. For example, to avoid >>> optimization in gamma, set gamma_grid.step = 0, gamma_grid.min_val, >>> gamma_grid.max_val as arbitrary numbers. In this case, the value >>> params.gamma is taken for gamma." >>> >>> I understand that if the grid steps are < 1 there is no optimization. And >>> the default constructor for the parameter grids is this: >>> >>> CvParamGrid::CvParamGrid() >>> { >>> min_val = max_val = step = 0; >>> } >>> >>> So I guess that the optimization is not done. >>> >>> Can anybody confirm this hypothesis? >>> >> To add some information, Benjamin has used libSVM instead of >> OpenCV's SVM (just choosing the other option in the application) and >> the parameter optimization works. >> >> Is this a big or are we doing something wrong? >> >> Thanks. >> >> Jordi >> >>> Thank you. >>> >>> Jordi >>> >>> Benjamin Tardy >>> <tardybenjamin4-re5jqeeqqe8avxtiumwx3w-xmd5yjdbdmrexy1tmh2ibg-xmd5yjdbdmrexy1tmh2...@public.gmane.org> >>> wrote: >>>> Hello, >>>> >>>> I'm trying to use TrainImageClassifier Application, with svm model and >>>> optimization. >>>> >>>> OTB Version:3.18.1 >>>> >>>> I set all parameters with SetParameter...: >>>> >>>> model= otb.Registry.CreateApplication("TrainImagesClassifier") >>>> >>>> model.SetParameterStringList("io.il","im.tif") >>>> >>>> model.SetParameterStringList("io.vd","training.shp") >>>> >>>> model.SetParameterString("io.imstat","stats.xml") >>>> >>>> model.SetParameterString("io.confmatout","mat.csv") >>>> >>>> model.SetParameterString("io.out","model.svm") >>>> >>>> model.SetParameterFloat("sample.vtr",0.5) >>>> >>>> model.SetParameterString("sample.vfn","Class") >>>> >>>> model.SetParameterString("classifier","svm") >>>> >>>> model.SetParameterString("classifier.svm.m","csvc") >>>> >>>> model.SetParameterString("classifier.svm.k","rbf") >>>> >>>> model.SetParameterFloat("classifier.svm.c",1) >>>> >>>> model.SetParameterFloat("classifier.svm.gamma",1) >>>> >>>> model.SetParameterInt("rand",3) >>>> >>>> model.SetParameterInt("classifier.svm.opt",0) >>>> >>>> model.ExecuteAndWriteOutput() >>>> >>>> This program works and gives results. But when I change the >>>> classifier.svm.opt to 1: I got same results and >>>> confusion matrix. >>>> I try to use model.SetParameterString("classifier.svm.opt",true) and >>>> false, but nothing change. >>>> I use the command line application too, with parameter 0,1 and >>>> true,false,and change default values for c and >>>> gamma ( 1 to 100000 or 0.5), always same results... >>>> >>>> Any help is welcome >>>> Thank you, >>>> >>>> Benjamin >>>> >>>> -- >>>> -- >>>> Check the OTB FAQ at >>>> http://www.orfeo-toolbox.org/FAQ.html >>>> You received this message because you are subscribed to the >>>> Google >>>> Groups "otb-users" group. >>>> To post to this group, send email to >>>> otb-users-/[email protected] >>>> To unsubscribe from this group, send email to >>>> otb-users+unsubscribe-/[email protected] >>>> For more options, visit this group at >>>> http://groups.google.com/group/otb-users?hl=en >>>> --- >>>> You received this message because you are subscribed to the Google Groups >>>> "otb-users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an >>>> email to otb-users+unsubscribe-/ >>>> JYPxA39Uh5TLH3MbocFFw-XMD5yJDbdMReXY1tMh2IBuG/[email protected] >>>> For more options, visit https://groups.google.com/d/optout. >>> -- > > > -- > Julien MICHEL > CNES - DCT/SI/AP - BPI 1219 > 18, avenue Edouard Belin > 31401 Toulouse Cedex 09 - France > Tel: +33 561 282 894 - Fax: +33 561 283 109 > > -- -- -- Check the OTB FAQ at http://www.orfeo-toolbox.org/FAQ.html You received this message because you are subscribed to the Google Groups "otb-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/otb-users?hl=en --- You received this message because you are subscribed to the Google Groups "otb-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
