DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


ApplyModel

Declaration: TMemBasedLearner.ApplyModel (Sensor: TDoubleArray; ExcludeObj, Tag: integer): integer;
The method ApplyModel applies the kNN model as defined by the parameters ModelData, DistMode, NumNearestNb, LocalModel and VarType to the data in the parameter Sensor. The Sensor array has to contain the values of the independent variables exactly in the cells which correspond to the variables declared as mblVarIndep in the property VarType. The results of the applied model are stored in the Sensor cells corresponding the variables declared as mblVarTarget. Variables declared as mblVarIgnore are not used for the calculations, the corresponding cells in Sensor are left unchanged.

The parameter ExcludeObj specifies the index of an object of the ModelData which has to be excluded when applying the model. ExcludeObj should be set to a zero value if all objects of the model data should be used for the calculations. Note that setting ExcludeObj to a non-zero value allows you to perform a one-fold (full) cross validation of the model.

The parameter Tag is a user-defined integer number which will be passed on to the OnModelApplied event.

The method returns the following error codes:

 0 .... everything is OK
-1 .... singular matrix encountered in regression model
-2 .... the number of neighbors exceeds the number objects of the model
-3 .... the width of the sensor array does not match the width of ModelData

The event OnModelApplied is triggered after the function has been completed. Please note, that this event provides additional information on the nearest neighbors of the Sensor data.