nirs4all.operators.transforms.sequence module

Fixed-width host encodings of variable-length multichannel series.

class nirs4all.operators.transforms.sequence.SequenceSummary(statistics: Sequence[str] = ('mean', 'std', 'min', 'max'), *, include_length: bool = True, channel_names: Sequence[str] | None = None, min_observations: int = 1, channel_bounds: Sequence[Sequence[float]] | None = None)[source]

Bases: TransformerMixin, BaseEstimator

Summarize each ragged series independently, without padding or resampling.

Input is a nirs4all_io.ragged.RaggedSeriesBatch. Each row contains a variable number of observations and the same number of channels. Output columns are ordered by channel, then by statistics; the optional length column comes last. Standard deviation uses ddof=0.

Observations have equal weight: time coordinates are deliberately ignored. Empty series and nonfinite observed values are refused. Missing sources must be excluded by the source-presence policy before reaching this encoder. Fitting records the channel contract, not training values or lengths. New series lengths are therefore accepted by the fitted encoder.

Parameters:
  • statistics – Ordered, distinct subset of mean, std, min and max. An empty sequence is permitted when include_length is true, producing only the length column.

  • include_length – Append the number of observations in each series.

  • channel_names – Optional distinct, nonempty names, one per channel. Otherwise use channel_0, channel_1, etc. The source schema is responsible for preserving channel semantics across datasets.

  • min_observations – Explicit minimum number of observations per series, checked during fit and prediction. The default accepts one.

  • channel_bounds – Optional inclusive, finite (lower, upper) limits in channel order. Every observation must satisfy these declared limits. No applicability range is inferred from training or held-out rows.

channel_bounds_: tuple[tuple[float, float], ...] | None
channel_names_: tuple[str, ...]
feature_names_in_: ndarray
fit(X: Any, y: Any = None) → Self[source]

Record a channel contract from the supplied training rows only.

get_feature_names_out(input_features: Any = None) → ndarray[source]

Name output columns in their stable channel/statistic order.

include_length_: bool
min_observations_: int
n_features_in_: int
n_features_out_: int
statistics_: tuple[str, ...]
transform(X: Any) → ndarray[source]

Return independent per-channel summaries for new series lengths.