Skip to content

Commit

Permalink
kd-tree var scaling for err calc
Browse files Browse the repository at this point in the history
  • Loading branch information
IftachSadeh committed Aug 3, 2015
1 parent b1fb110 commit c933c10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/ANNZ_err.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ void ANNZ::setupKdTreeKNN(TChain * aChainKnn, TFile *& knnErrOutFile, TMVA::Fact
// transform the input variable
// -----------------------------------------------------------------------------------------------------------
if(quantV[0] < quantV[1]) {
varScaled = (TString)"(("+inNamesVar[nMLMnow][nVarNow]+") - "+utils->floatToStr(quantV[0])
+") * "+utils->floatToStr( 2/(quantV[1] - quantV[0]) )+" - 1";
TString shiftStr = (TString)((quantV[0] > 0) ? " - " : " + ") + utils->floatToStr(fabs(quantV[0]));

TString varScaledFunc = varScaled; varScaledFunc.ReplaceAll(inNamesVar[nMLMnow][nVarNow],"x");
varScaled = (TString)"(("+inNamesVar[nMLMnow][nVarNow]+")"+shiftStr+") * "+utils->floatToStr( 2/(quantV[1] - quantV[0]) )+" - 1";

TString varScaledFunc(varScaled); varScaledFunc.ReplaceAll(inNamesVar[nMLMnow][nVarNow],"x");

inVarsScaleFunc[nMLMnow][nVarNow] = new TF1(varScaledFunc,varScaledFunc); //cout<<" ---> "<<varScaledFunc<<endl;

aLOG(Log::DEBUG_1)<<coutYellow<<" --> Transformation to range [-1,1] from "<<coutGreen<<inNamesVar[nMLMnow][nVarNow]
Expand Down
4 changes: 3 additions & 1 deletion src/CatFormat_wgtKNN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ void CatFormat::addWgtKNNtoTree(TChain * aChainInp, TChain * aChainRef, TString
}

if(valMin < valMax) {
varNamesScaled[nVarNow] = (TString)"(("+varNames[nVarNow]+") - "+utils->floatToStr(valMin)+") * "+utils->floatToStr( 2/(valMax - valMin) )+" - 1";
TString shiftStr = (TString)((valMin > 0) ? " - " : " + ") + utils->floatToStr(fabs(valMin));

varNamesScaled[nVarNow] = (TString)"(("+varNames[nVarNow]+") "+shiftStr+") * "+utils->floatToStr( 2/(valMax - valMin) )+" - 1";

aLOG(Log::INFO)<<coutYellow<<" - Transformation to range [-1,1] from "<<coutGreen<<varNames[nVarNow]
<<coutYellow<<" to: "<<coutBlue<<varNamesScaled[nVarNow]<<coutDef<<endl;
Expand Down

0 comments on commit c933c10

Please sign in to comment.