TruncatedSVD
Module: strata.decomposition • Kind: struct • Traits: Copyable, Movable, Transformer
Source: strata/decomposition/truncated_svd.mojo
struct TruncatedSVD[compute_dtype: DType = DType.float64](Copyable, Movable, Transformer)from strata.decomposition import TruncatedSVDDimensionality reduction using truncated SVD.
Constructors
Section titled “Constructors”def __init__(out self, n_components: Int = 2)| Argument | Type | Description |
|---|---|---|
n_components |
Int |
— |
Methods Overview
Section titled “Methods Overview”| Method | Description |
|---|---|
TruncatedSVD.fit() |
Fits TruncatedSVD on dense matrix X. |
TruncatedSVD.transform() |
Projects dense matrix X onto the truncated components. |
TruncatedSVD.fit_transform() |
Fits TruncatedSVD to X and returns the projected data. |
TruncatedSVD.inverse_transform() |
Transforms data back to its original space. |
Method Details
Section titled “Method Details”TruncatedSVD.fit()
Section titled “TruncatedSVD.fit()”def fit[in_dtype: DType](mut self, X: Matrix[in_dtype])
def fit[in_dtype: DType](mut self, X: CSRMatrix[in_dtype])
def fit[feat_dtype: DType, target_dtype: DType]( mut self, dataset: Dataset[feat_dtype, target_dtype],)Overload Note: This method accepts either a standard
X: Matrixor a unifieddataset: Datasetcontainer.
Fits TruncatedSVD on dense matrix X.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Feature matrix. |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix. (Can be provided alternatively in place of X) |
TruncatedSVD.transform()
Section titled “TruncatedSVD.transform()”def transform[in_dtype: DType]( self, X: Matrix[in_dtype],) -> Matrix[in_dtype]
def transform[in_dtype: DType]( self, X: CSRMatrix[in_dtype],) -> Matrix[in_dtype]
def transform[feat_dtype: DType, target_dtype: DType]( self, dataset: Dataset[feat_dtype, target_dtype],) -> Dataset[ feat_dtype, target_dtype ]Overload Note: This method accepts either a standard
X: Matrixor a unifieddataset: Datasetcontainer.
Projects dense matrix X onto the truncated components.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Feature matrix. |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix. (Can be provided alternatively in place of X) |
Returns: Matrix[in_dtype]
TruncatedSVD.fit_transform()
Section titled “TruncatedSVD.fit_transform()”def fit_transform[in_dtype: DType]( mut self, X: Matrix[in_dtype],) -> Matrix[in_dtype]
def fit_transform[in_dtype: DType]( mut self, X: CSRMatrix[in_dtype],) -> Matrix[in_dtype]
def fit_transform[feat_dtype: DType, target_dtype: DType]( mut self, dataset: Dataset[feat_dtype, target_dtype],) -> Dataset[ feat_dtype, target_dtype ]Overload Note: This method accepts either a standard
X: Matrixor a unifieddataset: Datasetcontainer.
Fits TruncatedSVD to X and returns the projected data.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Feature matrix. |
dataset |
Dataset[feat_dtype, target_dtype] |
Dataset container holding feature matrix. (Can be provided alternatively in place of X) |
Returns: Matrix[in_dtype]
TruncatedSVD.inverse_transform()
Section titled “TruncatedSVD.inverse_transform()”def inverse_transform[in_dtype: DType]( self, X: Matrix[in_dtype],) -> Matrix[in_dtype]Transforms data back to its original space.
| Parameter | Type | Description |
|---|---|---|
X |
Matrix[in_dtype] |
Feature matrix. |
Returns: Matrix[in_dtype]