Changes between Version 7 and Version 8 of DatabaseBasedAnalysis/RandomForest
- Timestamp:
- 08/15/18 18:32:27 (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DatabaseBasedAnalysis/RandomForest
v7 v8 15 15 }}} 16 16 17 Here is the full output (on an Ubuntu 18.04) 18 19 {{{#!Spoiler 20 {{{ 21 user@machine:~> git clone https://github.com/imbs-hl/ranger.git 22 Cloning into 'ranger'... 23 remote: Counting objects: 8000, done. 24 remote: Compressing objects: 100% (32/32), done. 25 remote: Total 8000 (delta 6), reused 5 (delta 3), pack-reused 7965 26 Receiving objects: 100% (8000/8000), 19.88 MiB | 2.30 MiB/s, done. 27 Resolving deltas: 100% (6172/6172), done. 28 user@machine:~> cd ranger 29 user@machine:~/ranger> cd cpp_version/ 30 user@machine:~/ranger/cpp_version> mkdir build 31 user@machine:~/ranger/cpp_version> cd build 32 user@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 47 CMake Warning (dev) at CMakeLists.txt:2 (cmake_minimum_required): 48 Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. 49 This 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 53 Compiler with C++11 support found. 54 -- Configuring done 55 -- Generating done 56 -- Build files have been written to: /home/fact/ranger/cpp_version/build 57 user@machine:~/ranger/cpp_version/build> make -j8 58 Scanning 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 77 user@machine:~/ranger/cpp_version/build> 78 }}} 79 17 80 == Writing Input Files == 81 82 Now 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'''. 18 83 19 84 {{{#!Spoiler … … 44 109 45 110 // Connect the variables to the cordesponding leaves 46 //c.SetBranchAddress("FileId", &FileId);47 //c.SetBranchAddress("EvtNumber", &EvtNumber);48 111 c.SetBranchAddress("X", &X); 49 112 c.SetBranchAddress("Y", &Y); … … 66 129 // in the future) 67 130 double mm2deg = +0.0117193246260285378; 68 //double abberation = 1.02;69 131 70 132 // -------------------- Source dependent parameter calculation ------------------- … … 87 149 double area = TMath::Pi()*Width*Length; 88 150 89 // The abberation correction does increase also Width and Length by 1.0290 91 151 int angle = 0; 92 152 … … 99 159 double py = cr*Y+sr*X; 100 160 101 double dx = MeanX - px*1.02 2;102 double dy = MeanY - py*1.02 2;161 double dx = MeanX - px*1.02; 162 double dy = MeanY - py*1.02; 103 163 104 164 double norm = sqrt(dx*dx + dy*dy); … … 118 178 // --------------------------------- Analysis ----------------------------------- 119 179 120 //double xi = 1.34723 + 0.15214 *slope + 0.970704*(1-1/(1+8.89826*Leakage1));121 180 double xi = 1.340 + 0.0755*slope + 1.67972*(1-1/(1+4.86232*Leakage1)); 122 181 … … 183 242 == Training == 184 243 244 Now we train the random forest with the train data using ranger: 245 185 246 {{{ 186 247 fact@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 … … 210 271 }}} 211 272 212 It will write a file called '''sim-train.forest''' and 273 It will write a file called '''sim-train.forest''' with the forest and give you a list of the importance of the parameters 274 213 275 {{{ 214 276 user@machine> cat ranger_out.importance … … 226 288 == Testing == 227 289 290 Now we can apply the forest to out test data. Once to all data and once to the data after background suppression: 291 228 292 {{{ 229 293 nice -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 … … 232 296 233 297 Here is an example output 298 234 299 {{{ 235 300 Starting Ranger. … … 257 322 == Plotting Result == 258 323 324 The 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 259 326 {{{#!Spoiler 260 327 {{{#!cpp … … 278 345 279 346 ifstream fin0("sim-test-cuts.csv"); 280 ifstream fin1(" sim-test-results-cuts.csv");347 ifstream fin1("ranger_out.prediction"); 281 348 282 349 TString str; … … 408 475 == Result == 409 476 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. 477 And here are the plots which were produced: 411 478 412 479 [[Image(Result.png)]]