5. PCA (module)

kClusterLib.pca.extractRelations(spnd_ids, inpMat, threshVarCap)[source]

Makes pca model and saves it in a ‘.np’ file.

Parameters:
  • spnd_ids (list) – list of SPND IDs that belong to same cluster
  • inpMat (ndArray) – Matrix containing the SPND values
  • threshVarCap (float) – Percent Threshold (Given as fraction) to select the Eigenvalues.
Returns:

  • relationEvectors (ndArray) – Singular Matrix
  • covResidualMat (ndArray) – covariance Matrix

Example

>>> cluster, inpMat, labels, combinedMean, combinedVar = loadKCFromDisk()
>>> clusterlist=separateClusters(cluster)
>>> threshVarCap=0.01
>>> for i in range(max(cluster)+1):
>>>     a,b = extractRelations(clusterlist[i],inpMat,threshVarCap)
>>>     print a,b
kClusterLib.pca.makeModels(eigenThreshold, clusterMap, dataMat)[source]

Creates and stores PCA Models in disk.

Parameters:
  • eigenThreshold (float) – Percentage Value to filter out the Eigen values.
  • dataMat (ndArray) – Sensor Data matrix on which model is to be created
  • clusterMap (list) – Mapping of SPND <–> Cluster ID
Returns:

fname – Name of file created on disk.

Return type:

string