46 const std::vector<Float_t> &mvaWeights)
49 assert(mvaValues.size() == mvaTargets.size());
50 assert(mvaValues.size() == mvaWeights.size());
52 for (
UInt_t i = 0; i < mvaValues.size(); i++) {
69 assert(mvaValues.size() == mvaTargets.size());
71 for (
UInt_t i = 0; i < mvaValues.size(); i++) {
94 const std::vector<Float_t> &mvaSignalWeights,
const std::vector<Float_t> &mvaBackgroundWeights)
97 assert(mvaSignal.size() == mvaSignalWeights.size());
98 assert(mvaBackground.size() == mvaBackgroundWeights.size());
117 if (num_points <= 2) {
121 UInt_t num_divisions = num_points - 1;
122 std::vector<Double_t> specificity_vector;
123 specificity_vector.push_back(0.0);
125 for (
Double_t threshold = -1.0; threshold < 1.0; threshold += (1.0 / num_divisions)) {
133 if (value > threshold) {
134 false_positives += weight;
136 true_negatives += weight;
140 Double_t total_background = false_positives + true_negatives;
142 (total_background <= std::numeric_limits<Double_t>::min()) ? (0.0) : (true_negatives / total_background);
144 specificity_vector.push_back(specificity);
147 specificity_vector.push_back(1.0);
148 return specificity_vector;
156 if (num_points <= 2) {
160 UInt_t num_divisions = num_points - 1;
161 std::vector<Double_t> sensitivity_vector;
162 sensitivity_vector.push_back(1.0);
164 for (
Double_t threshold = -1.0; threshold < 1.0; threshold += (1.0 / num_divisions)) {
168 for (
size_t i = 0; i <
fMvaSignal.size(); ++i) {
172 if (value > threshold) {
173 true_positives += weight;
175 false_negatives += weight;
179 Double_t total_signal = true_positives + false_negatives;
181 (total_signal <= std::numeric_limits<Double_t>::min()) ? (0.0) : (true_positives / total_signal);
182 sensitivity_vector.push_back(sensitivity);
185 sensitivity_vector.push_back(0.0);
186 return sensitivity_vector;
201 assert(0.0 <= effB and effB <= 1.0);
207 auto complement = [](
Double_t x) {
return 1 -
x; };
208 std::transform(effB_vec.begin(), effB_vec.end(), effB_vec.begin(), complement);
211 std::reverse(effS_vec.begin(), effS_vec.end());
212 std::reverse(effB_vec.begin(), effB_vec.end());
218 return rocSpline.Eval(effB);
236 for (
UInt_t i = 0; i < sensitivity.size() - 1; i++) {
238 Double_t currFnr = 1 - sensitivity[i];
239 Double_t nextFnr = 1 - sensitivity[i + 1];
241 integral += 0.5 * (nextFnr - currFnr) * (specificity[i] + specificity[i + 1]);
265 fGraph =
new TGraph(sensitivity.size(), &sensitivity[0], &specificity[0]);
std::vector< Float_t > fMvaSignal
Double_t GetEffSForEffB(Double_t effB, const UInt_t num_points=41)
Calculate the signal efficiency (sensitivity) for a given background efficiency (sensitivity).
ROCCurve(const std::vector< Float_t > &mvaValues, const std::vector< Bool_t > &mvaTargets, const std::vector< Float_t > &mvaWeights)
Double_t GetROCIntegral(const UInt_t points=41)
Calculates the ROC integral (AUC)
std::vector< Double_t > ComputeSpecificity(const UInt_t num_points)
std::vector< Float_t > fMvaSignalWeights
Linear interpolation of TGraph.
ostringstream derivative to redirect and format output
std::vector< Double_t > ComputeSensitivity(const UInt_t num_points)
Abstract ClassifierFactory template that handles arbitrary types.
TGraph * GetROCCurve(const UInt_t points=100)
Returns a new TGraph containing the ROC curve.
A Graph is a graphics object made of two arrays X and Y with npoints each.
std::vector< Float_t > fMvaBackgroundWeights
std::vector< Float_t > fMvaBackground