ddl.base.get_n_features

ddl.base.get_n_features(destructor, try_destructor_sample=False)[source]

Get the number of features for a fitted destructor.

Attempt to find n_features either from destructor.n_features_, destructor.density_.n_features_, or via density sampling destructor.density_.sample(1, random_state=0).shape[1].

Parameters:
destructor : estimator

The (fitted) destructor from which to extract the number of features.

try_destructor_sample : bool, optional, default=False

If True, additionally attempt destructor.sample(1, random_state=0).shape[ 1]. This option could cause infinite recursion since DestructorMixin uses get_n_features in order to sample but this can be avoided if the destructor reimplements sample without get_n_features such as in the ddl.base.CompositeDestructor.