77 const auto actualPositive = fPrimaryClusters.Retrieve();
78 const auto actualNegative = fSecondaryClusters.Retrieve();
79 const auto predictedPositive = fPredictedNeutrons.Retrieve();
88 fMult[predictedPositive.size()]++;
90 double truePositives = 0.;
91 for (
const auto&
c : actualPositive)
93 for (
const auto& n : predictedPositive)
102 const double falseNegatives = (double)actualPositive.size() - truePositives;
103 fTP += truePositives;
104 fhTP->Fill(truePositives);
105 fFN += falseNegatives;
106 fhFN->Fill(falseNegatives);
108 double falsePositives = 0.;
109 for (
const auto&
c : actualNegative)
111 for (
const auto& n : predictedPositive)
120 const double trueNegatives = (double)actualNegative.size() - falsePositives;
121 fFP += falsePositives;
122 fhFP->Fill(falsePositives);
123 fTN += trueNegatives;
124 fhTN->Fill(trueNegatives);
126 const double precision = truePositives / (truePositives + falsePositives);
127 const double recall = truePositives / (truePositives + falseNegatives);
129 auto Fbeta = [&](
double beta)
131 if (precision == 0. && recall == 0.)
133 return (1. + beta * beta) * (precision * recall) / ((beta * beta * precision) + recall);
135 fhF1->Fill(Fbeta(1.));
140 TDirectory* tmp = gDirectory;
141 FairRootManager::Instance()->GetOutFile()->cd();
143 gDirectory->mkdir(fPredictedName +
"Statistics");
144 gDirectory->cd(fPredictedName +
"Statistics");
154 const double precision = (double)fTP / ((
double)fTP + (
double)fFP);
155 const double recall = (double)fTP / ((
double)fTP + (
double)fFN);
156 auto Fbeta = [&](
double beta)
157 {
return (1. + beta * beta) * (precision * recall) / ((beta * beta * precision) + recall); };
158 const double accuracy = (double)(fTP + fTN) / (double)(fTP + fTN + fFP + fFN);
160 fOut <<
"PREC DATA\n";
161 fOut << fPredictedName <<
"\tTruePositive \t" << fTP <<
"\t" << (double)fTP / ((
double)fTP + (
double)fFN) <<
"\n"
162 << fPredictedName <<
"\tFalsePositive\t" << fFP <<
"\t" << (double)fFP / ((
double)fTN + (
double)fFP) <<
"\n"
163 << fPredictedName <<
"\tFalseNegative\t" << fFN <<
"\t" << (double)fFN / ((
double)fTP + (
double)fFN) <<
"\n"
164 << fPredictedName <<
"\tTrueNegative \t" << fTN <<
"\t" << (double)fTN / ((
double)fTN + (
double)fFP) <<
"\n"
165 << fPredictedName <<
"\tAccuracy\t" << accuracy <<
"\n"
166 << fPredictedName <<
"\tPrecision\t" << precision <<
"\n"
167 << fPredictedName <<
"\tSensitivity\t" << recall <<
"\n"
168 << fPredictedName <<
"\tF1\t" << Fbeta(1.) <<
"\n"
171 fOut <<
"MULT DATA\n";
172 const int sum = std::accumulate(fMult.begin(), fMult.end(), 0);
173 for (
unsigned int i = 0; i < fMult.size(); i++)
175 fOut << i <<
"\t" << fMult[i] <<
"\t" << (double)fMult[i] / (
double)sum <<
"\n";
177 fOut <<
"END" << std::endl;