Logo ROOT   6.07/09
Reference Guide
MethodPyAdaBoost.h
Go to the documentation of this file.
1 // @(#)root/tmva/pymva $Id$
2 // Authors: Omar Zapata, Lorenzo Moneta, Sergei Gleyzer 2015
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodPyAdaBoost *
8  * Web : http://oproject.org *
9  * *
10  * Description: *
11  * scikit-learn Package AdaBoostClassifier method based on python *
12  * *
13  **********************************************************************************/
14 
15 #ifndef ROOT_TMVA_MethodPyAdaBoost
16 #define ROOT_TMVA_MethodPyAdaBoost
17 
18 //////////////////////////////////////////////////////////////////////////
19 // //
20 // MethodPyAdaBoost //
21 // //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "TMVA/PyMethodBase.h"
26 
27 #include "TString.h"
28 
29 namespace TMVA {
30 
31  class Factory; // DSMTEST
32  class Reader; // DSMTEST
33  class DataSetManager; // DSMTEST
34  class Types;
35  class MethodPyAdaBoost : public PyMethodBase {
36 
37  public :
38 
39  // constructors
40  MethodPyAdaBoost(const TString &jobName,
41  const TString &methodTitle,
42  DataSetInfo &theData,
43  const TString &theOption = "");
44 
46  const TString &theWeightFile);
47 
48 
49  ~MethodPyAdaBoost(void);
50  void Train();
51  // options treatment
52  void Init();
53  void DeclareOptions();
54  void ProcessOptions();
55  // create ranking
57  {
58  return NULL; // = 0;
59  }
60 
61 
62  Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets);
63 
64  // performs classifier testing
65  virtual void TestClassification();
66 
67 
68  Double_t GetMvaValue(Double_t *errLower = 0, Double_t *errUpper = 0);
69 
70  virtual void ReadModelFromFile();
71 
73  // the actual "weights"
74  virtual void AddWeightsXMLTo(void * /*parent */ ) const {} // = 0;
75  virtual void ReadWeightsFromXML(void * /*wghtnode*/ ) {} // = 0;
76  virtual void ReadWeightsFromStream(std::istream &) {} //= 0; // backward compatibility
77  private :
79  friend class Factory; // DSMTEST
80  friend class Reader; // DSMTEST
81  protected:
82 
83 
84  //AdaBoost options
85  TString base_estimator;//object, optional (default=DecisionTreeClassifier)
86  //The base estimator from which the boosted ensemble is built.
87  //Support for sample weighting is required, as well as proper `classes_`
88  //and `n_classes_` attributes.
89  Int_t n_estimators;//integer, optional (default=10)
90  //The number of trees in the forest.
91  Double_t learning_rate;//loat, optional (default=1.)
92  //Learning rate shrinks the contribution of each classifier by
93  //``learning_rate``. There is a trade-off between ``learning_rate`` and ``n_estimators``.
94  TString algorithm;//{'SAMME', 'SAMME.R'}, optional (default='SAMME.R')
95  //If 'SAMME.R' then use the SAMME.R real boosting algorithm.
96  //``base_estimator`` must support calculation of class probabilities.
97  //If 'SAMME' then use the SAMME discrete boosting algorithm.
98  //The SAMME.R algorithm typically converges faster than SAMME,
99  //achieving a lower test error with fewer boosting iterations.
100  TString random_state;//int, RandomState instance or None, optional (default=None)
101  //If int, random_state is the seed used by the random number generator;
102  //If RandomState instance, random_state is the random number generator;
103  //If None, the random number generator is the RandomState instance used by `np.random`.
104  // get help message text
105  void GetHelpMessage() const;
106 
107 
109  };
110 } // namespace TMVA
111 #endif
EAnalysisType
Definition: Types.h:128
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void TestClassification()
initialization
#define ClassDef(name, id)
Definition: Rtypes.h:254
DataSetManager * fDataSetManager
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
virtual void ReadWeightsFromXML(void *)
virtual void ReadWeightsFromStream(std::istream &)
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void AddWeightsXMLTo(void *) const
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
const Ranking * CreateRanking()
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
Abstract ClassifierFactory template that handles arbitrary types.
#define NULL
Definition: Rtypes.h:82
virtual void ReadModelFromFile()
virtual void ReadWeightsFromStream(std::istream &)=0
MethodPyAdaBoost(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")