ddl.autoregressive.AutoregressiveDestructor¶
-
class
ddl.autoregressive.AutoregressiveDestructor(density_estimator=None, order=None, random_state=None)[source]¶ Bases:
ddl.base.BaseDensityDestructorAutoregressive destructor using densities that can compute conditionals.
The density estimator should implement the method
conditional_densitiesthat will return conditional densities,marginal_cdfthat will return the marginal cdf for a particular feature index, andmarginal_inverse_cdfthat will return the marginal inverse cdf for a particular feature index. For an example of this type of density, seeddl.gaussian.GaussianDensityorddl.mixture.GaussianMixtureDensity.Note that this interface has not been fully standardized yet and is likely to change in the future.
Parameters: - density_estimator : estimator
Density estimator to be used for the autoregressive destructor. Note that this estimator must implement
conditional_densities,marginal_cdf, andmarginal_inverse_cdf.- order : {None, ‘random’, array-like with shape (n_features,)}, default=None
If None, then simply choose the original index order. If ‘random’, then use the random number generator defined by the random_state parameter to generate a random permutation of feature indices. If an array-like is given, then use this as the order of features to regress.
- random_state : int, RandomState instance or None, optional (default=None)
Used to determine random feature order if order is not given.
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.
Attributes: - density_ : estimator
Fitted underlying density.
Methods
fit(self, X[, y, density_fit_params])[Placeholder]. fit_from_density(self, density)[Placeholder]. 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. 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))). 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, density_estimator=None, order=None, random_state=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
fit(self, X, y=None, density_fit_params=None)¶ [Placeholder].
Parameters: - X :
- y :
- density_fit_params :
Returns: - obj : object
-
fit_from_density(self, density)¶ [Placeholder].
Parameters: - density :
Returns: - obj : object
-
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)¶ 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 anddomain[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.
-
sample(self, n_samples=1, random_state=None)¶ 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.
-
score_samples(self, X, y=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.
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.