Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main Repositories
otb
Commits
05a28a67
Commit
05a28a67
authored
11 years ago
by
Arnaud Jaen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Parameters optimization for svm machine learning model, using default opencv grid
parent
db0e15b4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h
+4
-0
4 additions, 0 deletions
Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h
Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx
+12
-1
12 additions, 1 deletion
Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx
with
16 additions
and
1 deletion
Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.h
+
4
−
0
View file @
05a28a67
...
...
@@ -115,6 +115,9 @@ public:
itkGetMacro
(
P
,
double
);
itkSetMacro
(
P
,
double
);
itkGetMacro
(
ParameterOptimization
,
bool
);
itkSetMacro
(
ParameterOptimization
,
bool
);
protected:
/** Constructor */
SVMMachineLearningModel
();
...
...
@@ -141,6 +144,7 @@ private:
double
m_C
;
double
m_Nu
;
double
m_P
;
bool
m_ParameterOptimization
;
};
}
// end namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/UtilitiesAdapters/OpenCV/otbSVMMachineLearningModel.txx
+
12
−
1
View file @
05a28a67
...
...
@@ -63,7 +63,18 @@ SVMMachineLearningModel<TInputValue,TOutputValue>
CvSVMParams params( m_SVMType, m_KernelType, m_Degree, m_Gamma, m_Coef0, m_C, m_Nu, m_P, NULL , term_crit );
// Train the SVM
m_SVMModel->train(samples, labels, cv::Mat(), cv::Mat(), params);
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);
}
template <class TInputValue, class TOutputValue>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment