pykoop.Tsvd
- class Tsvd(truncation='economy', truncation_param=None)
Bases:
BaseEstimatorTruncated singular value decomposition.
- left_singular_vectors_
Left singular vectors.
- Type:
np.ndarray
- singular_values_
Singular values.
- Type:
np.ndarray
- right_singular_vectors_
Right singular vectors.
- Type:
np.ndarray
- __init__(truncation='economy', truncation_param=None)
Instantiate
Tsvd.- Parameters:
truncation (str) –
Truncation method. Possible values are
'economy'– do not truncate (use economy SVD),'unknown_noise'– truncate using optimal hard truncation [GD14] with unknown noise,'known_noise'– truncate using optimal hard truncation [GD14] with known noise,'cutoff'– truncate singular values smaller than a cutoff, or'rank'– truncate singular values to a fixed rank.
truncation_param (Optional[float]) –
Parameter whose interpretation is based on the truncation method. For each truncation method,
truncation_paramis interpreted as'economy'– ignored,'unknown_noise'– ignored,'known_noise'– known noise magnitude,'cutoff'– singular value cutoff, or'rank'– desired rank.
- Return type:
None
Notes
Optimal hard truncation [GD14] assumes the noisy measured matrix
X_measuredis composed of:X_measured = X_true + noise_magnitude * X_noise
where
X_noiseis composed of i.i.d. Gaussian variables with zero mean and unit variance.Warning
Does not consider episode features!
Examples
SVD with no truncation
>>> tsvd = pykoop.Tsvd() >>> tsvd.fit(X_msd) Tsvd() >>> tsvd.singular_values_ array(...)
SVD with cutoff truncation
>>> tsvd = pykoop.Tsvd(truncation='cutoff', truncation_param=1e-3) >>> tsvd.fit(X_msd) Tsvd(truncation='cutoff', truncation_param=0.001) >>> tsvd.singular_values_ array(...)
SVD with manual rank truncation
>>> tsvd = pykoop.Tsvd(truncation='rank', truncation_param=2) >>> tsvd.fit(X_msd) Tsvd(truncation='rank', truncation_param=2) >>> tsvd.singular_values_ array(...)
Methods
__init__([truncation, truncation_param])Instantiate
Tsvd.fit(X[, y])Compute the truncated singular value decomposition.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
- fit(X, y=None)
Compute the truncated singular value decomposition.
- Parameters:
X (np.ndarray) – Data matrix.
y (Optional[np.ndarray]) – Ignored.
- Returns:
Instance of itself.
- Return type:
- Raises:
ValueError – If any of the constructor parameters are incorrect.
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance