MLCore::MLDimReductionOperation
MLCore::MLDimReductionOperation
Abstract base for dimensionality reduction operations. More…
#include <MLDimReductionOperation.hpp>
Inherits from MLCore::MLModelOperation
Inherited by MLCore::ICAOperation, MLCore::PCAOperation, MLCore::RobustPCAOperation, MLCore::TSNEOperation
Public Functions
| Name | |
|---|---|
| ~MLDimReductionOperation() override =default | |
| virtual bool | fitTransform(arma::mat const & features, MLModelParametersBase const * params, arma::mat & result) =0 Fit the model to data and transform in a single call. |
| virtual bool | transform(arma::mat const & features, arma::mat & result) =0 Project new data using the fitted model. |
| virtual std::size_t | outputDimensions() const =0 Return the number of output dimensions after reduction. |
| virtual std::vector< double > | explainedVarianceRatio() const =0 Return the explained variance ratio per component (if available). |
| virtual MLTaskType | getTaskType() const override Dimensionality reduction is always its own task type. |
| virtual bool | fit(arma::mat const & features, MLModelParametersBase const * params) override Route fit() to fitTransform() (discarding the result). |
Additional inherited members
Public Functions inherited from MLCore::MLModelOperation
| Name | |
|---|---|
| virtual | ~MLModelOperation() =default |
| virtual std::string | getName() const =0 Unique human-readable name for this model (e.g., “Random Forest”). |
| virtual std::unique_ptr< MLModelParametersBase > | getDefaultParameters() const =0 Create a default parameter set for this model. |
| virtual bool | train(arma::mat const & features, arma::Row< std::size_t > const & labels, MLModelParametersBase const * params) Train the model on labeled data. |
| virtual bool | predict(arma::mat const & features, arma::Row< std::size_t > & predictions) Predict class labels for new observations. |
| virtual bool | predictProbabilities(arma::mat const & features, arma::mat & probabilities) Predict class probabilities for new observations. |
| virtual bool | trainSequences(std::vector< arma::mat > const & featureSequences, std::vector< arma::Row< std::size_t > > const & labelSequences, MLModelParametersBase const * params) Train the model on pre-segmented temporal sequences. |
| virtual bool | predictSequences(std::vector< arma::mat > const & featureSequences, std::vector< arma::Row< std::size_t > > & predictionSequences) Predict labels for pre-segmented temporal sequences. |
| virtual bool | predictSequencesConstrained(std::vector< arma::mat > const & featureSequences, std::vector< arma::Row< std::size_t > > & predictionSequences, std::vector< std::optional< std::size_t > > const & initial_state_constraints) Predict labels with per-sequence initial state constraints. |
| virtual bool | predictSequencesBidirectionalConstrained(std::vector< arma::mat > const & featureSequences, std::vector< arma::Row< std::size_t > > & predictionSequences, std::vector< std::optional< std::size_t > > const & initial_state_constraints, std::vector< std::optional< std::size_t > > const & terminal_state_constraints) Predict labels with both initial and terminal state constraints. |
| virtual bool | predictProbabilitiesPerSequence(std::vector< arma::mat > const & featureSequences, std::vector< arma::mat > & probabilitySequences, std::vector< std::optional< std::size_t > > const & initial_state_constraints, std::vector< std::optional< std::size_t > > const & terminal_state_constraints) Compute per-sequence state probabilities with boundary constraints. |
| virtual bool | isSequenceModel() const Whether this model natively handles temporal sequences. |
| virtual bool | assignClusters(arma::mat const & features, arma::Row< std::size_t > & assignments) Assign cluster labels to observations. |
| virtual bool | save(std::ostream & out) const Save the trained model to a stream. |
| virtual bool | load(std::istream & in) Load a previously saved model from a stream. |
| virtual bool | isTrained() const =0 Whether the model has been trained (supervised) or fit (unsupervised). |
| virtual std::size_t | numClasses() const Number of classes (supervised) or clusters (unsupervised). |
| virtual std::size_t | numFeatures() const Number of features the model was trained on. |
Detailed Description
class MLCore::MLDimReductionOperation;Abstract base for dimensionality reduction operations.
Fit/Transform workflow
op->fitTransform(features, params, result); // fit + transform in one call
op->transform(new_features, result); // project new data (if supported)
auto ratio = op->explainedVarianceRatio(); // inspect explained varianceAll matrices use mlpack convention: (features × observations) — each column is one observation.
Unlike clustering operations, dimensionality reduction produces a transformed matrix rather than cluster labels. The output matrix has n_components rows and the same number of columns as the input.
Public Functions Documentation
function ~MLDimReductionOperation
~MLDimReductionOperation() override =defaultfunction fitTransform
virtual bool fitTransform(
arma::mat const & features,
MLModelParametersBase const * params,
arma::mat & result
) =0Fit the model to data and transform in a single call.
Parameters:
- features Input matrix (features × observations) in mlpack convention
- params Algorithm-specific parameters
- result Output: reduced matrix (n_components × observations)
Return: true on success
Precondition:
- features must not be empty (enforcement: runtime_check)
- features must not contain NaN or Inf values (enforcement: none) [IMPORTANT]
- params must be of the correct concrete type for this operation (enforcement: none)
- Features are expected to be z-score normalized (mean≈0, std≈1 per feature) when scale-sensitive comparison across features is desired. Normalization is the caller’s responsibility (via FeatureConverter). Centering is handled internally by each algorithm. (enforcement: none) [IMPORTANT]
Postcondition:
- isTrained() returns true on success
- result has n_components rows and features.n_cols columns
Reimplemented by: MLCore::ICAOperation::fitTransform, MLCore::PCAOperation::fitTransform, MLCore::RobustPCAOperation::fitTransform, MLCore::TSNEOperation::fitTransform
function transform
virtual bool transform(
arma::mat const & features,
arma::mat & result
) =0Project new data using the fitted model.
Parameters:
- features Input matrix (features × observations)
- result Output: reduced matrix (n_components × observations)
Return: true on success, false if not fitted or projection unsupported
Precondition:
- isTrained() must be true (enforcement: runtime_check)
- features.n_rows must equal numFeatures() (enforcement: none) [IMPORTANT]
- features must not contain NaN or Inf values (enforcement: none) [IMPORTANT]
- Features must be z-score normalized using the SAME parameters (mean/std) that were used for the training data passed to fitTransform(). Use FeatureConverter::applyZscoreNormalization() with stored parameters. (enforcement: none) [IMPORTANT]
Reimplemented by: MLCore::ICAOperation::transform, MLCore::PCAOperation::transform, MLCore::RobustPCAOperation::transform, MLCore::TSNEOperation::transform
function outputDimensions
virtual std::size_t outputDimensions() const =0Return the number of output dimensions after reduction.
Reimplemented by: MLCore::ICAOperation::outputDimensions, MLCore::PCAOperation::outputDimensions, MLCore::RobustPCAOperation::outputDimensions, MLCore::TSNEOperation::outputDimensions
function explainedVarianceRatio
virtual std::vector< double > explainedVarianceRatio() const =0Return the explained variance ratio per component (if available).
Return: Vector of explained variance ratios (one per component), or empty if not applicable to this algorithm
Reimplemented by: MLCore::ICAOperation::explainedVarianceRatio, MLCore::PCAOperation::explainedVarianceRatio, MLCore::RobustPCAOperation::explainedVarianceRatio, MLCore::TSNEOperation::explainedVarianceRatio
function getTaskType
inline virtual MLTaskType getTaskType() const overrideDimensionality reduction is always its own task type.
Reimplements: MLCore::MLModelOperation::getTaskType
function fit
inline virtual bool fit(
arma::mat const & features,
MLModelParametersBase const * params
) overrideRoute fit() to fitTransform() (discarding the result).
Reimplements: MLCore::MLModelOperation::fit
Updated on 2026-11-13 at 20:25:41 +0000