ddl.base.DestructorMixin

class ddl.base.DestructorMixin[source]

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

Mixin helper class to add universal destructor methods.

Adds sample, get_domain, and score if the destructor defines the density_ attribute after fitting. (Also, if the destructor defines the attribute n_features_, no sampling is required to determine the number of features, see note below.)

Note that this finds the data dimension by looking sequentally for the fitted n_features_ attribute, the density_.n_features_ attribute, and finally attempting to call self.density_.sample(1) and determine the dimension from the density sample.

Methods

fit_transform(self, X[, y]) Fit to data, then transform it.
sample(self[, n_samples, random_state]) Generate random samples from this density/destructor.
score(self, X[, y]) Return the mean log likelihood (or log(det(Jacobian))).
__init__(self, /, *args, **kwargs)

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

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.

sample(self, n_samples=1, random_state=None)[source]

Generate random samples from this density/destructor.

Parameters:
n_samples : int, default=1

Number of samples to generate. Defaults to 1.

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.

Returns:
X : array, shape (n_samples, n_features)

Randomly generated sample.

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.