Expert for the Python MVA method.
More...
#include <Python.h>
Expert for the Python MVA method.
Definition at line 115 of file Python.h.
◆ apply() [1/2]
std::vector< float > apply |
( |
Dataset & |
test_data | ) |
const |
|
overridevirtual |
Apply this expert onto a dataset.
- Parameters
-
Implements Expert.
Definition at line 412 of file Python.cc.
415 uint64_t numberOfFeatures = test_data.getNumberOfFeatures();
416 uint64_t numberOfEvents = test_data.getNumberOfEvents();
418 auto X = std::unique_ptr<float[]>(
new float[numberOfEvents * numberOfFeatures]);
419 npy_intp dimensions_X[2] = {
static_cast<npy_intp
>(numberOfEvents),
static_cast<npy_intp
>(numberOfFeatures)};
421 for (uint64_t iEvent = 0; iEvent < numberOfEvents; ++iEvent) {
422 test_data.loadEvent(iEvent);
424 for (uint64_t iFeature = 0; iFeature < numberOfFeatures; ++iFeature)
425 X[iEvent * numberOfFeatures + iFeature] = (test_data.m_input[iFeature] -
m_means[iFeature]) /
m_stds[iFeature];
427 for (uint64_t iFeature = 0; iFeature < numberOfFeatures; ++iFeature)
428 X[iEvent * numberOfFeatures + iFeature] = test_data.m_input[iFeature];
432 std::vector<float> probabilities(test_data.getNumberOfEvents());
435 auto ndarray_X = boost::python::handle<>(PyArray_SimpleNewFromData(2, dimensions_X, NPY_FLOAT32, X.get()));
437 for (uint64_t iEvent = 0; iEvent < numberOfEvents; ++iEvent) {
440 probabilities[iEvent] =
static_cast<float>(*
static_cast<float*
>(PyArray_GETPTR1(
reinterpret_cast<PyArrayObject*
>(result.ptr()),
446 B2ERROR(
"Failed calling applying PythonExpert");
447 throw std::runtime_error(
"Failed calling applying PythonExpert");
450 return probabilities;
◆ apply() [2/2]
virtual std::vector<float> apply |
( |
Dataset & |
test_data, |
|
|
const unsigned int |
classID |
|
) |
| const |
|
inlinevirtualinherited |
Apply this expert onto a dataset.
Multi-class mode signature. Not pure virtual, since not all derived classes need to re-implement this.
- Parameters
-
test_data | dataset |
classID | class identifier. |
Reimplemented in TMVAExpertMulticlass.
Definition at line 59 of file Expert.h.
◆ load()
Load the expert from a Weightfile.
- Parameters
-
weightfile | containing all information necessary to build the expert |
Implements Expert.
Definition at line 374 of file Python.cc.
The documentation for this class was generated from the following files: