Changeset 8656 for trunk/MagicSoft/Mars/mjtrain
- Timestamp:
- 08/03/07 13:00:52 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mjtrain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc
r8644 r8656 189 189 // Run Disp optimization 190 190 // 191 Bool_t MJTrainDisp::Train (const char *out, const MDataSet &set, Int_t num)191 Bool_t MJTrainDisp::TrainDisp(const char *out, const MDataSet &set, Int_t num) 192 192 { 193 193 SetTitle(Form("TrainDisp: %s", out)); … … 224 224 if (fEnableWeights) 225 225 train.AddColumn("MWeight.fVal"); 226 train.AddColumn(f gTrainParameter);226 train.AddColumn(fTrainParameter); 227 227 228 228 // ----------------------- Fill Matrix RF ---------------------- … … 240 240 241 241 // ------------------------ Train RF -------------------------- 242 MRanForestCalc rf( fTitle);242 MRanForestCalc rf("TrainDisp", fTitle); 243 243 rf.SetNumTrees(fNumTrees); 244 244 rf.SetNdSize(fNdSize); … … 268 268 gLog.Separator("Test"); 269 269 270 MH::SetPalette("pretty"); 271 270 272 MParList plist; 271 273 MTaskList tlist; … … 329 331 MFillH fillh2a(&hdisp1, "", "FillSize"); 330 332 MFillH fillh2b(&hdisp2, "", "FillEnergy"); 331 fillh2a.SetDrawOption(" blueprofx");332 fillh2b.SetDrawOption(" blueprofx");333 fillh2a.SetDrawOption("colz profx"); 334 fillh2b.SetDrawOption("colz profx"); 333 335 fillh2a.SetNameTab("Size"); 334 336 fillh2b.SetNameTab("Energy"); … … 354 356 355 357 // Print the result 356 *fLog << inf << "Rule: " << rule << endl; 358 *fLog << inf; 359 *fLog << "Rule: " << rule << endl; 360 *fLog << "Disp: " << fTrainParameter << endl; 357 361 hist.GetAlphaFitter().Print("result"); 358 362 … … 366 370 } 367 371 372 /* 373 #include "MParameterCalc.h" 374 #include "MHillasCalc.h" 375 #include "../mpointing/MSrcPosRndm.h" 376 377 Bool_t MJTrainDisp::TrainGhostbuster(const char *out, const MDataSet &set, Int_t num) 378 { 379 SetTitle(Form("TrainGhostbuster: %s", out)); 380 381 if (fDisplay) 382 fDisplay->SetTitle(fTitle); 383 384 if (!set.IsValid()) 385 { 386 *fLog << err << "ERROR - DataSet invalid!" << endl; 387 return kFALSE; 388 } 389 390 if (!HasWritePermission(out)) 391 return kFALSE; 392 393 *fLog << inf; 394 fLog->Separator(GetDescriptor()); 395 396 // --------------------- Setup files -------------------- 397 MReadMarsFile readtrn("Events"); 398 MReadMarsFile readtst("Events"); 399 readtrn.DisableAutoScheme(); 400 readtst.DisableAutoScheme(); 401 402 if (!set.AddFilesOn(readtrn)) 403 return kFALSE; 404 if (!set.AddFilesOff(readtst)) 405 return kFALSE; 406 407 // ----------------------- Setup Matrix ------------------ 408 MHMatrix train("Train"); 409 train.AddColumns(fRules); 410 if (fEnableWeights) 411 train.AddColumn("MWeight.fVal"); 412 train.AddColumn("sign(MHillasSrc.fCosDeltaAlpha)==sign(SignStore.fVal)"); 413 414 MParameterCalc calc("MHillasSrc.fCosDeltaAlpha", "SignStore"); 415 calc.SetNameParameter("SignStore"); 416 417 MSrcPosRndm rndm; 418 rndm.SetRule(fTrainParameter); 419 //rndm.SetDistOfSource(120*3.37e-3); 420 421 MHillasCalc hcalc; 422 hcalc.SetFlags(MHillasCalc::kCalcHillasSrc); 423 424 // ----------------------- Fill Matrix RF ---------------------- 425 MTFillMatrix fill(fTitle); 426 fill.SetDisplay(fDisplay); 427 fill.SetLogStream(fLog); 428 fill.SetDestMatrix1(&train, num); 429 fill.SetReader(&readtrn); 430 fill.AddPreCuts(fPreCuts); 431 fill.AddPreCuts(fTrainCuts); 432 fill.AddPreTasks(fPreTasks); 433 fill.AddPostTasks(fPostTasks); 434 fill.AddPostTask(&calc); 435 fill.AddPostTask(&rndm); 436 fill.AddPostTask(&hcalc); 437 if (!fill.Process()) 438 return kFALSE; 439 440 // ------------------------ Train RF -------------------------- 441 MRanForestCalc rf("TrainGhostbuster", fTitle); 442 rf.SetNumTrees(fNumTrees); 443 rf.SetNdSize(fNdSize); 444 rf.SetNumTry(fNumTry); 445 rf.SetNumObsoleteVariables(1); 446 rf.SetLastDataColumnHasWeights(fEnableWeights); 447 rf.SetDisplay(fDisplay); 448 rf.SetLogStream(fLog); 449 rf.SetFileName(out); 450 rf.SetDebug(fDebug>1); 451 rf.SetNameOutput("Sign"); 452 453 if (!rf.TrainRegression(train)) // regression (best choice) 454 return kFALSE; 455 456 // --------------------- Display result ---------------------- 457 458 gLog.Separator("Test"); 459 460 MH::SetPalette("pretty"); 461 462 MParList plist; 463 MTaskList tlist; 464 plist.AddToList(this); 465 plist.AddToList(&tlist); 466 //plist.AddToList(&b); 467 468 MFilterList list; 469 if (!list.AddToList(fPreCuts)) 470 *fLog << err << "ERROR - Calling MFilterList::AddToList for fPreCuts failed!" << endl; 471 if (!list.AddToList(fTestCuts)) 472 *fLog << err << "ERROR - Calling MFilterList::AddToList for fTestCuts failed!" << endl; 473 474 MContinue cont(&list); 475 cont.SetInverted(); 476 477 const char *rule = "abs(Sign.fVal-(sign(MHillasSrc.fCosDeltaAlpha)==sign(SignStore.fVal)))"; 478 479 //MChisqEval eval; 480 //eval.SetY1("sqrt(ThetaSquared.fVal)"); 481 482 MH3 hsign1("MHillas.fSize", rule); 483 MH3 hsign2("MMcEvt.fEnergy", rule); 484 hsign1.SetTitle("Was ist das? vs. Size:Size [phe]:XXX"); 485 hsign2.SetTitle("Was ist das? vs. Energy:Enerhy [GeV]:XXXX"); 486 487 MBinning binsx( 70, 10, 31623, "BinningMH3X", "log"); 488 MBinning binsy( 51, 0, 1, "BinningMH3Y", "lin"); 489 490 plist.AddToList(&binsx); 491 plist.AddToList(&binsy); 492 493 MFillH fillh2a(&hsign1, "", "FillSize"); 494 MFillH fillh2b(&hsign2, "", "FillEnergy"); 495 fillh2a.SetDrawOption("profx colz"); 496 fillh2b.SetDrawOption("profx colz"); 497 fillh2a.SetNameTab("Size"); 498 fillh2b.SetNameTab("Energy"); 499 500 tlist.AddToList(&readtst); 501 tlist.AddToList(&cont); 502 tlist.AddToList(&calc); 503 tlist.AddToList(&rndm); 504 tlist.AddToList(&hcalc); 505 tlist.AddToList(&rf); 506 tlist.AddToList(&fillh2a); 507 tlist.AddToList(&fillh2b); 508 //tlist.AddToList(&eval); 509 510 MEvtLoop loop(fTitle); 511 loop.SetLogStream(fLog); 512 loop.SetDisplay(fDisplay); 513 loop.SetParList(&plist); 514 //if (!SetupEnv(loop)) 515 // return kFALSE; 516 517 if (!loop.Eventloop()) 518 return kFALSE; 519 520 // Print the result 521 *fLog << inf << "Rule: " << rule << endl; 522 523 //DisplayResult(hdisp1, hdisp2); 524 525 SetPathOut(out); 526 if (!WriteDisplay(0, "UPDATE")) 527 return kFALSE; 528 529 return kTRUE; 530 } 531 */ -
trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.h
r8644 r8656 27 27 28 28 Bool_t Train(const char *out, const MDataSet &set, Int_t num); 29 //Bool_t TrainGhostbuster(const char *out, const MDataSet &set, Int_t num); 29 30 30 31 ClassDef(MJTrainDisp, 0)//Class to train Random Forest disp estimator
Note:
See TracChangeset
for help on using the changeset viewer.