Changes between Version 7 and Version 8 of DatabaseBasedAnalysis/RandomForest


Ignore:
Timestamp:
08/15/18 18:32:27 (6 years ago)
Author:
tbretz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseBasedAnalysis/RandomForest

    v7 v8  
    1515}}}
    1616
     17Here is the full output (on an Ubuntu 18.04)
     18
     19{{{#!Spoiler
     20{{{
     21user@machine:~> git clone https://github.com/imbs-hl/ranger.git                                 
     22Cloning into 'ranger'...                                                                                   
     23remote: Counting objects: 8000, done.
     24remote: Compressing objects: 100% (32/32), done.
     25remote: Total 8000 (delta 6), reused 5 (delta 3), pack-reused 7965
     26Receiving objects: 100% (8000/8000), 19.88 MiB | 2.30 MiB/s, done.
     27Resolving deltas: 100% (6172/6172), done.
     28user@machine:~> cd ranger
     29user@machine:~/ranger> cd cpp_version/
     30user@machine:~/ranger/cpp_version> mkdir build
     31user@machine:~/ranger/cpp_version> cd build
     32user@machine:~/ranger/cpp_version/build> cmake ..
     33-- The C compiler identification is GNU 7.3.0
     34-- The CXX compiler identification is GNU 7.3.0
     35-- Check for working C compiler: /usr/bin/cc
     36-- Check for working C compiler: /usr/bin/cc -- works
     37-- Detecting C compiler ABI info
     38-- Detecting C compiler ABI info - done
     39-- Detecting C compile features
     40-- Detecting C compile features - done
     41-- Check for working CXX compiler: /usr/bin/c++
     42-- Check for working CXX compiler: /usr/bin/c++ -- works
     43-- Detecting CXX compiler ABI info
     44-- Detecting CXX compiler ABI info - done
     45-- Detecting CXX compile features
     46-- Detecting CXX compile features - done
     47CMake Warning (dev) at CMakeLists.txt:2 (cmake_minimum_required):
     48  Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.
     49This warning is for project developers.  Use -Wno-dev to suppress it.
     50
     51-- Performing Test COMPILER_SUPPORTS_CXX11
     52-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
     53Compiler with C++11 support found.
     54-- Configuring done
     55-- Generating done
     56-- Build files have been written to: /home/fact/ranger/cpp_version/build
     57user@machine:~/ranger/cpp_version/build> make -j8
     58Scanning dependencies of target ranger
     59[ 23%] Building CXX object CMakeFiles/ranger.dir/src/Forest/ForestProbability.o
     60[ 23%] Building CXX object CMakeFiles/ranger.dir/src/Forest/ForestClassification.o
     61[ 29%] Building CXX object CMakeFiles/ranger.dir/src/Forest/ForestSurvival.o
     62[ 23%] Building CXX object CMakeFiles/ranger.dir/src/Forest/Forest.o
     63[ 23%] Building CXX object CMakeFiles/ranger.dir/src/Forest/ForestRegression.o
     64[ 35%] Building CXX object CMakeFiles/ranger.dir/src/Tree/Tree.o
     65[ 41%] Building CXX object CMakeFiles/ranger.dir/src/Tree/TreeClassification.o
     66[ 47%] Building CXX object CMakeFiles/ranger.dir/src/Tree/TreeProbability.o
     67[ 52%] Building CXX object CMakeFiles/ranger.dir/src/Tree/TreeRegression.o
     68[ 58%] Building CXX object CMakeFiles/ranger.dir/src/Tree/TreeSurvival.o
     69[ 64%] Building CXX object CMakeFiles/ranger.dir/src/main.o
     70[ 70%] Building CXX object CMakeFiles/ranger.dir/src/utility/ArgumentHandler.o
     71[ 76%] Building CXX object CMakeFiles/ranger.dir/src/utility/Data.o
     72[ 82%] Building CXX object CMakeFiles/ranger.dir/src/utility/DataChar.o
     73[ 88%] Building CXX object CMakeFiles/ranger.dir/src/utility/DataFloat.o
     74[ 94%] Building CXX object CMakeFiles/ranger.dir/src/utility/utility.o
     75[100%] Linking CXX executable ranger
     76[100%] Built target ranger
     77user@machine:~/ranger/cpp_version/build>
     78}}}
     79
    1780== Writing Input Files ==
     81
     82Now we have the random forest, now we need the data. I assume that you have created a root-file with the simulation data you want to use already which is named '''simulation.root'''.
    1883
    1984{{{#!Spoiler
     
    44109
    45110    // Connect the variables to the cordesponding leaves
    46     //c.SetBranchAddress("FileId", &FileId);
    47     //c.SetBranchAddress("EvtNumber", &EvtNumber);
    48111    c.SetBranchAddress("X", &X);
    49112    c.SetBranchAddress("Y", &Y);
     
    66129    // in the future)
    67130    double mm2deg = +0.0117193246260285378;
    68     //double abberation = 1.02;
    69131
    70132    // -------------------- Source dependent parameter calculation -------------------
     
    87149        double area = TMath::Pi()*Width*Length;
    88150
    89         // The abberation correction does increase also Width and Length by 1.02
    90 
    91151        int angle = 0;
    92152
     
    99159        double py = cr*Y+sr*X;
    100160
    101         double dx = MeanX - px*1.022;
    102         double dy = MeanY - py*1.022;
     161        double dx = MeanX - px*1.02;
     162        double dy = MeanY - py*1.02;
    103163
    104164        double norm = sqrt(dx*dx + dy*dy);
     
    118178        // --------------------------------- Analysis -----------------------------------
    119179
    120         //double xi = 1.34723 + 0.15214 *slope + 0.970704*(1-1/(1+8.89826*Leakage1));
    121180        double xi = 1.340 + 0.0755*slope + 1.67972*(1-1/(1+4.86232*Leakage1));
    122181
     
    183242== Training ==
    184243
     244Now we train the random forest with the train data using ranger:
     245
    185246{{{
    186247fact@ihp-pc45:~/Analysis> nice -n 10 ~/ranger-master/cpp_version/build/ranger --file sim-train.csv --depvarname Energy --memmode 1 --treetype 3 --verbose --impmeasure 1 --outprefix sim-train
     
    210271}}}
    211272
    212 It will write a file called '''sim-train.forest''' and
     273It will write a file called '''sim-train.forest''' with the forest and give you a list of the importance of the parameters
     274
    213275{{{
    214276user@machine> cat ranger_out.importance
     
    226288== Testing ==
    227289
     290Now we can apply the forest to out test data. Once to all data and once to the data after background suppression:
     291
    228292{{{
    229293nice -n 10 ~/ranger-master/cpp_version/build/ranger --file sim-test.csv      --depvarname Energy --memmode 1 --treetype 3 --verbose --impmeasure 1 --predict sim-train.forest
     
    232296
    233297Here is an example output
     298
    234299{{{
    235300Starting Ranger.
     
    257322== Plotting Result ==
    258323
     324The predicted values have been written to '''ranger_out.prediction'''. We can read them now together with the test-data and do some control plots. Here is an example ROOT macro which plots the result for the test-data after background suppresion cuts.
     325
    259326{{{#!Spoiler
    260327{{{#!cpp
     
    278345
    279346    ifstream fin0("sim-test-cuts.csv");
    280     ifstream fin1("sim-test-results-cuts.csv");
     347    ifstream fin1("ranger_out.prediction");
    281348
    282349    TString str;
     
    408475== Result ==
    409476
    410 I trained without any cuts applied. This is how the result looks like if the random forest prediction is applied to the test sample with cuts applied.
     477And here are the plots which were produced:
    411478
    412479[[Image(Result.png)]]