55 DeclareOptionRef(fEncapsulatedMethodName,
"EncapsulatedMethodName",
"");
56 DeclareOptionRef(fEncapsulatedMethodTypeName,
"EncapsulatedMethodTypeName",
"");
57 DeclareOptionRef(fNumFolds,
"NumFolds",
"Number of folds to generate");
58 DeclareOptionRef(fOutputEnsembling =
TString(
"None"),
"OutputEnsembling",
59 "Combines output from contained methods. If None, no combination is performed. (default None)");
62 DeclareOptionRef(fSplitExprString,
"SplitExpr",
"The expression used to assign events to folds");
78 Log() << kDEBUG <<
"ProcessOptions -- fNumFolds: " << fNumFolds <<
Endl;
79 Log() << kDEBUG <<
"ProcessOptions -- fEncapsulatedMethodName: " << fEncapsulatedMethodName <<
Endl;
80 Log() << kDEBUG <<
"ProcessOptions -- fEncapsulatedMethodTypeName: " << fEncapsulatedMethodTypeName <<
Endl;
82 if (fSplitExprString !=
TString(
"")) {
83 fSplitExpr = std::unique_ptr<CvSplitKFoldsExpr>(
new CvSplitKFoldsExpr(DataInfo(), fSplitExprString));
100 fMulticlassValues = std::vector<Float_t>(DataInfo().GetNClasses());
101 fRegressionValues = std::vector<Float_t>(DataInfo().GetNTargets());
115 if (
iFold >= fNumFolds) {
116 Log() << kFATAL <<
iFold <<
" out of range. "
117 <<
"Should be < " << fNumFolds <<
"." <<
Endl;
159 Log() << kFATAL <<
"MethodCategory not supported for the moment." <<
Endl;
166 m->SetAnalysisType(fAnalysisType);
168 m->ReadStateFromFile();
185 gTools().
AddAttr(
wght,
"EncapsulatedMethodTypeName", fEncapsulatedMethodTypeName);
212 gTools().
ReadAttr(parent,
"EncapsulatedMethodName", fEncapsulatedMethodName);
213 gTools().
ReadAttr(parent,
"EncapsulatedMethodTypeName", fEncapsulatedMethodTypeName);
226 if (fSplitExprString !=
TString(
"")) {
227 fSplitExpr = std::unique_ptr<CvSplitKFoldsExpr>(
new CvSplitKFoldsExpr(DataInfo(), fSplitExprString));
229 Log() << kFATAL <<
"MethodCrossValidation supports XML reading only for deterministic splitting !" <<
Endl;
239 Log() << kFATAL <<
"CrossValidation currently supports only reading from XML." <<
Endl;
249 if (fOutputEnsembling ==
"None") {
250 if (fSplitExpr !=
nullptr) {
253 return fEncapsulatedMethods.at(
iFold)->GetMvaValue(err,
errUpper);
256 UInt_t iFold = fEventToFoldMapping.at(Data()->GetEvent());
257 return fEncapsulatedMethods.at(
iFold)->GetMvaValue(err,
errUpper);
259 }
else if (fOutputEnsembling ==
"Avg") {
261 for (
auto &
m : fEncapsulatedMethods) {
264 return val / fEncapsulatedMethods.size();
266 Log() << kFATAL <<
"Ensembling type " << fOutputEnsembling <<
" unknown" <<
Endl;
278 if (fOutputEnsembling ==
"None") {
279 if (fSplitExpr !=
nullptr) {
282 return fEncapsulatedMethods.at(
iFold)->GetMulticlassValues();
285 UInt_t iFold = fEventToFoldMapping.at(Data()->GetEvent());
286 return fEncapsulatedMethods.at(
iFold)->GetMulticlassValues();
288 }
else if (fOutputEnsembling ==
"Avg") {
290 for (
auto &
e : fMulticlassValues) {
294 for (
auto &
m : fEncapsulatedMethods) {
301 for (
auto &
e : fMulticlassValues) {
302 e /= fEncapsulatedMethods.size();
305 return fMulticlassValues;
308 Log() << kFATAL <<
"Ensembling type " << fOutputEnsembling <<
" unknown" <<
Endl;
309 return fMulticlassValues;
320 if (fOutputEnsembling ==
"None") {
321 if (fSplitExpr !=
nullptr) {
324 return fEncapsulatedMethods.at(
iFold)->GetRegressionValues();
327 UInt_t iFold = fEventToFoldMapping.at(Data()->GetEvent());
328 return fEncapsulatedMethods.at(
iFold)->GetRegressionValues();
330 }
else if (fOutputEnsembling ==
"Avg") {
332 for (
auto &
e : fRegressionValues) {
336 for (
auto &
m : fEncapsulatedMethods) {
343 for (
auto &
e : fRegressionValues) {
344 e /= fEncapsulatedMethods.size();
347 return fRegressionValues;
350 Log() << kFATAL <<
"Ensembling type " << fOutputEnsembling <<
" unknown" <<
Endl;
351 return fRegressionValues;
372 <<
"Method CrossValidation should not be created manually,"
373 " only as part of using TMVA::Reader."
401 Log() << kWARNING <<
"MakeClassSpecific not implemented for CrossValidation" <<
Endl;
409 Log() << kWARNING <<
"MakeClassSpecificHeader not implemented for CrossValidation" <<
Endl;
#define REGISTER_METHOD(CLASS)
for example
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TSystem * gSystem
static ClassifierFactory & Instance()
access to the ClassifierFactory singleton creates the instance if needed
Class that contains all the data information.
Virtual base Class for all MVA method.
virtual void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
friend class MethodCrossValidation
void Train(void) override
Call the Optimizer with the set of parameters and ranges that are meant to be tuned.
const Ranking * CreateRanking() override
void WriteMonitoringHistosToFile(void) const override
write special monitoring histograms to file dummy implementation here --------------—
void GetHelpMessage() const override
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override
void AddWeightsXMLTo(void *parent) const override
Write weights to XML.
void DeclareCompatibilityOptions() override
Options that are used ONLY for the READER to ensure backward compatibility.
void Init(void) override
Common initialisation with defaults for the Method.
void MakeClassSpecific(std::ostream &, const TString &) const override
Make ROOT-independent C++ class for classifier response (classifier-specific implementation).
TString GetWeightFileNameForFold(UInt_t iFold) const
Returns filename of weight file for a given fold.
const std::vector< Float_t > & GetMulticlassValues() override
Get the multiclass MVA response.
MethodBase * InstantiateMethodFromXML(TString methodTypeName, TString weightfile) const
Reads in a weight file an instantiates the corresponding method.
void ReadWeightsFromStream(std::istream &istr) override
Read the weights.
void ProcessOptions() override
The option string is decoded, for available options see "DeclareOptions".
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr) override
void Reset(void) override
Reset the method, as if it had just been instantiated (forget all training etc.).
const std::vector< Float_t > & GetRegressionValues() override
Get the regression value generated by the containing methods.
void ReadWeightsFromXML(void *parent) override
Reads from the xml file.
void MakeClassSpecificHeader(std::ostream &, const TString &) const override
Specific class header.
virtual ~MethodCrossValidation(void)
Destructor.
void DeclareOptions() override
Ranking for variables in method (implementation)
Singleton class for Global types used by TMVA.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
create variable transformations
MsgLogger & Endl(MsgLogger &ml)