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?
Thank you.
Jordi
Benjamin Tardy <[email protected]> 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-/
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
--
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.