Skip to content

Commit a9f317f

Browse files
committed
Please consider the following formatting changes
1 parent 97800fe commit a9f317f

1 file changed

Lines changed: 59 additions & 62 deletions

File tree

PWGHF/Core/HfAeToMseXicToPKPi.h

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class HfAeToMseXicToPKPi : public HfMlResponse<TypeOutputScore>
3434

3535
void setMinMaxScaling(std::vector<float>& yOut, std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
3636
{
37-
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
38-
for (size_t j = 0; j < yIn.size(); ++j){ // loop for over the features
37+
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
38+
for (size_t j = 0; j < yIn.size(); ++j) { // loop for over the features
3939
// MinMax scaling of the input features
4040
LOG(debug) << "--------------> MinMax scaling Debug \t" << scaleMin.at(j) << "\t" << scaleMax.at(j);
41-
yOut.push_back((yIn.at(j) - scaleMin.at(j)) / (scaleMax.at(j)- scaleMin.at(j)));
41+
yOut.push_back((yIn.at(j) - scaleMin.at(j)) / (scaleMax.at(j) - scaleMin.at(j)));
4242
LOG(debug) << "Feature = " << j << " ----> input = " << yIn.at(j) << " scaled feature = " << yOut.at(j);
4343
}
4444
}
@@ -50,76 +50,73 @@ class HfAeToMseXicToPKPi : public HfMlResponse<TypeOutputScore>
5050
LOG(debug) << "No external preprocessing transformation will be applied";
5151
yScaled.assign(yIn.begin(), yIn.end());
5252
} else {
53-
if (scaleType == 1) {
54-
LOG(debug) << "MinMax scaling will be applied";
55-
setMinMaxScaling(yScaled, yIn, scaleMin, scaleMax);
56-
} // ... with scaleType > 1 we could add other preprocessing trasformations
57-
}
53+
if (scaleType == 1) {
54+
LOG(debug) << "MinMax scaling will be applied";
55+
setMinMaxScaling(yScaled, yIn, scaleMin, scaleMax);
56+
} // ... with scaleType > 1 we could add other preprocessing trasformations
57+
}
5858
}
5959
std::vector<float> getPreprocessedFeatures()
6060
{
6161
for (size_t j = 0; j < yScaled.size(); ++j)
6262
LOG(debug) << "Global scaled feature = " << yScaled.at(j);
63-
return yScaled;
63+
return yScaled;
6464
}
6565
// Reverse preprocessing - output postprocessing
6666
void unsetMinMaxScaling(std::vector<float>& yOut, std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
6767
{
68-
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
69-
for (size_t j = 0; j < yIn.size(); ++j){ // loop for over the features
70-
// MinMax scaling of the input features
71-
LOG(debug) << "--------------> MinMax unscaling Debug \t" << scaleMin.at(j) << "\t" << scaleMax.at(j);
72-
yOut.push_back(yIn.at(j)*(scaleMax.at(j)- scaleMin.at(j))+ scaleMin.at(j));
73-
LOG(debug) << "Unscaling output = " << j << " ----> input = " << yIn.at(j) << " rescaled output = " << yOut.at(j);
74-
}
75-
}
68+
yOut.clear(); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
69+
for (size_t j = 0; j < yIn.size(); ++j) { // loop for over the features
70+
// MinMax scaling of the input features
71+
LOG(debug) << "--------------> MinMax unscaling Debug \t" << scaleMin.at(j) << "\t" << scaleMax.at(j);
72+
yOut.push_back(yIn.at(j) * (scaleMax.at(j) - scaleMin.at(j)) + scaleMin.at(j));
73+
LOG(debug) << "Unscaling output = " << j << " ----> input = " << yIn.at(j) << " rescaled output = " << yOut.at(j);
74+
}
75+
}
7676

77-
void unsetScaling(bool scaleFlag, int scaleType, /*AE output*/ std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
78-
{ // it takes the bool flag and scaling parameters configurables in taskXic
79-
yOutRescaled.clear();
80-
if (scaleFlag == false) {
81-
LOG(debug) << "No external preprocessing transformation will be applied";
82-
yOutRescaled.assign(yIn.begin(), yIn.end());
83-
} else {
84-
if (scaleType == 1) {
85-
LOG(debug) << "MinMax unscaling will be applied";
86-
unsetMinMaxScaling(yOutRescaled, yIn, scaleMin, scaleMax);
87-
} //... with scaleType > 1 we could add other preprocessing trasformations
88-
}
89-
}
77+
void unsetScaling(bool scaleFlag, int scaleType, /*AE output*/ std::vector<float> yIn, std::vector<float> scaleMin, std::vector<float> scaleMax)
78+
{ // it takes the bool flag and scaling parameters configurables in taskXic
79+
yOutRescaled.clear();
80+
if (scaleFlag == false) {
81+
LOG(debug) << "No external preprocessing transformation will be applied";
82+
yOutRescaled.assign(yIn.begin(), yIn.end());
83+
} else {
84+
if (scaleType == 1) {
85+
LOG(debug) << "MinMax unscaling will be applied";
86+
unsetMinMaxScaling(yOutRescaled, yIn, scaleMin, scaleMax);
87+
} //... with scaleType > 1 we could add other preprocessing trasformations
88+
}
89+
}
9090

91-
std::vector<float> getPostprocessedOutput()
92-
{
93-
for (size_t j = 0; j < yOutRescaled.size(); ++j)
94-
LOG(debug)<<"Global rescaled AE output = "<< yOutRescaled.at(j);
95-
return yOutRescaled;
96-
}
97-
//---- MSE function
98-
float getMse(std::vector<float> yTrue, std::vector<float> yPred)
99-
{
100-
LOG(debug) << "Inside getMse sizes " << yTrue.size() << "\t" << yPred.size();
101-
float mse= 0.0f;
102-
float sum = 0.0f;
103-
for (size_t j = 0; j < yTrue.size(); ++j)
104-
LOG(debug) << "Local Feature = " << j << " ----> input = " << yTrue.at(j) << " scaled feature = " << yPred.at(j);
105-
std::vector<float> yTrueScaled = getPreprocessedFeatures(); // to make the input features adimensional
106-
if (yTrue.size() != yPred.size())
107-
{
108-
LOG(debug) << "size of input vector =" << yTrue.size();
109-
LOG(debug) << "size of AE output vector =" << yPred.size();
110-
LOG(fatal) << "vectors of input and predictions don't have the same size";
111-
}
112-
else
113-
{ //MSE
114-
for (size_t j = 0; j < yPred.size(); ++j) {
115-
sum += std::pow(((yTrueScaled).at(j) - (yPred).at(j)), 2); //AE model gives adimensional predictions by design choice
116-
LOG(debug) << "getMse Local feature = " << j << " ----> input = " << yTrueScaled.at(j) << " AE prediction = " << yPred.at(j);
117-
}
118-
mse = sum/yPred.size(); // MSE of a candidate
119-
LOG(debug) << "Local mse " << mse;
120-
}
121-
return mse;
122-
}
91+
std::vector<float> getPostprocessedOutput()
92+
{
93+
for (size_t j = 0; j < yOutRescaled.size(); ++j)
94+
LOG(debug) << "Global rescaled AE output = " << yOutRescaled.at(j);
95+
return yOutRescaled;
96+
}
97+
//---- MSE function
98+
float getMse(std::vector<float> yTrue, std::vector<float> yPred)
99+
{
100+
LOG(debug) << "Inside getMse sizes " << yTrue.size() << "\t" << yPred.size();
101+
float mse = 0.0f;
102+
float sum = 0.0f;
103+
for (size_t j = 0; j < yTrue.size(); ++j)
104+
LOG(debug) << "Local Feature = " << j << " ----> input = " << yTrue.at(j) << " scaled feature = " << yPred.at(j);
105+
std::vector<float> yTrueScaled = getPreprocessedFeatures(); // to make the input features adimensional
106+
if (yTrue.size() != yPred.size()) {
107+
LOG(debug) << "size of input vector =" << yTrue.size();
108+
LOG(debug) << "size of AE output vector =" << yPred.size();
109+
LOG(fatal) << "vectors of input and predictions don't have the same size";
110+
} else { // MSE
111+
for (size_t j = 0; j < yPred.size(); ++j) {
112+
sum += std::pow(((yTrueScaled).at(j) - (yPred).at(j)), 2); // AE model gives adimensional predictions by design choice
113+
LOG(debug) << "getMse Local feature = " << j << " ----> input = " << yTrueScaled.at(j) << " AE prediction = " << yPred.at(j);
114+
}
115+
mse = sum / yPred.size(); // MSE of a candidate
116+
LOG(debug) << "Local mse " << mse;
117+
}
118+
return mse;
119+
}
123120
}; // end of the class
124121

125122
} // namespace o2::analysis

0 commit comments

Comments
 (0)