13.6.2. Macro “modelerFlowrateLinearRegression.C

13.6.2.1. 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 Presentation of the problem on 500 patterns.

13.6.2.2. Macro Uranie

    TDataServer * tds = new TDataServer();

    tds->fileDataRead("flowrate_sampler_launcher_500.dat");

    TCanvas *c = new TCanvas("c1", "Graph for the Macro modeler",5,64,1270,667);
    TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
    pad->Divide(2);
    pad->cd(1); tds->draw("yhat:rw");

    //   tds->getAttribute("yhat")->setOutput();

    TLinearRegression *tlin = new TLinearRegression(tds, "rw","yhat");
    tlin->estimate();

    pad->cd(2); tds->draw("yhathat:yhat");
 
    tds->startViewer();

The TDataServer is loaded with the database contained in the file flowrate_sampler_launcher_500.dat with the fileDataRead method:

    TDataServer * tds = new TDataServer();
    tds->fileDataRead("flowrate_sampler_launcher_500.dat");

The linear regression is initialised and characteristic values are computed for rw with the estimate method:

    TLinearRegression *tlin = new TLinearRegression(tds, "rw","yhat");
    tlin->estimate();

13.6.2.3. Graph

../../_images/modelerFlowrateLinearRegression.png

Figure 13.38 Graph of the macro “modelerFlowrateLinearRegression.C”