DocumentationClassesEmpiricalCovariance

Class: EmpiricalCovariance

Maximum likelihood covariance estimator.

Read more in the User Guide.

Python Reference

Constructors

new EmpiricalCovariance()

new EmpiricalCovariance(opts?): EmpiricalCovariance

Parameters

ParameterTypeDescription
opts?object-
opts.assume_centered?booleanIf true, data are not centered before computation. Useful when working with data whose mean is almost, but not exactly zero. If false (default), data are centered before computation.
opts.store_precision?booleanSpecifies if the estimated precision is stored.

Returns EmpiricalCovariance

Defined in generated/covariance/EmpiricalCovariance.ts:23

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/covariance/EmpiricalCovariance.ts:21
_isInitializedbooleanfalsegenerated/covariance/EmpiricalCovariance.ts:20
_pyPythonBridgeundefinedgenerated/covariance/EmpiricalCovariance.ts:19
idstringundefinedgenerated/covariance/EmpiricalCovariance.ts:16
optsanyundefinedgenerated/covariance/EmpiricalCovariance.ts:17

Accessors

covariance_

Get Signature

get covariance_(): Promise<ArrayLike[]>

Estimated covariance matrix

Returns Promise<ArrayLike[]>

Defined in generated/covariance/EmpiricalCovariance.ts:429


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/covariance/EmpiricalCovariance.ts:510


location_

Get Signature

get location_(): Promise<ArrayLike>

Estimated location, i.e. the estimated mean.

Returns Promise<ArrayLike>

Defined in generated/covariance/EmpiricalCovariance.ts:402


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/covariance/EmpiricalCovariance.ts:483


precision_

Get Signature

get precision_(): Promise<ArrayLike[]>

Estimated pseudo-inverse matrix. (stored only if store_precision is true)

Returns Promise<ArrayLike[]>

Defined in generated/covariance/EmpiricalCovariance.ts:456


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/covariance/EmpiricalCovariance.ts:42

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/covariance/EmpiricalCovariance.ts:98


error_norm()

error_norm(opts): Promise<number>

Compute the Mean Squared Error between two covariance estimators.

Parameters

ParameterTypeDescription
optsobject-
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_).
opts.scaling?booleanIf true (default), the squared error norm is divided by n_features. If false, the squared error norm is not rescaled.
opts.squared?booleanWhether 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.

Returns Promise<number>

Defined in generated/covariance/EmpiricalCovariance.ts:115


fit()

fit(opts): Promise<any>

Fit the maximum likelihood covariance estimator to X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training data, where n_samples is the number of samples and n_features is the number of features.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/covariance/EmpiricalCovariance.ts:172


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/covariance/EmpiricalCovariance.ts:213


get_precision()

get_precision(opts): Promise<any>

Getter for the precision matrix.

Parameters

ParameterTypeDescription
optsobject-
opts.precision_?ArrayLike[]The precision matrix associated to the current covariance object.

Returns Promise<any>

Defined in generated/covariance/EmpiricalCovariance.ts:249


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/covariance/EmpiricalCovariance.ts:55


mahalanobis()

mahalanobis(opts): Promise<ArrayLike>

Compute the squared Mahalanobis distances of given observations.

Parameters

ParameterTypeDescription
optsobject-
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/EmpiricalCovariance.ts:285


score()

score(opts): Promise<number>

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_.

Parameters

ParameterTypeDescription
optsobject-
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?anyNot used, present for API consistency by convention.

Returns Promise<number>

Defined in generated/covariance/EmpiricalCovariance.ts:323


set_score_request()

set_score_request(opts): Promise<any>

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.X_test?string | booleanMetadata routing for X_test parameter in score.

Returns Promise<any>

Defined in generated/covariance/EmpiricalCovariance.ts:366