cleverly.bases.Sieve#

class cleverly.bases.Sieve(basis: Any, size: Any = 'cv')[source]#

A nested family of bases and the rule that picks its size.

size is an integer (a fixed size), "cv" (chosen by cross-validation, which makes the target data-adaptive), or a declared schedule: a callable n -> size or a mapping from sample sizes to sizes, read at the largest key at most n. A fixed size or a schedule resolves to one known basis before the fit.

Parameters:
basisBasis

The largest member of the family; smaller members are its truncations.

sizeint, “cv”, callable() or mapping

How the member is chosen.

Methods#

Sieve.at(n: int) → Any[source]#

The basis this sieve declares for a sample of n rows.

Parameters:
nint

The sample size.

Returns:
Basis

The truncated basis.

classmethod Sieve.default(modifiers: Modifiers, *, max_size: int = 6, size: Any = 'cv') → Sieve[source]#

Additive cosines of the continuous modifiers and indicators of the categorical.

Parameters:
modifiersModifiers

The declared schema; every continuous modifier needs a domain.

max_sizeint

The largest number of cosines per continuous modifier.

sizeint, “cv”, callable() or mapping

How the member is chosen.

Returns:
Sieve

The default sieve.

Sieve.size_at(n: int) → int[source]#

The size this sieve declares for a sample of n rows.

Parameters:
nint

The sample size.

Returns:
int

The declared size.

Raises:
DataError

If the size is chosen by cross-validation, or a schedule gives no size at n.

Attributes#

Sieve.chosen_by_cv#

Whether the size is chosen by cross-validation.

Sieve.size: Any = 'cv'#
Sieve.basis: Any#