ddl.independent.IndependentInverseCdf

class ddl.independent.IndependentInverseCdf[source]

Bases: sklearn.base.BaseEstimator, ddl.base.ScoreMixin, sklearn.base.TransformerMixin

Independent inverse CDF transformer applied coordinate-wise.

A transformer (or relative destructor) that performs the inverse CDF transform independently for the fitted univariate densities corresponding to each feature. The default is the inverse CDF of the standard normal; this default is useful to make linear projection destructors canonical by prepending this as a preprocessing step so that the domain of the destructor is the unit hypercube (i.e. canonical domain).

See fit function documentation for more information.

Attributes:
fitted_densities_ : array, shape (n_features,)

Fitted univariate densities for each feature. Note that these must be passed in as parameters to the fit function. All needed transformation and scoring information is built into the univariate densities. For example, the transform function merely uses the inverse_cdf function.

Methods

create_fitted(n_features[, fitted_densities]) Create fitted transformer.
fit(self, X[, y, fitted_densities]) Fit estimator to X.
fit_transform(self, X[, y]) Fit to data, then transform it.
get_domain(self) Get the domain of this destructor.
get_params(self[, deep]) Get parameters for this estimator.
inverse_transform(self, X[, y]) Apply inverse destructive transformation to X.
score(self, X[, y]) Return the mean log likelihood (or log(det(Jacobian))).
score_samples(self, X[, y]) Compute log-likelihood (or log(det(Jacobian))) for each sample.
set_params(self, \*\*params) Set the parameters of this estimator.
transform(self, X[, y]) Apply destructive transformation to X.
__init__(self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

classmethod create_fitted(n_features, fitted_densities=None, **kwargs)[source]

Create fitted transformer.

Parameters:
fitted_density : Density

Fitted density.

**kwargs

Other parameters to pass to constructor.

Returns:
fitted_transformer : Transformer

Fitted transformer.

fit(self, X, y=None, fitted_densities=None, **fit_params)[source]

Fit estimator to X.

X is only used to get the number of features.

Parameters:
X : array-like, shape (n_samples, n_features)

Training data, where n_samples is the number of samples and n_features is the number of features.

y : None, default=None

Not used in the fitting process but kept for compatibility.

fitted_densities : array-like of estimators

Default assumes that fitted_densities are standard Gaussian. fitted_densities should be fitted versions of the following similar to the univariate_estimators parameter of IndependentDensity:

  1. None (defaults to fitted ScipyUnivariateDensity()),
  2. univariate density estimator,
  3. array-like of univariate density estimators.
Returns:
self : estimator

Returns the instance itself.

fit_transform(self, X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.

Returns:
X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

get_domain(self)[source]

Get the domain of this destructor.

Returns:
domain : array-like, shape (2,) or shape (n_features, 2)

If shape is (2, ), then domain[0] is the minimum and domain[1] is the maximum for all features. If shape is (n_features, 2), then each feature’s domain (which could be different for each feature) is given similar to the first case.

get_params(self, deep=True)

Get parameters for this estimator.

Parameters:
deep : boolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

inverse_transform(self, X, y=None)[source]

Apply inverse destructive transformation to X.

Parameters:
X : array-like, shape (n_samples, n_features)

New data, where n_samples is the number of samples and n_features is the number of features.

y : None, default=None

Not used in the transformation but kept for compatibility.

Returns:
X_new : array-like, shape (n_samples, n_features)

Transformed data.

score(self, X, y=None)

Return the mean log likelihood (or log(det(Jacobian))).

Parameters:
X : array-like, shape (n_samples, n_features)

New data, where n_samples is the number of samples and n_features is the number of features.

y : None, default=None

Not used but kept for compatibility.

Returns:
log_likelihood : float

Mean log likelihood data points in X.

score_samples(self, X, y=None)[source]

Compute log-likelihood (or log(det(Jacobian))) for each sample.

Parameters:
X : array-like, shape (n_samples, n_features)

New data, where n_samples is the number of samples and n_features is the number of features.

y : None, default=None

Not used but kept for compatibility.

Returns:
log_likelihood : array, shape (n_samples,)

Log likelihood of each data point in X.

set_params(self, **params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
self
transform(self, X, y=None)[source]

Apply destructive transformation to X.

Parameters:
X : array-like, shape (n_samples, n_features)

New data, where n_samples is the number of samples and n_features is the number of features.

y : None, default=None

Not used in the transformation but kept for compatibility.

Returns:
X_new : array-like, shape (n_samples, n_features)

Transformed data.