TIlabTrnDataSet

Declaration: TIlabTrnDataset = class(TComponent)
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 four tables, one holding the positions of the selected pixels and their associated class numbers, one the names of the classes, one user-dedined quantities and one the names of the quantities. Initially, all tables are empty (zero rows). In order to define new classes you have to call the method AddClass. The readonly property NClasses returns the number of defined classes. Likewise the user-defined quantities can extended by calling AddQuantity. The readonly property NQuantities returns the number of user-defined quantities. The names of the quantities can be specified by using the array property QuantNames.

The data point table is filled by using the method AddDataPoint. Existing data points can be read or changed by manipulating the arrays DataXPos, DataYPos and DataClass.

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.