TIlabTrnDataSet

Declaration: TIlabTrnDataset = class(TRLData)
The class TIlabTrnDataset provides access to training and test datasets. You can both read existing datasets (created by the dataset editor) and create new ones. The general structure of the TIlabTrnDataset is as follows: it contains two tables, one holding the positions of the selected pixels and their associated class numbers, and one containing the names of the classes. Initially, both the pixel table and the classname table are empty (zero rows). In order to define classes you have to set the property NClasses and specify the names of the classes. The data point table is filled by using the method AddDataPoint. Existing data points can be read or changed by manipulating the arrays Xpos, Ypos and ClassIx.

The following list provides the properties and methods of the TIlabTrnDataset class:

Properties

Methods

Sample
program:
The following short program lets you select a dataset file and displays the coordinates and the class assignments of data points in the dataset:
program DisplayDataSet;

const
  PAGE = 1;

var
  dset           : TIlabTrnDataSet;
  FName          : string;

procedure ShowDataSet;

var
  i,j            : integer;

begin
ChartBook.Reset;
ChartBook.TabCaption[PAGE] := 'Dataset';
ChartBook.Configure
   (PAGE,               // page 1
    false, true, false, // only the table is visible
    250, 250);          // default width & height
with ChartBook.Tables[PAGE] do
  begin
  SuppressPaint := true;
  NrOfRows := dset.NDataPoints;         // adjust the table size
  NrOfColumns := DSet.NClasses+2;
  Clear;

  CommonHeader := 'Dataset: '+FName;    // create headers
  Header[1] := 'XPos';
  Header[2] := 'yPos';
  for i:=1 to NrOfColumns do
    begin
    Header[i+2] := DSet.ClassNames[i];
    ColumnCheckMode[i+2] := cmBox;
    end;
  for j:=1 to NrOfRows do               // fill in the data
    begin
    Elem[1,j] := strff(Dset.DataXPos[j],1,2);
    Elem[2,j] := strff(Dset.DataYPos[j],1,2);
    ElemChecked[2+DSet.DataClass[j],j] := true;
    end;
  FitAllColWidths (NrOfColumns, true, 4, 200, 24);
  SuppressPaint := false;
  end;
end;

begin         // main program
FName := SelectFile (GetILabDir(idTestData), '*.tdts', 'Select a file');
if FName <> '' then
  begin
  dset := TIlabTrnDataSet.Create(nil);
  if dset.Load(FName)
    then ShowDataSet
    else MessageDlg ('cannot load dataset', mtError, [mbOK]);
  dset.Free;
  end;
end.


Last Update: 2018-Mai-02