I will continue the promised story about how the model can be applied in practice, at the same time I will try to expand on the topic of TMVA exclusivity in more detail.
Suppose you are working in a project that requires the maximum speed of the system (gamedev, map service or data from the collider), then it is obvious that your code is written in a language that is extremely close to hardware - C / C ++. And one day it becomes necessary to add some kind of mathematics to the service, depending on the needs of the project. Usually the eye falls on the snake language , which has many convenient mathematical libraries for prototyping ideas, but at the same time it is useless in working with a really large amount of data and eating like all the resources of a machine.
In this case, you will need to recruit people into the team who will draw on the knee code on python, because development on industrial PL usually takes a little more time (usually this way, but in practice I have met people who write good C ++ code during the average pythonist time).
CERN's ROOT library solves the problem of algorithm prototyping, speeding up the development process for lovers of pluses.
The ROOT provides a tool for the statistical analysis of the statistical analysis of the macros. an efficient way "
You can compile the code, you can just write macros, it’s important that the development speed increases, and for this you don’t have to spend time on the support of non-production tools.
Let's go back directly to the Reader in TMVA. As I have already said, it allows you to read the constructed model and apply it on data with a similar structure, you can unload information (id, phone number, email) with a certain cutpoint from the ball. Those. The model obtained in TMVA is portable ...
Reader sample:
{ cout <<" >>>> _____________________Reader application launched_________________________________________________________\n"; // TFile* realdata = new TFile("ForScoring.csv"); // root- TFile *target = new TFile("real_data-mva.root","RECREATE" ); // TMVA::Reader *reader = new TMVA::Reader( "V:Color:!Silent" ); // Float_t var[2]; reader->AddVariable ("Param0", &var[0]); reader->AddVariable ("Param1", &var[1]); reader->AddVariable ("Param2", &var[2]); //reader->AddSpectator("id", &var[3]); //if we need download it cout <<" >>>> All is good, next phase \n"; // xml , weights reader->BookMVA("SVM", "weights/TMVAClassification_SVM.weights.xml"); Float_t uservar[3]; //Long64_t id; realdataTree->SetBranchAddress("Param0",&uservar[0]); realdataTree->SetBranchAddress("Param1",&uservar[1]); realdataTree->SetBranchAddress("Param2",&Param2); // id' Float_t SVM_response; tree->Branch("SVM_response",&SVM_response); outputListFileName = "Output_mva.csv"; cout << "opening file "<<outputListFileName <<"\n"; ofstream* outCsv = new ofstream(outputListFileName.c_str()); for (Long64_t ievt=0; ievt<realdataTree->GetEntries();ievt++) { if (ievt%5000000 == 0) std::cout << "--- ... Processing event: " << ievt <<std::endl; realdataTree->GetEntry(ievt); // var[0]=Param0; var[1]=Param1; var[2]=Param2; // . 0.9 BDT_response=reader->EvaluateMVA("SVM"); if (SVM_response >= 0.9) *outCsv << id << ";" << SVM_response <<"\n"; tree->Fill(); } outCsv->close(); delete outCsv; delete reader; tree->Write(); target->Close(); }
Source: https://habr.com/ru/post/307154/
All Articles