TMtxPCA Class

ComponentTMtxComponentTMtxPCA

type TMtxPCA = class(TMtxComponent);

Performs Principle Component Analysis (PCA).

Principal Components Analysis - PCA - is a data analysis tool that is usually used to reduce the dimensionality (number of variables) of a large number of interrelated variables, while retaining as much of the information (variation) as possible. PCA calculates an uncorrelated set of variables (factors or PCs). These factors are ordered so that the first few retain most of the variation present in all of the original variables.

The PCA procedure is reduced to an eigenvalue-eigenvector problem. PCA routines perform a PCA on either a correlation or a covariance matrix. Data matrix can be either "raw" data or pre-calculated correlation/covariance matrix.

How to use TMtxPCA component?

  • Drop a TMtxPCA component on the form.
  • By setting the TMtxPCA.PCAMode property define whether PCA will use correlation or covariance matrix to calculate PCA.
  • Define the actual TMtxPCA.Data (by changing Data matrix values).
  • Call the TMtxPCA.Recalc method to calculate PCA results.

Results:

  • TMtxPCA.EigValues - Data eigenvalues
  • TMtxPCA.PC - Data eigenvectors
  • TMtxPCA.TotalVarPct - the percentage of the total variation in the variables (columns)
  • TMtxPCA.ZScores - Z-Scores (eigenvectors in PC space).

Examples

delphi
Uses StatTools, MtxVec, Statistics;
procedure Example(MtxPCA1: TMtxPCA);
begin
    // ...
    MtxPCA1.Data.SetIt(4,3,false,[1,2,3,
    5,7,9,
    1,11,13,
    3,7,4]);
    MtxPCA1.PCAMode := PCARawData; // using data matrix to evaluate PCA
    MtxPCA1.Recalc; // force recalculation
    // ...
end;

Properties

NameTypeDescription
AutoUpdateBooleanIf true then changing any of the TMtxPCA properties will trigger the TMtxPCA.Recalc method.
BlockAssignBooleanBlock streaming of specific properties when storing only a "template".
DataTMtxDefines the data to be analyzed by PCA.
DirtyBooleanWhen any of the TMtxPCA properties changes, this property is automatically set to true.
EditorActiveBooleanReturns True, if the component editor is displayed.
EigValuesTVecReturns the eigenvalues.
PCTMtxReturns the principal components (PC).
PCAModeTPCAModePCA type.
ReferenceTReferenceListStores a list of components that have to be notified, when this component is destroyed.
TotalVarPctTVecReturns the percentage of the total variation in the variables.
ZScoresTMtxReturns the Z-Scores.

Methods

NameDescription
AllowStreamingReturns the negatated value of BlockAssign.
AssignAssign values of all published properties from Source.
AssignTemplateAssign values of "template-like" published properties from Source.
EditorClassTo be overriden in descendanr classses.
LoadFromStreamLoad the component from Src stream.
LoadTemplateFromFileLoad a template from file.
LoadTemplateFromStreamLoad a template from stream.
RecalcTriggers PCA recalculation.
ResetReset is called after loading the data from stream or file.
SaveTemplateToFileSave template to file.
SaveTemplateToStreamSave template to stream.
SaveToStreamSave the component to Dst stream.