23 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 24 #include <numpy/arrayobject.h> 26 #pragma GCC diagnostic ignored "-Wunused-parameter" 63 base_estimator("
None"),
74 base_estimator(
"None"),
102 The base estimator from which the boosted ensemble is built.\ 103 Support for sample weighting is required, as well as proper `classes_`\ 104 and `n_classes_` attributes.");
107 The maximum number of estimators at which boosting is terminated.\ 108 In case of perfect fit, the learning procedure is stopped early.");
111 Learning rate shrinks the contribution of each classifier by\ 112 ``learning_rate``. There is a trade-off between ``learning_rate`` and\ 116 If 'SAMME.R' then use the SAMME.R real boosting algorithm.\ 117 ``base_estimator`` must support calculation of class probabilities.\ 118 If 'SAMME' then use the SAMME discrete boosting algorithm.\ 119 The SAMME.R algorithm typically converges faster than SAMME,\ 120 achieving a lower test error with fewer boosting iterations.");
123 If int, random_state is the seed used by the random number generator;\ 124 If RandomState instance, random_state is the random number generator;\ 125 If None, the random number generator is the RandomState instance used\ 133 if (!pobase_estimator) {
135 <<
" The options are Object or None." 138 Py_DECREF(pobase_estimator);
141 Log() <<
kERROR <<
" NEstimators <=0... that does not work !! " 142 <<
" I set it to 10 .. just so that the program does not crash" 147 Log() <<
kERROR <<
" LearningRate <=0... that does not work !! " 148 <<
" I set it to 1.0 .. just so that the program does not crash" 155 <<
" The options are SAMME of SAMME.R." 159 if (!porandom_state) {
161 <<
"If int, random_state is the seed used by the random number generator;" 162 <<
"If RandomState instance, random_state is the random number generator;" 163 <<
"If None, the random number generator is the RandomState instance used by `np.random`." 166 Py_DECREF(porandom_state);
178 PyObject *pName = PyUnicode_FromString(
"sklearn.ensemble");
180 fModule = PyImport_Import(pName);
192 int *dims =
new int[2];
193 dims[0] = fNrowsTraining;
195 fTrainData = (PyArrayObject *)PyArray_FromDims(2, dims, NPY_FLOAT);
196 float *TrainData = (
float *)(PyArray_DATA(
fTrainData));
199 fTrainDataClasses = (PyArrayObject *)PyArray_FromDims(1, &fNrowsTraining, NPY_FLOAT);
202 fTrainDataWeights = (PyArrayObject *)PyArray_FromDims(1, &fNrowsTraining, NPY_FLOAT);
205 for (
int i = 0; i < fNrowsTraining; i++) {
207 for (
UInt_t j = 0; j < fNvars; j++) {
208 TrainData[j + i * fNvars] = e->
GetValue(j);
223 PyObject_Print(args, stdout, 0);
224 std::cout << std::endl;
226 PyObject *fClassifierClass = PyDict_GetItemString(pDict,
"AdaBoostClassifier");
229 if (PyCallable_Check(fClassifierClass)) {
231 fClassifier = PyObject_CallObject(fClassifierClass , args);
238 Py_DECREF(fClassifierClass);
239 Log() <<
kFATAL <<
"Can't call function AdaBoostClassifier" <<
Endl;
277 PyArrayObject *pEvent= (PyArrayObject *)PyArray_FromDims(2, dims, NPY_FLOAT);
278 float *pValue = (
float *)(PyArray_DATA(pEvent));
282 PyArrayObject *
result = (PyArrayObject *)PyObject_CallMethod(
fClassifier, const_cast<char *>(
"predict_proba"),
const_cast<char *
>(
"(O)"), pEvent);
283 double *proba = (
double *)(PyArray_DATA(result));
314 Log() <<
"Decision Trees and Rule-Based Models " <<
Endl;
const TString & GetWeightFileDir() const
MsgLogger & Endl(MsgLogger &ml)
#define REGISTER_METHOD(CLASS)
for example
const Event * GetTrainingEvent(Long64_t ievt) const
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
virtual void TestClassification()
initialization
static void Serialize(TString file, PyObject *classifier)
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not...
PyArrayObject * fTrainDataClasses
static int PyIsInitialized()
static void PyInitialize()
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
const char * Data() const
static PyObject * Eval(TString code)
PyArrayObject * fTrainDataWeights
UInt_t GetNVariables() const
accessor to the number of variables
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
char * Form(const char *fmt,...)
PyArrayObject * fTrainData
void GetHelpMessage() const
const Event * GetEvent() const
UInt_t GetNVariables() const
access the number of variables through the datasetinfo
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
Abstract ClassifierFactory template that handles arbitrary types.
virtual void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
Long64_t GetNTrainingEvents() const
virtual void ReadModelFromFile()
static void UnSerialize(TString file, PyObject **obj)
MethodPyAdaBoost(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
virtual void TestClassification()
initialization
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
Bool_t IsModelPersistence()