Skip to content
Prev Previous commit
Next Next commit
[TMVA] DataSet - Add method DeleteAllResults
When doing CV, we reuse the same DataSet (and the corresponding list of
results). Thus we need to empty the DataSet results between folds.
A convenient way of doing this was missing.
  • Loading branch information
ashlaban committed Apr 18, 2018
commit cf0eec585e5d570aa8d2b351e2f0a238ffce6009
2 changes: 2 additions & 0 deletions tmva/tmva/inc/TMVA/DataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ namespace TMVA {
void DeleteResults ( const TString &,
Types::ETreeType type,
Types::EAnalysisType analysistype );
void DeleteAllResults(Types::ETreeType type,
Types::EAnalysisType analysistype);

void SetVerbose( Bool_t ) {}

Expand Down
29 changes: 29 additions & 0 deletions tmva/tmva/src/DataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,35 @@ void TMVA::DataSet::DeleteResults( const TString & resultsName,
<< " of type " << type << " which I should have deleted" << Endl;
}
}

////////////////////////////////////////////////////////////////////////////////
/// Deletes all results currently in the dataset.
///
void TMVA::DataSet::DeleteAllResults(Types::ETreeType type,
Types::EAnalysisType /* analysistype */ )
{
if (fResults.empty()) return;

if (UInt_t(type) > fResults.size()){
Log()<<kFATAL<< Form("Dataset[%s] : ",fdsi->GetName()) << "you asked for an Treetype (training/testing/...)"
<< " whose index " << type << " does not exist " << Endl;
}

std::map<TString, Results *> & resultsForType = fResults[UInt_t(type)];

for (auto && it : resultsForType) {
auto & resultsName = it.first;

Log() << kDEBUG << Form("Dataset[%s] : ", fdsi->GetName())
<< " DeleteAllResults previous existing result: "
<< resultsName << " of type " << type << Endl;

delete it.second;
}

resultsForType.clear();
}

////////////////////////////////////////////////////////////////////////////////
/// divide training set

Expand Down