{ "cells": [ { "cell_type": "markdown", "id": "5ca5797d", "metadata": {}, "source": [ "# TMVACrossValidationRegression\n", "This macro provides an example of how to use TMVA for k-folds cross\n", "evaluation.\n", "\n", "As input data is used a toy-MC sample consisting of two gaussian\n", "distributions.\n", "\n", "The output file \"TMVARegCv.root\" can be analysed with the use of dedicated\n", "macros (simply say: root -l ), which can be conveniently\n", "invoked through a GUI that will appear at the end of the run of this macro.\n", "You can also launch the GUI in another ROOT session via the command:\n", "\n", "```\n", "root -l -e 'TMVA::TMVAGui(\"TMVARegCv.root\")'\n", "```\n", "\n", "## Cross Evaluation\n", "Cross evaluation is a special case of k-folds cross validation where the\n", "splitting into k folds is computed deterministically. This ensures that the\n", "a given event will always end up in the same fold.\n", "\n", "In addition all resulting classifiers are saved and can be applied to new\n", "data using `MethodCrossValidation`. One requirement for this to work is a\n", "splitting function that is evaluated for each event to determine into what\n", "fold it goes (for training/evaluation) or to what classifier (for\n", "application).\n", "\n", "## Split Expression\n", "Cross evaluation uses a deterministic split to partition the data into\n", "folds called the split expression. The expression can be any valid\n", "`TFormula` as long as all parts used are defined.\n", "\n", "For each event the split expression is evaluated to a number and the event\n", "is put in the fold corresponding to that number.\n", "\n", "It is recommended to always use `%int([NumFolds])` at the end of the\n", "expression.\n", "\n", "The split expression has access to all spectators and variables defined in\n", "the dataloader. Additionally, the number of folds in the split can be\n", "accessed with `NumFolds` (or `numFolds`).\n", "\n", "### Example\n", " ```\n", " \"int(fabs([eventID]))%int([NumFolds])\"\n", " ```\n", "\n", "- Project : TMVA - a ROOT-integrated toolkit for multivariate data analysis\n", "- Package : TMVA\n", "- Root Macro: TMVACrossValidationRegression\n", "\n", "\n", "\n", "**Author:** Kim Albertsson (adapted from code originally by Andreas Hoecker) \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:24 PM." ] }, { "cell_type": "markdown", "id": "6b126746", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 1, "id": "4a36aa8f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:09.994704Z", "iopub.status.busy": "2026-05-19T20:24:09.994571Z", "iopub.status.idle": "2026-05-19T20:24:10.004779Z", "shell.execute_reply": "2026-05-19T20:24:10.004308Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "\n", "#include \n", "#include \n", "#include \n", "#include \n", "\n", "#include \"TChain.h\"\n", "#include \"TFile.h\"\n", "#include \"TTree.h\"\n", "#include \"TString.h\"\n", "#include \"TObjString.h\"\n", "#include \"TSystem.h\"\n", "#include \"TROOT.h\"\n", "\n", "#include \"TMVA/Factory.h\"\n", "#include \"TMVA/DataLoader.h\"\n", "#include \"TMVA/Tools.h\"\n", "#include \"TMVA/TMVAGui.h\"\n", "#include \"TMVA/CrossValidation.h\"\n", "\n", "TFile * getDataFile(TString fname) {\n", " TFile *input(nullptr);\n", "\n", " if (!gSystem->AccessPathName(fname)) {\n", " input = TFile::Open(fname); // check if file in local directory exists\n", " }\n", "\n", " if (!input) {\n", " std::cout << \"ERROR: could not open data file \" << fname << std::endl;\n", " exit(1);\n", " }\n", "\n", " return input;\n", "}" ] }, { "cell_type": "markdown", "id": "006611e2", "metadata": {}, "source": [ "This loads the library" ] }, { "cell_type": "code", "execution_count": 2, "id": "d5d665e4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:10.006165Z", "iopub.status.busy": "2026-05-19T20:24:10.006049Z", "iopub.status.idle": "2026-05-19T20:24:10.346392Z", "shell.execute_reply": "2026-05-19T20:24:10.345774Z" } }, "outputs": [], "source": [ "TMVA::Tools::Instance();" ] }, { "cell_type": "markdown", "id": "c3770171", "metadata": {}, "source": [ "--------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "e221a890", "metadata": {}, "source": [ "Create a ROOT output file where TMVA will store ntuples, histograms, etc." ] }, { "cell_type": "code", "execution_count": 3, "id": "79ae6e9a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:10.356219Z", "iopub.status.busy": "2026-05-19T20:24:10.356087Z", "iopub.status.idle": "2026-05-19T20:24:10.560522Z", "shell.execute_reply": "2026-05-19T20:24:10.559939Z" } }, "outputs": [], "source": [ "TString outfileName(\"TMVARegCv.root\");\n", "TFile * outputFile = TFile::Open(outfileName, \"RECREATE\");\n", "\n", "TString infileName = gROOT->GetTutorialDir() + \"/machine_learning/data/tmva_reg_example.root\";\n", "TFile * inputFile = getDataFile(infileName);\n", "\n", "TMVA::DataLoader *dataloader=new TMVA::DataLoader(\"datasetcvreg\");\n", "\n", "dataloader->AddVariable(\"var1\", \"Variable 1\", \"units\", 'F');\n", "dataloader->AddVariable(\"var2\", \"Variable 2\", \"units\", 'F');" ] }, { "cell_type": "markdown", "id": "28b3307a", "metadata": {}, "source": [ "Add the variable carrying the regression target" ] }, { "cell_type": "code", "execution_count": 4, "id": "894e9dca", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:10.566504Z", "iopub.status.busy": "2026-05-19T20:24:10.566330Z", "iopub.status.idle": "2026-05-19T20:24:10.774102Z", "shell.execute_reply": "2026-05-19T20:24:10.773253Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "DataSetInfo : [datasetcvreg] : Added class \"Regression\"\n", " : Add Tree TreeR of type Regression with 10000 events\n" ] } ], "source": [ "dataloader->AddTarget(\"fvalue\");\n", "\n", "TTree * regTree = (TTree*)inputFile->Get(\"TreeR\");\n", "dataloader->AddRegressionTree(regTree, 1.0);" ] }, { "cell_type": "markdown", "id": "b74e5a32", "metadata": {}, "source": [ "Individual events can be weighted\n", "dataloader->SetWeightExpression(\"weight\", \"Regression\");" ] }, { "cell_type": "code", "execution_count": 5, "id": "377d2d1c", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:10.775874Z", "iopub.status.busy": "2026-05-19T20:24:10.775720Z", "iopub.status.idle": "2026-05-19T20:24:10.983004Z", "shell.execute_reply": "2026-05-19T20:24:10.982499Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- TMVACrossValidationRegression: Using input file: /github/home/ROOT-CI/build/tutorials/machine_learning/data/tmva_reg_example.root\n" ] } ], "source": [ "std::cout << \"--- TMVACrossValidationRegression: Using input file: \" << inputFile->GetName() << std::endl;" ] }, { "cell_type": "markdown", "id": "bffeed7a", "metadata": {}, "source": [ "Bypasses the normal splitting mechanism, CV uses a new system for this.\n", "Unfortunately the old system is unhappy if we leave the test set empty so\n", "we ensure that there is at least one event by placing the first event in\n", "it.\n", "You can with the selection cut place a global cut on the defined\n", "variables. Only events passing the cut will be using in training/testing.\n", "Example: `TCut selectionCut = \"var1 < 1\";`" ] }, { "cell_type": "code", "execution_count": 6, "id": "20f6e349", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:10.984950Z", "iopub.status.busy": "2026-05-19T20:24:10.984816Z", "iopub.status.idle": "2026-05-19T20:24:11.190430Z", "shell.execute_reply": "2026-05-19T20:24:11.189720Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " : Dataset[datasetcvreg] : Class index : 0 name : Regression\n" ] } ], "source": [ "TCut selectionCut = \"\";\n", "dataloader->PrepareTrainingAndTestTree(selectionCut, \"nTest_Regression=1\"\n", " \":SplitMode=Block\"\n", " \":NormMode=NumEvents\"\n", " \":!V\");" ] }, { "cell_type": "markdown", "id": "6e56d097", "metadata": {}, "source": [ "--------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "0899fcc3", "metadata": {}, "source": [ "This sets up a CrossValidation class (which wraps a TMVA::Factory\n", "internally) for 2-fold cross validation. The data will be split into the\n", "two folds randomly if `splitExpr` is `\"\"`.\n", "\n", "One can also give a deterministic split using spectator variables. An\n", "example would be e.g. `\"int(fabs([spec1]))%int([NumFolds])\"`." ] }, { "cell_type": "code", "execution_count": 7, "id": "1c682679", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:11.192034Z", "iopub.status.busy": "2026-05-19T20:24:11.191903Z", "iopub.status.idle": "2026-05-19T20:24:11.399759Z", "shell.execute_reply": "2026-05-19T20:24:11.398931Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "
Factory : You are running ROOT Version: 6.41.01, Apr 23, 2026\n", " : \n", " : _/_/_/_/_/ _| _| _| _| _|_| \n", " : _/ _|_| _|_| _| _| _| _| \n", " : _/ _| _| _| _| _| _|_|_|_| \n", " : _/ _| _| _| _| _| _| \n", " : _/ _| _| _| _| _| \n", " : \n", " : ___________TMVA Version 4.2.1, Feb 5, 2015\n", " : \n" ] } ], "source": [ "UInt_t numFolds = 2;\n", "TString analysisType = \"Regression\";\n", "TString splitExpr = \"\";\n", "\n", "TString cvOptions = Form(\"!V\"\n", " \":!Silent\"\n", " \":ModelPersistence\"\n", " \":!FoldFileOutput\"\n", " \":AnalysisType=%s\"\n", " \":NumFolds=%i\"\n", " \":SplitExpr=%s\",\n", " analysisType.Data(), numFolds, splitExpr.Data());\n", "\n", "TMVA::CrossValidation cv{\"TMVACrossValidationRegression\", dataloader, outputFile, cvOptions};" ] }, { "cell_type": "markdown", "id": "cc9a72cd", "metadata": {}, "source": [ "--------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "0b3b436c", "metadata": {}, "source": [ "Books a method to use for evaluation" ] }, { "cell_type": "code", "execution_count": 8, "id": "9f0951a6", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:11.401425Z", "iopub.status.busy": "2026-05-19T20:24:11.401274Z", "iopub.status.idle": "2026-05-19T20:24:11.612912Z", "shell.execute_reply": "2026-05-19T20:24:11.612262Z" } }, "outputs": [], "source": [ "cv.BookMethod(TMVA::Types::kBDT, \"BDTG\",\n", " \"!H:!V:NTrees=500:BoostType=Grad:Shrinkage=0.1:\"\n", " \"UseBaggedBoost:BaggedSampleFraction=0.5:nCuts=20:MaxDepth=3\");" ] }, { "cell_type": "markdown", "id": "8a050279", "metadata": {}, "source": [ "--------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "7594c3cf", "metadata": {}, "source": [ "Train, test and evaluate the booked methods.\n", "Evaluates the booked methods once for each fold and aggregates the result\n", "in the specified output file." ] }, { "cell_type": "code", "execution_count": 9, "id": "9799a0e9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:11.618423Z", "iopub.status.busy": "2026-05-19T20:24:11.618284Z", "iopub.status.idle": "2026-05-19T20:24:14.687423Z", "shell.execute_reply": "2026-05-19T20:24:14.686894Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " : Rebuilding Dataset datasetcvreg\n", " : Building event vectors for type 2 Regression\n", " : Dataset[datasetcvreg] : create input formulas for tree TreeR\n", "
DataSetFactory : [datasetcvreg] : Number of events in input trees\n", " : \n", " : Number of training and testing events\n", " : ---------------------------------------------------------------------------\n", " : Regression -- training events : 9999\n", " : Regression -- testing events : 1\n", " : Regression -- training and testing events: 10000\n", " : \n", "
DataSetInfo : Correlation matrix (Regression):\n", " : ------------------------\n", " : var1 var2\n", " : var1: +1.000 +0.002\n", " : var2: +0.002 +1.000\n", " : ------------------------\n", "
DataSetFactory : [datasetcvreg] : \n", " : \n", " : \n", " : \n", " : ========================================\n", " : Processing folds for method BDTG\n", " : ========================================\n", " : \n", "
Factory : Booking method: BDTG_fold1\n", " : \n", " : the option NegWeightTreatment=InverseBoostNegWeights does not exist for BoostType=Grad\n", " : --> change to new default NegWeightTreatment=Pray\n", " : Regression Loss Function: Huber\n", " : Training 500 Decision Trees ... patience please\n", " : Elapsed time for training with 4999 events: 0.748 sec \n", " : Dataset[datasetcvreg] : Create results for training\n", " : Dataset[datasetcvreg] : Evaluation of BDTG_fold1 on training sample\n", " : Dataset[datasetcvreg] : Elapsed time for evaluation of 4999 events: 0.071 sec \n", " : Create variable histograms\n", " : Create regression target histograms\n", " : Create regression average deviation\n", " : Results created\n", " : Creating xml weight file: datasetcvreg/weights/TMVACrossValidationRegression_BDTG_fold1.weights.xml\n", "
Factory : Test all methods\n", "
Factory : Test method: BDTG_fold1 for Regression performance\n", " : \n", " : Dataset[datasetcvreg] : Create results for testing\n", " : Dataset[datasetcvreg] : Evaluation of BDTG_fold1 on testing sample\n", " : Dataset[datasetcvreg] : Elapsed time for evaluation of 5000 events: 0.0719 sec \n", " : Create variable histograms\n", " : Create regression target histograms\n", " : Create regression average deviation\n", " : Results created\n", "
Factory : Evaluate all methods\n", " : Evaluate regression method: BDTG_fold1\n", " : TestRegression (testing)\n", " : Calculate regression for all events\n", " : Elapsed time for evaluation of 5000 events: 0.0714 sec \n", " : TestRegression (training)\n", " : Calculate regression for all events\n", " : Elapsed time for evaluation of 4999 events: 0.0708 sec \n", " : \n", " : Evaluation results ranked by smallest RMS on test sample:\n", " : (\"Bias\" quotes the mean deviation of the regression from true target.\n", " : \"MutInf\" is the \"Mutual Information\" between regression and target.\n", " : Indicated by \"_T\" are the corresponding \"truncated\" quantities ob-\n", " : tained when removing events deviating more than 2sigma from average.)\n", " : --------------------------------------------------------------------------------------------------\n", " : --------------------------------------------------------------------------------------------------\n", " : datasetcvreg BDTG_fold1 : 0.0268 0.0575 2.23 1.74 | 3.112 3.181\n", " : --------------------------------------------------------------------------------------------------\n", " : \n", " : Evaluation results ranked by smallest RMS on training sample:\n", " : (overtraining check)\n", " : --------------------------------------------------------------------------------------------------\n", " : DataSet Name: MVA Method: RMS RMS_T | MutInf MutInf_T\n", " : --------------------------------------------------------------------------------------------------\n", " : datasetcvreg BDTG_fold1 : 0.0139 -0.00318 2.04 1.55 | 3.125 3.185\n", " : --------------------------------------------------------------------------------------------------\n", " : \n", "
Factory : Thank you for using TMVA!\n", " : For citation information, please visit: http://tmva.sf.net/citeTMVA.html\n", "
Factory : Booking method: BDTG_fold2\n", " : \n", " : the option NegWeightTreatment=InverseBoostNegWeights does not exist for BoostType=Grad\n", " : --> change to new default NegWeightTreatment=Pray\n", " : Regression Loss Function: Huber\n", " : Training 500 Decision Trees ... patience please\n", " : Elapsed time for training with 5000 events: 0.749 sec \n", " : Dataset[datasetcvreg] : Create results for training\n", " : Dataset[datasetcvreg] : Evaluation of BDTG_fold2 on training sample\n", " : Dataset[datasetcvreg] : Elapsed time for evaluation of 5000 events: 0.0699 sec \n", " : Create variable histograms\n", " : Create regression target histograms\n", " : Create regression average deviation\n", " : Results created\n", " : Creating xml weight file: datasetcvreg/weights/TMVACrossValidationRegression_BDTG_fold2.weights.xml\n", "
Factory : Test all methods\n", "
Factory : Test method: BDTG_fold2 for Regression performance\n", " : \n", " : Dataset[datasetcvreg] : Create results for testing\n", " : Dataset[datasetcvreg] : Evaluation of BDTG_fold2 on testing sample\n", " : Dataset[datasetcvreg] : Elapsed time for evaluation of 4999 events: 0.0698 sec \n", " : Create variable histograms\n", " : Create regression target histograms\n", " : Create regression average deviation\n", " : Results created\n", "
Factory : Evaluate all methods\n", " : Evaluate regression method: BDTG_fold2\n", " : TestRegression (testing)\n", " : Calculate regression for all events\n", " : Elapsed time for evaluation of 4999 events: 0.0687 sec \n", " : TestRegression (training)\n", " : Calculate regression for all events\n", " : Elapsed time for evaluation of 5000 events: 0.0683 sec \n", " : \n", " : Evaluation results ranked by smallest RMS on test sample:\n", " : (\"Bias\" quotes the mean deviation of the regression from true target.\n", " : \"MutInf\" is the \"Mutual Information\" between regression and target.\n", " : Indicated by \"_T\" are the corresponding \"truncated\" quantities ob-\n", " : tained when removing events deviating more than 2sigma from average.)\n", " : --------------------------------------------------------------------------------------------------\n", " : --------------------------------------------------------------------------------------------------\n", " : datasetcvreg BDTG_fold2 : 0.0542 0.0840 2.29 1.74 | 3.111 3.182\n", " : --------------------------------------------------------------------------------------------------\n", " : \n", " : Evaluation results ranked by smallest RMS on training sample:\n", " : (overtraining check)\n", " : --------------------------------------------------------------------------------------------------\n", " : DataSet Name: MVA Method: RMS RMS_T | MutInf MutInf_T\n", " : --------------------------------------------------------------------------------------------------\n", " : datasetcvreg BDTG_fold2 : 0.00602 0.0199 2.13 1.55 | 3.131 3.207\n", " : --------------------------------------------------------------------------------------------------\n", " : \n", "
Factory : Thank you for using TMVA!\n", " : For citation information, please visit: http://tmva.sf.net/citeTMVA.html\n", "
Factory : Booking method: BDTG\n", " : \n", " : Reading weightfile: datasetcvreg/weights/TMVACrossValidationRegression_BDTG_fold1.weights.xml\n", " : Reading weight file: datasetcvreg/weights/TMVACrossValidationRegression_BDTG_fold1.weights.xml\n", " : Reading weightfile: datasetcvreg/weights/TMVACrossValidationRegression_BDTG_fold2.weights.xml\n", " : Reading weight file: datasetcvreg/weights/TMVACrossValidationRegression_BDTG_fold2.weights.xml\n", " : \n", " : \n", " : ========================================\n", " : Folds processed for all methods, evaluating.\n", " : ========================================\n", " : \n", "
Factory : [datasetcvreg] : Create Transformation \"I\" with events from all classes.\n", " : \n", "
: Transformation, Variable selection : \n", " : Input : variable 'var1' <---> Output : variable 'var1'\n", " : Input : variable 'var2' <---> Output : variable 'var2'\n", "
TFHandler_Factory : Variable Mean RMS [ Min Max ]\n", " : -----------------------------------------------------------\n", " : var1: 2.4948 1.4515 [ 0.00020069 5.0000 ]\n", " : var2: 2.4837 1.4409 [ 0.00071490 5.0000 ]\n", " : fvalue: 134.53 84.778 [ 1.6186 394.84 ]\n", " : -----------------------------------------------------------\n", " : Ranking input variables (method unspecific)...\n", "
IdTransformation : Ranking result (top variable is best ranked)\n", " : --------------------------------------------\n", " : Rank : Variable : |Correlation with target|\n", " : --------------------------------------------\n", " : 1 : var2 : 7.607e-01\n", " : 2 : var1 : 5.995e-01\n", " : --------------------------------------------\n", "
IdTransformation : Ranking result (top variable is best ranked)\n", " : -------------------------------------\n", " : Rank : Variable : Mutual information\n", " : -------------------------------------\n", " : 1 : var1 : 2.253e+00\n", " : 2 : var2 : 2.100e+00\n", " : -------------------------------------\n", "
IdTransformation : Ranking result (top variable is best ranked)\n", " : ------------------------------------\n", " : Rank : Variable : Correlation Ratio\n", " : ------------------------------------\n", " : 1 : var2 : 2.458e+00\n", " : 2 : var1 : 2.336e+00\n", " : ------------------------------------\n", "
IdTransformation : Ranking result (top variable is best ranked)\n", " : ----------------------------------------\n", " : Rank : Variable : Correlation Ratio (T)\n", " : ----------------------------------------\n", " : 1 : var1 : 5.362e-01\n", " : 2 : var2 : 5.109e-01\n", " : ----------------------------------------\n", " : Elapsed time for training with 9999 events: 4.05e-06 sec \n", " : Dataset[datasetcvreg] : Create results for training\n", " : Dataset[datasetcvreg] : Evaluation of BDTG on training sample\n", " : Dataset[datasetcvreg] : Elapsed time for evaluation of 9999 events: 0.126 sec \n", " : Create variable histograms\n", " : Create regression target histograms\n", " : Create regression average deviation\n", " : Results created\n", " : Creating xml weight file: datasetcvreg/weights/TMVACrossValidationRegression_BDTG.weights.xml\n", "
Factory : Test all methods\n", "
Factory : Test method: BDTG for Regression performance\n", " : \n", " : Dataset[datasetcvreg] : Create results for testing\n", " : Dataset[datasetcvreg] : Evaluation of BDTG on testing sample\n", " : Dataset[datasetcvreg] : Elapsed time for evaluation of 9999 events: 0.126 sec \n", " : Create variable histograms\n", " : Create regression target histograms\n", " : Create regression average deviation\n", " : Results created\n", "
Factory : Evaluate all methods\n", " : Evaluate regression method: BDTG\n", " : TestRegression (testing)\n", " : Calculate regression for all events\n", " : Elapsed time for evaluation of 9999 events: 0.123 sec \n", " : TestRegression (training)\n", " : Calculate regression for all events\n", " : Elapsed time for evaluation of 9999 events: 0.124 sec \n", "
TFHandler_BDTG : Variable Mean RMS [ Min Max ]\n", " : -----------------------------------------------------------\n", " : var1: 2.4948 1.4515 [ 0.00020069 5.0000 ]\n", " : var2: 2.4837 1.4409 [ 0.00071490 5.0000 ]\n", " : fvalue: 134.53 84.778 [ 1.6186 394.84 ]\n", " : -----------------------------------------------------------\n", " : \n", " : Evaluation results ranked by smallest RMS on test sample:\n", " : (\"Bias\" quotes the mean deviation of the regression from true target.\n", " : \"MutInf\" is the \"Mutual Information\" between regression and target.\n", " : Indicated by \"_T\" are the corresponding \"truncated\" quantities ob-\n", " : tained when removing events deviating more than 2sigma from average.)\n", " : --------------------------------------------------------------------------------------------------\n", " : --------------------------------------------------------------------------------------------------\n", " : datasetcvreg BDTG : 0.0405 0.0697 2.26 1.74 | 3.099 3.173\n", " : --------------------------------------------------------------------------------------------------\n", " : \n", " : Evaluation results ranked by smallest RMS on training sample:\n", " : (overtraining check)\n", " : --------------------------------------------------------------------------------------------------\n", " : DataSet Name: MVA Method: RMS RMS_T | MutInf MutInf_T\n", " : --------------------------------------------------------------------------------------------------\n", " : datasetcvreg BDTG : 0.0405 0.0697 2.26 1.74 | 3.099 3.173\n", " : --------------------------------------------------------------------------------------------------\n", " : \n", "
Dataset:datasetcvreg : Created tree 'TestTree' with 9999 events\n", " : \n", "
Dataset:datasetcvreg : Created tree 'TrainTree' with 9999 events\n", " : \n", "
Factory : Thank you for using TMVA!\n", " : For citation information, please visit: http://tmva.sf.net/citeTMVA.html\n", " : Evaluation done.\n" ] } ], "source": [ "cv.Evaluate();" ] }, { "cell_type": "markdown", "id": "2405897e", "metadata": {}, "source": [ "--------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "aa0bcc6b", "metadata": {}, "source": [ "Save the output" ] }, { "cell_type": "code", "execution_count": 10, "id": "b13d47d7", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:14.695164Z", "iopub.status.busy": "2026-05-19T20:24:14.695039Z", "iopub.status.idle": "2026-05-19T20:24:14.902296Z", "shell.execute_reply": "2026-05-19T20:24:14.901720Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "==> Wrote root file: TMVARegCv.root\n", "==> TMVACrossValidationRegression is done!\n" ] } ], "source": [ "outputFile->Close();\n", "\n", "std::cout << \"==> Wrote root file: \" << outputFile->GetName() << std::endl;\n", "std::cout << \"==> TMVACrossValidationRegression is done!\" << std::endl;" ] }, { "cell_type": "markdown", "id": "420512b8", "metadata": {}, "source": [ "--------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "4b88e462", "metadata": {}, "source": [ "Launch the GUI for the root macros" ] }, { "cell_type": "code", "execution_count": 11, "id": "f25a2ad4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:14.903872Z", "iopub.status.busy": "2026-05-19T20:24:14.903755Z", "iopub.status.idle": "2026-05-19T20:24:15.124384Z", "shell.execute_reply": "2026-05-19T20:24:15.111959Z" } }, "outputs": [], "source": [ "if (!gROOT->IsBatch()) {\n", " TMVA::TMVAGui(outfileName);\n", "}\n", "\n", "return 0;" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }