Skip to content
Snippets Groups Projects
Commit 731597df authored by Ludovic Hussonnois's avatar Ludovic Hussonnois
Browse files

COMP: Add check for empty unsupervised classifier.

parent 951a7888
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,9 @@ LearningApplicationBase<TInputValue,TOutputValue> ...@@ -60,7 +60,9 @@ LearningApplicationBase<TInputValue,TOutputValue>
InitUnsupervisedClassifierParams(); InitUnsupervisedClassifierParams();
std::vector<std::string> allClassifier = GetChoiceKeys("classifier"); std::vector<std::string> allClassifier = GetChoiceKeys("classifier");
m_UnsupervisedClassifier.assign(allClassifier.begin() + m_SupervisedClassifier.size(), allClassifier.end()); // Check for empty unsupervised classifier
if( allClassifier.size() > m_UnsupervisedClassifier.size() )
m_UnsupervisedClassifier.assign( allClassifier.begin() + m_SupervisedClassifier.size(), allClassifier.end() );
} }
template <class TInputValue, class TOutputValue> template <class TInputValue, class TOutputValue>
...@@ -68,10 +70,16 @@ typename LearningApplicationBase<TInputValue,TOutputValue>::ClassifierCategory ...@@ -68,10 +70,16 @@ typename LearningApplicationBase<TInputValue,TOutputValue>::ClassifierCategory
LearningApplicationBase<TInputValue,TOutputValue> LearningApplicationBase<TInputValue,TOutputValue>
::GetClassifierCategory() ::GetClassifierCategory()
{ {
bool foundUnsupervised = if( m_UnsupervisedClassifier.empty() )
std::find(m_UnsupervisedClassifier.begin(), m_UnsupervisedClassifier.end(), {
GetParameterString("classifier")) != m_UnsupervisedClassifier.end(); return Supervised;
return foundUnsupervised ? Unsupervised : Supervised; }
else
{
bool foundUnsupervised = std::find( m_UnsupervisedClassifier.begin(), m_UnsupervisedClassifier.end(),
GetParameterString( "classifier" ) ) != m_UnsupervisedClassifier.end();
return foundUnsupervised ? Unsupervised : Supervised;
}
} }
template <class TInputValue, class TOutputValue> template <class TInputValue, class TOutputValue>
...@@ -202,7 +210,7 @@ LearningApplicationBase<TInputValue,TOutputValue> ...@@ -202,7 +210,7 @@ LearningApplicationBase<TInputValue,TOutputValue>
#endif #endif
} }
// OpenCV SVM implementation is buggy with linear kernel // OpenCV SVM implementation is buggy with linear kernel
// Users should use the libSVM implementation instead. // Users should use the libSVM implementation instead.
// else if (modelName == "svm") // else if (modelName == "svm")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment