// This macro reads in the data file "test_results.dat" that is made by the // test_results program and makes a plot of the output produced by the // ANN vs. the actual output. // // As a reminder, this test trained the ANN to multiply two numbers, each // from 0 to 3. The training sample only used integer values for each // input so the values in between are a result of the ANN exrapolating into // an area where no training samples were provided. void output_vs_actual(void) { TTree *t = new TTree("t","A tree"); t->ReadFile("test_results.dat","input1:input2:output"); TCanvas *c1 = new TCanvas("c1"); c1->SetGrid(); c1->SetTicks(); TH2D *axes = new TH2D("axes","ANN multiplication test2", 100, -0.5, 10.0, 100, -0.5, 10.0); axes->SetStats(0); axes->SetXTitle("ANN output"); axes->SetYTitle("input1*input2"); axes->Draw(); TLegend *leg = new TLegend(0.15, 0.6, 0.5, 0.85); leg->SetFillColor(kWhite); TLine *l = new TLine(-0.5, -0.5, 10.0, 10.0); l->SetLineColor(kMagenta); l->Draw(); leg->AddEntry(l, "perfect correlation"); // Draw line of ideal result t->SetMarkerStyle(1); t->SetMarkerSize(0.3); t->Draw("output:input1*input2","","same"); // Draw markers at training points for(int i=0; i<=3; i++){ for(int j=i; j<=3; j++){ double x = (double)i*(double)j; TMarker *m = new TMarker(x, x, 22); m->SetMarkerColor(kMagenta); m->SetMarkerSize(1.25); m->Draw(); if(i==0 && j==0)leg->AddEntry(m, "Training point"); } } leg->Draw(); c1->SaveAs("output_vs_actual.pdf"); c1->SaveAs("output_vs_actual.png"); }