RPar

Declaration: TRndForest.RPar: double;
The property RPar controls the resampling factor of the random forest. Typical values are between 0.30 and 0.66. If the resampling factor is set to values less than zero or greater than 0.8 the method CalculateModel will not work.

Hint: You can find the optimum resampling factor by performing an R-scan in the Random Forest Development Tool.

Sample
Program:
The following sample program shows how to scan the RPar property and display the OOB RMS error in a chart:
program RF_RScan;

const
  TSLOT = 1;         // time slot of data cube to be used
  PAGE = 1;          // default chart page
  SCANRVON = 0.02;   // range of RPar to be scanned
  SCANRBIS = 0.8;
  SCANRRES = 0.02;   // resolution of R scan
  NREP = 5;          // number of repetitions
  NTREES = 75;       // number of trees

                     // please note that both the training data and the
                     // spectral descriptors are expected to be available
                     // in the respective default directories...
  TRNDATA   = 'test_trndata.tdts';        // training data
  SPDCFNAME = 'test_descriptors.spdc';    // spectral descriptors

var
  clix        : integer;
  rep         : integer;
  RF          : TRndForest;
  errnum      : integer;
  First       : boolean;
  repo        : TRFReport;
  cnt         : integer;

begin
FuncMon (false);
ChartBook.Reset;
ChartBook.TabCaption[PAGE] := 'Tab 1';
ChartBook.Configure
   (PAGE,               // page 1
    true, false, false, // only the chart is visible
    250, 250);          // default width & height
ChartBook.TabCaption[PAGE] := 'Cross Section';
ChartBook.Charts[PAGE].Clear;
ChartBook.Charts[PAGE].ScalePropsX[1].Caption := 'R';
ChartBook.Charts[PAGE].ScalePropsY[1].Caption := 'OOB RMSError';
ChartBook.Charts[PAGE].SetRange(1,0,0,0.8,1);

RF := TRndForest.Create(nil);
RF.SpdcSet.LoadUnchecked (GetILabDir (idSpdc)+SPDCFNAME, cnt);
RF.LoadTrnData (GetILabDir(idTestData)+TRNDATA);
RF.NTrees := NTREES;
RF.RPar := SCANRVON-SCANRRES;

First := true;
while (RF.RPar <= SCANRBIS) do
  begin
  RF.RPar := RF.RPar + SCANRRES;
  Application.ProcessMessages;
  ChartBook.Charts[PAGE].SuppressPaint := true;
  rep:=0;
  while rep < NREP do
    begin
    inc (rep);
    Application.ProcessMessages;
    for clix := 1 to RF.NClasses do
      begin
      errnum := RF.CalculateModel (RawData, TSLOT, MData, first);
      first := false;
      ChartBook.Charts[PAGE].DataColor := GetClassColor(clix);
      repo := RF.Report[clix];
      ChartBook.Charts[PAGE].MarkAt (RF.RPar, repo.OOBRMSError, 26);
      end;
    end;
  ChartBook.Charts[PAGE].SuppressPaint := false;
  end;
ChartBook.Charts[PAGE].AutoRange (1,2);
ChartBook.Charts[PAGE].Update;
RF.Free;
FuncMon (true);
end.