LedoitWolf
LedoitWolf Estimator.
Ledoit-Wolf is a particular form of shrinkage, where the shrinkage coefficient is computed using O. Ledoit and M. Wolf’s formula as described in “A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices”, Ledoit and Wolf, Journal of Multivariate Analysis, Volume 88, Issue 2, February 2004, pages 365-411.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new LedoitWolf(opts?: object): LedoitWolf;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.assume_centered? | boolean | If true , data will not be centered before computation. Useful when working with data whose mean is almost, but not exactly zero. If false (default), data will be centered before computation. Default Value false |
opts.block_size? | number | Size of blocks into which the covariance matrix will be split during its Ledoit-Wolf estimation. This is purely a memory optimization and does not affect results. Default Value 1000 |
opts.store_precision? | boolean | Specify if the estimated precision is stored. Default Value true |
Returns
Defined in: generated/covariance/LedoitWolf.ts:25 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/covariance/LedoitWolf.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/covariance/LedoitWolf.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/covariance/LedoitWolf.ts:21 (opens in a new tab)
id
string
Defined in: generated/covariance/LedoitWolf.ts:18 (opens in a new tab)
opts
any
Defined in: generated/covariance/LedoitWolf.ts:19 (opens in a new tab)
Accessors
covariance_
Estimated covariance matrix.
Signature
covariance_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/covariance/LedoitWolf.ts:327 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/covariance/LedoitWolf.ts:446 (opens in a new tab)
location_
Estimated location, i.e. the estimated mean.
Signature
location_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/covariance/LedoitWolf.ts:352 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/covariance/LedoitWolf.ts:421 (opens in a new tab)
precision_
Estimated pseudo inverse matrix. (stored only if store_precision is true
)
Signature
precision_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/covariance/LedoitWolf.ts:375 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/covariance/LedoitWolf.ts:51 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/covariance/LedoitWolf.ts:55 (opens in a new tab)
shrinkage_
Coefficient in the convex combination used for the computation of the shrunk estimate. Range is [0, 1].
Signature
shrinkage_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/covariance/LedoitWolf.ts:398 (opens in a new tab)
Methods
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/covariance/LedoitWolf.ts:106 (opens in a new tab)
error_norm()
Compute the Mean Squared Error between two covariance estimators.
Signature
error_norm(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.comp_cov? | ArrayLike [] | The covariance to compare with. |
opts.norm? | "frobenius" | "spectral" | The type of norm used to compute the error. Available error types: - ‘frobenius’ (default): sqrt(tr(A^t.A)) - ‘spectral’: sqrt(max(eigenvalues(A^t.A)) where A is the error (comp\_cov \- self.covariance\_) . Default Value 'frobenius' |
opts.scaling? | boolean | If true (default), the squared error norm is divided by n_features. If false , the squared error norm is not rescaled. Default Value true |
opts.squared? | boolean | Whether to compute the squared error norm or the error norm. If true (default), the squared error norm is returned. If false , the error norm is returned. Default Value true |
Returns
Promise
<number
>
Defined in: generated/covariance/LedoitWolf.ts:123 (opens in a new tab)
fit()
Fit the Ledoit-Wolf shrunk covariance model to X.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Training data, where n\_samples is the number of samples and n\_features is the number of features. |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/covariance/LedoitWolf.ts:181 (opens in a new tab)
get_precision()
Getter for the precision matrix.
Signature
get_precision(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.precision_? | ArrayLike [] | The precision matrix associated to the current covariance object. |
Returns
Promise
<any
>
Defined in: generated/covariance/LedoitWolf.ts:219 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/covariance/LedoitWolf.ts:64 (opens in a new tab)
mahalanobis()
Compute the squared Mahalanobis distances of given observations.
Signature
mahalanobis(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | The observations, the Mahalanobis distances of the which we compute. Observations are assumed to be drawn from the same distribution than the data used in fit. |
Returns
Promise
<ArrayLike
>
Defined in: generated/covariance/LedoitWolf.ts:252 (opens in a new tab)
score()
Compute the log-likelihood of X\_test
under the estimated Gaussian model.
The Gaussian model is defined by its mean and covariance matrix which are represented respectively by self.location\_
and self.covariance\_
.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X_test? | ArrayLike [] | Test data of which we compute the likelihood, where n\_samples is the number of samples and n\_features is the number of features. X\_test is assumed to be drawn from the same distribution than the data used in fit (including centering). |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<number
>
Defined in: generated/covariance/LedoitWolf.ts:287 (opens in a new tab)