@@ -33,79 +33,79 @@ namespace o2::analysis
3333 std::vector<float > yScaled, yOutRescaled;
3434 // private :
3535 void setMinMaxScaling (std::vector<float >& yOut, std::vector<float > yIn, std::vector<float > scaleMin, std::vector<float > scaleMax)
36- { yOut.clear (); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
36+ { yOut.clear (); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
3737 for (size_t j = 0 ; j < yIn.size (); ++j)
3838 { // 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);
4141 yOut.push_back ((yIn.at (j) - scaleMin.at (j))/(scaleMax.at (j)- scaleMin.at (j)));
42- LOG (debug)<<" Feature = " <<j<<" ----> input = " <<yIn.at (j)<<" scaled feature = " << yOut.at (j);
42+ LOG (debug)<<" Feature = " <<j<<" ----> input = " <<yIn.at (j)<<" scaled feature = " << yOut.at (j);
4343 }
4444 }
4545 // ---- External preprocessing scaling
4646 void setScaling (bool scaleFlag, int scaleType, /* input features of a candidate */ std::vector<float > yIn, std::vector<float > scaleMin, std::vector<float > scaleMax)
4747 { // it takes the bool flag and scaling parameters configurables in taskXic
4848 yScaled.clear ();
49- if ( scaleFlag == false ){
49+ if ( scaleFlag == false ) {
5050 LOG (debug)<<" No external preprocessing transformation will be applied" ;
5151 yScaled.assign (yIn.begin (), yIn.end ());
52- } else {
53- if (scaleType == 1 ){
52+ } else {
53+ if (scaleType == 1 ) {
5454 LOG (debug)<<" MinMax scaling will be applied" ;
5555 setMinMaxScaling (yScaled, yIn, scaleMin, scaleMax);
56- } // ... with scaleType > 1 we could add other preprocessing trasformations
57- }
56+ } // ... with scaleType > 1 we could add other preprocessing trasformations
57+ }
5858 }
5959 std::vector<float > getPreprocessedFeatures (){
6060 for (size_t j = 0 ; j < yScaled.size (); ++j) LOG (debug)<<" Global scaled feature = " << yScaled.at (j);
6161 return yScaled;
6262 }
6363 // Reverse preprocessing - output postprocessing
6464 void unsetMinMaxScaling (std::vector<float >& yOut, std::vector<float > yIn, std::vector<float > scaleMin, std::vector<float > scaleMax)
65- { yOut.clear (); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
65+ { yOut.clear (); // initial clear to avoid multiple filling if setMinMax o setScaling are called more than once
6666 for (size_t j = 0 ; j < yIn.size (); ++j)
6767 { // loop for over the features
6868 // MinMax scaling of the input features
6969 LOG (debug)<<" --------------> MinMax unscaling Debug \t " <<scaleMin.at (j)<<" \t " <<scaleMax.at (j);
7070 yOut.push_back (yIn.at (j)*(scaleMax.at (j)- scaleMin.at (j))+ scaleMin.at (j));
71- LOG (debug)<<" Unscaling output = " <<j<<" ----> input = " <<yIn.at (j)<<" rescaled output = " << yOut.at (j);
71+ LOG (debug)<<" Unscaling output = " <<j<<" ----> input = " <<yIn.at (j)<<" rescaled output = " << yOut.at (j);
7272 }
7373 }
7474
7575 void unsetScaling (bool scaleFlag, int scaleType, /* AE output*/ std::vector<float > yIn, std::vector<float > scaleMin, std::vector<float > scaleMax)
7676 { // it takes the bool flag and scaling parameters configurables in taskXic
7777 yOutRescaled.clear ();
78- if ( scaleFlag == false ){
78+ if ( scaleFlag == false ) {
7979 LOG (debug)<<" No external preprocessing transformation will be applied" ;
8080 yOutRescaled.assign (yIn.begin (), yIn.end ());
81- } else {
82- if (scaleType == 1 ){
81+ } else {
82+ if (scaleType == 1 ) {
8383 LOG (debug)<<" MinMax unscaling will be applied" ;
8484 unsetMinMaxScaling (yOutRescaled, yIn, scaleMin, scaleMax);
85- } // ... with scaleType > 1 we could add other preprocessing trasformations
86- }
85+ } // ... with scaleType > 1 we could add other preprocessing trasformations
86+ }
8787 }
8888
89- std::vector<float > getPostprocessedOutput (){
89+ std::vector<float > getPostprocessedOutput () {
9090 for (size_t j = 0 ; j < yOutRescaled.size (); ++j) LOG (debug)<<" Global rescaled AE output = " << yOutRescaled.at (j);
9191 return yOutRescaled;
9292 }
9393 // ---- MSE function
9494 float getMse (std::vector<float > yTrue, std::vector<float > yPred){
9595 LOG (debug)<<" Inside getMse sizes " <<yTrue.size ()<<" \t " <<yPred.size ();
9696 float mse= 0 .0f ;
97- float sum = 0 .0f ;
97+ float sum = 0 .0f ;
9898 for (size_t j = 0 ; j < yTrue.size (); ++j) LOG (debug)<<" Local Feature = " <<j<<" ----> input = " <<yTrue.at (j)<<" scaled feature = " << yPred.at (j);
9999 std::vector<float > yTrueScaled = getPreprocessedFeatures (); // to make the input features adimensional
100- if ( yTrue.size () != yPred.size ()){
100+ i f ( yTrue.size () != yPred.size ()){
101101 LOG (debug)<< " size of input vector =" <<yTrue.size ();
102102 LOG (debug)<< " size of AE output vector =" << yPred.size ();
103- LOG (fatal) << " vectors of input and predictions don't have the same size" ;
104- } else { // MSE
105- for (size_t j = 0 ; j < yPred.size (); ++j) {
106- sum += std::pow (((yTrueScaled).at (j) - (yPred).at (j)), 2 ); // AE model gives adimensional predictions by design choice
107- LOG (debug)<<" getMse Local feature = " <<j<<" ----> input = " <<yTrueScaled.at (j)<<" AE prediction = " << yPred.at (j);
108- }
103+ LOG (fatal) << " vectors of input and predictions don't have the same size" ;
104+ } else { // MSE
105+ for (size_t j = 0 ; j < yPred.size (); ++j) {
106+ sum += std::pow (((yTrueScaled).at (j) - (yPred).at (j)), 2 ); // AE model gives adimensional predictions by design choice
107+ LOG (debug)<<" getMse Local feature = " <<j<<" ----> input = " <<yTrueScaled.at (j)<<" AE prediction = " << yPred.at (j);
108+ }
109109 mse = sum/yPred.size (); // MSE of a candidate
110110 LOG (debug)<<" Local mse " <<mse;
111111 }
0 commit comments