ddl.deep.DeepDestructor

class ddl.deep.DeepDestructor(canonical_destructor=None, init_destructor=None, n_canonical_destructors=1, random_state=None)[source]

Bases: ddl.base.CompositeDestructor

Destructor formed by composing copies of some atomic destructor.

This destructor creates a dynamic composite destructor that includes an optional initial destructor (parameter init_destructor) followed by multiple copies of a canonical destructor (parameter canonical_destructor). The init_destructor is often used for preprocessing steps such as standardization.

If the training data’s domain/support is not the unit hypercube, an initial destructor is required—this initial destructor should have a domain that matches the training data (by the definition of a destructor, the range of the destructor is the unit hypercube and thus the initial destructor will project the data onto the canonical domain.

This is a relatively thin wrapper around CompositeDestructor that creates copies of the canonical destructor to create a deep composite destructor with destuctors (or “layers”) that are similar in structure because they have the same hyperparameters.

Parameters:
canonical_destructor : estimator or list

The canonical destructor(s) that will be cloned to build up a deep destructor. Parameter canonical_destructor can be a list of canonical destructors. The list will be cycled through to get as many canonical destructors as needed.

init_destructor : estimator, optional

Initial destructor (e.g. preprocessing or just to project to canonical domain).

n_canonical_destructors : int, default=1

Number of cloned canonical destructors to add to the deep destructor.

random_state : int, RandomState instance or None, optional (default=None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by numpy.random.

Attributes:
fitted_destructors_ : list

List of fitted (sub)destructors. See fitted_destructors_ of CompositeDestructor.

density_ : estimator

Implicit density of deep destructor.

See also

DeepDestructorCV
A deep destructor whose number of destructors/layers is chosen automatically based on cross-validation test likelihood.
ddl.base.CompositeDestructor

Methods

create_fitted(fitted_destructors, \*\*kwargs) Create fitted destructor.
fit(self, X[, y]) Fit estimator to X.
fit_transform(self, X[, y]) Fit estimator to X and then transform X.
get_domain(self) Get the domain of this destructor.
get_params(self[, deep]) Get parameters for this estimator.
inverse_transform(self, X[, y, partial_idx]) Apply inverse destructive transformation to X.
sample(self[, n_samples, y, random_state]) Sample from composite destructor.
score(self, X[, y, partial_idx]) Override super class to allow for partial_idx.
score_layers(self, X[, y, partial_idx]) Override super class to allow for partial_idx.
score_samples(self, X[, y, partial_idx]) Compute log-likelihood (or log(det(Jacobian))) for each sample.
score_samples_layers(self, X[, y, partial_idx]) [Placeholder].
set_params(self, \*\*params) Set the parameters of this estimator.
transform(self, X[, y, partial_idx]) Apply destructive transformation to X.
__init__(self, canonical_destructor=None, init_destructor=None, n_canonical_destructors=1, random_state=None)[source]

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

classmethod create_fitted(fitted_destructors, **kwargs)

Create fitted destructor.

Parameters:
fitted_destructors : array-like of Destructor

Fitted destructors.

**kwargs

Other parameters to pass to constructor.

Returns:
fitted_transformer : Transformer

Fitted transformer.

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

Fit estimator to X.

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.

fit_params : dict, optional

Optional extra fit parameters.

Returns:
self : estimator

Returns the instance itself.

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

Fit estimator to X and then transform X.

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.

fit_params : dict, optional

Parameters to pass to the fit method.

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

Transformed data.

get_domain(self)

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, partial_idx=None)

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.

partial_idx : list or None, default=None

List of indices of the fitted destructor to use in the transformation. The default of None uses all the fitted destructors. Mainly used for visualization or debugging.

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

Transformed data (possibly only partial transformation).

sample(self, n_samples=1, y=None, random_state=None)

Sample from composite destructor.

Nearly the same as DestructorMixin.sample but the number of features is found from first fitted destructor to avoid recursion.

score(self, X, y=None, partial_idx=None)

Override super class to allow for partial_idx.

score_layers(self, X, y=None, partial_idx=None)

Override super class to allow for partial_idx.

score_samples(self, X, y=None, partial_idx=None)

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.

partial_idx : list or None, default=None

List of indices of the fitted destructor to use in the computing the log likelihood. The default of None uses all the fitted destructors. Mainly used for visualization or debugging.

Returns:
log_likelihood : array, shape (n_samples,)

Log likelihood of each data point in X.

score_samples_layers(self, X, y=None, partial_idx=None)

[Placeholder].

Parameters:
X :
y :
partial_idx :
Returns:
obj : object
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, partial_idx=None)

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.

partial_idx : list or None, default=None

List of indices of the fitted destructor to use in the transformation. The default of None uses all the fitted destructors. Mainly used for visualization or debugging.

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

Transformed data (possibly only partial transformation).