Unreleased
# Unreleased
drift¶
- The
river.driftsub-package is now clean under strict mypy, and theriver.drift.*entry was removed from the non-strict overrides inpyproject.toml. Public signatures and docstrings are unchanged. - Fixed a latent bug in
drift.datasets.base.Dataset._annotations_aggregated, which read a nonexistentself._annotationsattribute and keyed the intersection branch on the integer0instead of the annotator key. The method has no callers today, so behavior is unchanged. DriftRetrainingClassifiernow passes aboolinstead of anintas the error indicator to its wrapped binary drift detector.
naive_bayes¶
- Added
CategoricalNB, a Naive Bayes classifier for categorical features that maintains per-class frequencies for every value of every feature, with additive (Laplace) smoothing and support for both online and mini-batch modes.
linear_model¶
BayesianLinearRegression.predict_dist_onenow replacesBayesianLinearRegression.predict_one(..., with_dist=True)to better respect theRegressorinterface while still being able to predict distributions.
naive_bayes¶
MultinomialNB.learn_many,predict_many, andpredict_proba_manynow accept any narwhals-supported eager backend (pandas, polars, pyarrow, ...) instead of being pandas-only, preserving the input backend (including the pandas index) on output. A backend-agnosticBaseNB.predict_manywas added so the argmax-over-probabilities logic is shared by all Naive Bayes variants.
stream¶
stream.Cachenow writes a pass to a temporary file and renames it into place once the stream is exhausted. An interrupted first pass (abreak, an exception, an abandoned generator) used to leave a truncated file behind, which every later pass then read back as if it were the whole dataset.stream.iter_csvno longer yields an emptyxfor a blank line in the middle of a file.csv.DictReaderskips those, andstream.iter_arffalready did.stream.iter_csvnow closes the file it opened and restorescsv.field_size_limiteven when the stream is not exhausted, e.g. when the caller breaks out of the loop. Only the fileiter_csvopened itself is closed; a buffer passed in by the caller is still left open.stream.iter_sqlnow closes the result it iterates, so the underlying cursor is released once the stream is exhausted or abandoned.stream.cache,stream.iter_csv, andstream.iter_sqlare now clean under strict mypy.sqlalchemyis type-checked rather than ignored, so thequeryandconnarguments ofstream.iter_sqlare checked against the SQLAlchemy 2.0 types.
preprocessing¶
preprocessing.Normalizernow handles zero vectors without raising aZeroDivisionError. A zero vector is returned unchanged instead.
cluster¶
- Fixed the radius of
cluster.DenStreammicro-clusters, which used the norm of the vector of squared sums instead of the sum of its components and was 0 away from the origin. The docstring example now usesepsilon=1.0. cluster.DenStream.predict_onenow expands a cluster past the direct neighbors of its first micro-cluster. The neighbors of a neighbor were only queued if they already had a label, so a chain of micro-clusters came out as several clusters.- New
cluster.DenStreammicro-clusters no longer reuse the key of a deleted one, which overwrote an existing micro-cluster.