ddl.base.DestructorMixin¶
-
class
ddl.base.DestructorMixin[source]¶ Bases:
ddl.base.ScoreMixin,sklearn.base.TransformerMixinMixin helper class to add universal destructor methods.
Adds
sample,get_domain, andscoreif the destructor defines thedensity_attribute after fitting. (Also, if the destructor defines the attributen_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, thedensity_.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
RandomStateinstance, random_state is the random number generator; If None, the random number generator is theRandomStateinstance used bynumpy.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.
-