Commit ec370c36 authored by Guillaume Pasero's avatar Guillaume Pasero

BUG: Mantis-1159: fix computation of sampling rates when BoundByMin=off

parent 71a99b6d
......@@ -400,23 +400,30 @@ ListSampleGenerator<TImage, TVectorData>
itmap != m_ClassesSize.end();
++itmap)
{
m_ClassesProbTraining[itmap->first] = minSizeTraining / itmap->second;
m_ClassesProbValidation[itmap->first] = minSizeValidation / itmap->second;
if(!m_BoundByMin)
if (m_BoundByMin)
{
m_ClassesProbTraining[itmap->first] = minSizeTraining / itmap->second;
m_ClassesProbValidation[itmap->first] = minSizeValidation / itmap->second;
}
else
{
long int maxSizeT = (itmap->second)*(1.0 - m_ValidationTrainingProportion);
long int maxSizeV = (itmap->second)*m_ValidationTrainingProportion;
maxSizeT = (m_MaxTrainingSize == -1)?maxSizeT:m_MaxTrainingSize;
maxSizeV = (m_MaxValidationSize == -1)?maxSizeV:m_MaxValidationSize;
//not enough samples to respect the bounds
if(maxSizeT+maxSizeV > itmap->second)
// Check if max sizes respect the maximum bounds
double correctionRatioTrain = 1.0;
if((m_MaxTrainingSize > -1) && (m_MaxTrainingSize < maxSizeT))
{
correctionRatioTrain = (double)(m_MaxTrainingSize) / (double)(maxSizeT);
}
double correctionRatioValid = 1.0;
if((m_MaxValidationSize > -1) && (m_MaxValidationSize < maxSizeV))
{
maxSizeT = (itmap->second)*(1.0 - m_ValidationTrainingProportion);
maxSizeV = (itmap->second)*m_ValidationTrainingProportion;
correctionRatioValid = (double)(m_MaxValidationSize) / (double)(maxSizeV);
}
m_ClassesProbTraining[itmap->first] = maxSizeT/(itmap->second);
m_ClassesProbValidation[itmap->first] = maxSizeV/(itmap->second);
double correctionRatio = std::min(correctionRatioTrain,correctionRatioValid);
m_ClassesProbTraining[itmap->first] = correctionRatio*(1.0 - m_ValidationTrainingProportion);
m_ClassesProbValidation[itmap->first] = correctionRatio*m_ValidationTrainingProportion;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment