Пример #1
0
litiv::IMetricsCalculatorPtr litiv::IDatasetEvaluator_<litiv::eDatasetEval_BinaryClassifier>::getMetrics(bool bAverage) const {
    if(bAverage) {
        IDataHandlerPtrArray vpBatches = getBatches(true);
        auto ppBatchIter = vpBatches.begin();
        for(; ppBatchIter!=vpBatches.end() && !(*ppBatchIter)->getTotPackets(); ++ppBatchIter);
        CV_Assert(ppBatchIter!=vpBatches.end());
        IMetricsCalculatorPtr pMetrics = dynamic_cast<const IDataReporter_<eDatasetEval_BinaryClassifier>&>(**ppBatchIter).getMetrics(bAverage);
        for(; ppBatchIter!=vpBatches.end(); ++ppBatchIter)
            if((*ppBatchIter)->getTotPackets())
                pMetrics->accumulate(dynamic_cast<const IDataReporter_<eDatasetEval_BinaryClassifier>&>(**ppBatchIter).getMetrics(bAverage));
        return pMetrics;
    }
    return BinClassifMetricsCalculator::create(getMetricsBase());
}
Пример #2
0
 /// accumulates and returns high-level evaluation metrics, e.g. computes F-Measure from classification counters
 virtual IIMetricsCalculatorPtr getMetrics(bool bAverage) const override final {
     if(bAverage && this->isGroup() && !this->isBare()) {
         IDataHandlerPtrArray vpBatches = this->getBatches(true);
         auto ppBatchIter = vpBatches.begin();
         for(; ppBatchIter!=vpBatches.end() && (*ppBatchIter)->getCurrentOutputCount()==0; ++ppBatchIter) {}
         lvAssert_(ppBatchIter!=vpBatches.end(),"found no processed output packets");
         IIMetricsCalculatorPtr pMetrics = dynamic_cast<const IIMetricRetriever&>(**ppBatchIter).getMetrics(bAverage);
         for(; ppBatchIter!=vpBatches.end(); ++ppBatchIter)
             if((*ppBatchIter)->getCurrentOutputCount()>0)
                 pMetrics->accumulate(dynamic_cast<const IIMetricRetriever&>(**ppBatchIter).getMetrics(bAverage));
         return pMetrics;
     }
     return IIMetricsCalculator::create<MetricsCalculator_<eDatasetEval,eDataset>>(getMetricsBase());
 }