Factorization¶
lzsuite.factorization ¶
Return LZ76 factor counts and phrase boundaries.
Parameters:
-
data(array_like) –Real numeric, boolean, Unicode-string, or byte-string array. Each position outside
axisidentifies one sequence. Floats default to per-sequence mean binarization; other supported dtypes are symbols. -
axis(int, default:0) –Axis containing successive observations. Negative axes are accepted.
-
discretization(str or callable, default:None) –Registered method name or function applied to each numeric sequence. Overrides automatic mean binarization. Strings cannot be discretized.
-
discretization_kwargs(mapping of str to object, default:None) –Keyword arguments passed to the selected discretizer. Custom methods receive an input copy and may return a different sequence length.
-
n_jobs(int, default:4) –Maximum worker processes, capped by available CPUs and calculation count. Use 1 for inline execution or -1 for all available CPUs.
Returns:
-
result(tuple of (int, list of int) or numpy.ndarray) –For 1D input,
(count, boundaries)directly. For higher-dimensional input, an object array of those tuples, withaxisremoved.
Raises:
-
TypeError–If the dtype, discretizer output, or parameter type is unsupported.
-
ValueError–If the sequence axis is empty, values are nonfinite, the axis or settings are invalid, or a custom discretizer returns no labels.
Warns:
-
RuntimeWarning–If more than 256 categories must be reduced to the byte alphabet. Categories then merge and results no longer faithfully represent the original alphabet.
Notes
Boundaries index the prepared symbolic sequence, whose length may change during discretization. The final attempted phrase boundary can extend beyond the input. A copied tail does not contribute to the completed-factor count, so count need not equal len(boundaries) - 1. Clamp end positions to sequence length when displaying visible phrases.
Preparation and discretization run in the caller. Native calculations
use reusable joblib processes, with one Rayon thread per worker. The
caller's Rayon configuration is unchanged. A single calculation runs
inline. Use n_jobs=1 when process overhead outweighs useful work.
See Also
complexity : Return only the factor count. lz76 : Factorization and all other measures.
Examples: