mixle.inference.streaming module¶
Online / streaming estimation over batched sufficient statistics.
streaming_accumulate folds one batch’s sufficient statistics; StreamingEstimator and
IncrementalEstimator drive incremental fitting across a stream of batches (with optional
forgetting/step schedules). Distinct from the Bayesian BayesianStreamingEstimator in
estimation.py.
- streaming_accumulate(enc_data, estimator, model)[source]
Return one batch’s globally tied sufficient-stat accumulator.
Encoded-data handles can implement
pysp_stream_accumulateto do the local/distributed fold themselves. Plain encoded chunks use the legacy in-processseq_updateloop.
- class StreamingEstimator(estimator, schedule=None, model=None, init_estimator=None, init_p=0.1, rng=None, encoder=None, num_chunks=1)[source]
Bases:
_StreamingBaseDecay-mode online estimator built from accumulator scaling and M-steps.
- Parameters:
estimator (ParameterEstimator)
model (SequenceEncodableProbabilityDistribution | None)
init_estimator (ParameterEstimator | None)
init_p (float)
rng (RandomState | None)
num_chunks (int)
- class IncrementalEstimator(estimator, model=None, init_estimator=None, init_p=0.1, rng=None, encoder=None, num_chunks=1)[source]
Bases:
_StreamingBaseNeal-Hinton style incremental EM over replaceable data chunks.
Each chunk contributes a sufficient-statistic payload computed under the current model. Revisiting a chunk subtracts that chunk’s previous payload, adds the new payload, and runs the ordinary estimator M-step on the pooled statistics. No distribution-specific estimation code lives here; the class only uses
scale(-1),combine(), andestimate().- Parameters:
estimator (ParameterEstimator)
model (SequenceEncodableProbabilityDistribution | None)
init_estimator (ParameterEstimator | None)
init_p (float)
rng (RandomState | None)
num_chunks (int)
- update(data=None, *, enc_data=None, chunk_id=None)[source]
Replace one chunk contribution and return the updated model.
chunk_idis keyword-only so this matchesStreamingEstimator.update()’s(data, *, enc_data)shape across the streaming surface; it is required (aNonechunk_idraises) because the Neal-Hinton update keys each batch’s contribution by it.
- chunk_value(chunk_id)[source]
Return a copy of one stored chunk contribution.
- Parameters:
chunk_id (Any)
- reset()[source]
Drop all chunk contributions and fitted model state.
- Return type:
None