Skip to content

← feature_extraction package

SparsePrincipalComponentAnalysis

Reduce dimensionality using Sparse Principal Component Analysis (Sparse PCA).

Basic PCA is one of the most commonly-used dimensionality reduction techniques, and will produce components, that is linear combinations of input features, such that the first component captures the direction of largest variance in the data, the second component the next-largest (orthogonal) direction, and so on. The difference in sparse PCA is that these components will in addition only be based on a small ("sparse") subset of the input features, rather than combining all features together like PCA does. The tradeoff between sparsity versus best capturing the direction of maximum variance in the data can be adjusted using the sparsity parameter. Note that, since this method is not aware of any "labels" of the data, and as such only performs what is known as unsupervised learning, there is no guarantee that the method will not remove data dimensions that would have been informative about those labels, that is, useful to a subsequent supervised learning method. Nevertheless, dimensionality reduction can greatly speed up subsequent data processing, or make it tractable in the first place. Also, the components produced by Sparse PCA can, given the right data, produce interpretable or otherwise meaningful features, which can enable subsequent machine learning methods to make good use of them. Important:This node is adaptive to the data, that is, it will learn a transformation of the data that depends on the input data. In order to learn this transformation, the node requires a reasonable amount of input data for calibration or "training" (otherwise it will yield an ill-fitting or noisy model). Since this feature extraction method is not capable of being trained incrementally on streaming data, the method requires a data packet that contains the entire training data; this training data packet can either be accumulated online and then released in one shot using the Accumulate Calibration Data node, or it can be imported from a separate calibration recording and then spliced into the processing pipeline using the Inject Calibration Data, where it passes through the same nodes as the regular data until it reaches the machine learning node, where it is used for calibration. Once this node is calibrated, the trainable state of this node can be saved to a model file and later loaded for continued use. Like most other feature extraction nodes, this node can compute features between elements of an axis of your choice while treating elements of another axis as the observations, trials, or samples. It can also optionally compute multiple separate models on different slices of the data along some axis of choice. It is also possible to pool multiple axes for any of these roles. More Info... Version 1.0.0

Ports/Properties

domain_axes

Axes which form the input domain of the transformation. Features are computed between elements along these axes (or in other words, elements along these axes will be combined with each other to yield features). This is a comma-separated list of axis names (for example: "space, frequency"), possibly empty, or the special string "(all others)", which stands for all axes that are not listed in the other two lists of axes. For time-series data, this is usually the space axis, and if features have already been extracted from the data through some other method, it would be the features axis. In rare cases it can also include other axes, such as frequency, lag, and time. This axis drops out of the data and is replaced by a feature axis that has a number of elements that corresponds to the output feature dimension of the model.

  • verbose name: Compute Features Between Axes
  • default value: (all others)
  • port type: ComboPort
  • value type: str (can be None)

aggregate_axes

Axes that have the statistical observations in them. The elements along these axes are treated as the "trials", "samples", or, equivalently, "observations". Adaptive feature extractors will aggregate statistics along the elements of these axes during training. When the transformer applies to data, this axis remains in the data (if multiple, they will be flattened into one axis, however). This is a comma-separated list of axis names (for example: "time, instance"), possibly empty, or the special string "(all others)", which stands for all axes that are not listed in the other two lists of axes. This is almost always the instance axis (especially if the data has already been segmented, i.e., if the Segmentation node was used), but in some cases it may also be the time axis, or occasionally other axes.

  • verbose name: Treat Elements As Trials/samples Along Axes
  • default value: instance
  • port type: ComboPort
  • value type: str (can be None)

separate_axes

Axes along which to learn separate models. It is possible to use multiple separate feature-extraction models, each of which operates on a different slice of the data. This node does not combine data between elements along these axes in any way (although features between these elements may of course be combined in later stages, for instance in a classifier node). This is a comma-separated list of axis names (for example: "time, frequency"), possibly empty, or the special string "(all others)", which stands for all axes that are not listed in the other two lists of axes. This axis, if any, will also persist in the data.

  • verbose name: Compute Separate Models Along Axes
  • default value:
  • port type: ComboPort
  • value type: str (can be None)

data

Data to process.

  • verbose name: Data
  • default value: None
  • port type: DataPort
  • value type: Packet (can be None)
  • data direction: INOUT

num_components

Number of components to keep. If left unspecified, all components are kept, that is, the number of output features will correspond to the number of input dimensions.

  • verbose name: Number Of Components
  • default value: None
  • port type: IntPort
  • value type: int (can be None)

alpha

Degree of sparsity. Higher values yield components with more sparse support.

  • verbose name: Degree Of Sparsity
  • default value: 1.0
  • port type: FloatPort
  • value type: float (can be None)

max_iter

Maximum number of iterations. This is one of the stopping criteria to limit the compute time. The default is usually fine, and gains from increasing the number of iterations will be minimal (it can be worth experimenting with lower iteration numbers if the algorithm must finish in a fixed time budget, at a cost of potentially less accurate solutions).

  • verbose name: Maximum Number Of Iterations
  • default value: 1000
  • port type: IntPort
  • value type: int (can be None)

num_jobs

Number of parallel compute jobs. This value only affects the running time and not the results. Values between 1 and twice the number of CPU cores make sense to expedite computation, but may temporarily reduce the responsiveness of the machine. The value of -1 stands for all available CPU cores.

  • verbose name: Number Of Parallel Jobs
  • default value: 1
  • port type: IntPort
  • value type: int (can be None)

verbosity

Verbosity level. Higher numbers will produce more extensive diagnostic output.

  • verbose name: Verbosity Level
  • default value: 0
  • port type: IntPort
  • value type: int (can be None)

ridge_alpha

Shrinkage parameter to improve transform conditioning.

  • verbose name: Ridge Alpha
  • default value: 0.01
  • port type: FloatPort
  • value type: float (can be None)

tolerance

Convergence tolerance. This is the desired errors tolerance or acceptable inaccuracy in the solution. Using larger values gives less accurate results, but will lead to faster compute times. Note that, for biosignal-driven machine learning systems, one often does not need very small tolerances.

  • verbose name: Tolerance
  • default value: 0.0001
  • port type: FloatPort
  • value type: float (can be None)

method

Method for optimization. The lars method is faster than coordinate descent if the components are sparse.

  • verbose name: Method
  • default value: lars
  • port type: EnumPort
  • value type: str (can be None)

random_seed

Random seed. Different values may yield slightly different results.

  • verbose name: Random Seed
  • default value: 12345
  • port type: IntPort
  • value type: int (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)