--- myst: substitutions: macro: python: 1-5,15-21,24-36 cpp: 4-5,11-14,17-27 bloc1: python: 16-17 cpp: 4,11 bloc2: python: 30-31 cpp: 22-23 --- # Macro "**modelerFlowrateLinearRegression.{{extension}}**" ## Objective The objective of this macro is to build a linear regression between a predictor **rw** and a target variable **yhat** from the database contained in the ASCII file `flowrate_sampler_launcher_500.dat` defining values for the eight variables described in [](#launcher_introduction_simple_case_problem) on 500 patterns. ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateLinearRegression." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + macro[language] + "\n" + "```" }} The {{tds}} is loaded with the database contained in the file `flowrate_sampler_launcher_500.dat` with the `fileDataRead` method: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateLinearRegression." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} The linear regression is initialised and characteristic values are computed for **rw** with the `estimate` method: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateLinearRegression." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} ```{only} py The last argument is the option field, which in most cases is empty. Here it is filled with "DummyPython" which helps specify to python which constructor to choose. There are indeed several possible constructors these 5 five first arguments, but C++ can make the difference between them as the literal members are either `std::string`, `ROOT::TString`, `Char_t*` or even `Option_t*`. For python, these format are all `PyString`, so the sixth argument is compulsory to disentangle the possibilities. ``` ## Graph {{ "```{figure} " + parent_dir + "/roottest/build/uranie/doc/modeler/use_cases/" + language + "/linear_regression/modelerFlowrateLinearRegression.png\n" + ":align: center\n" + ":name: use_cases_modelerFlowrateLinearRegression\n" + figure_scale + "\n" + "\n" + "Graph of the macro **\"modelerFlowrateLinearRegression." + extension + "\"**" + "\n" + "```" }}