Repository navigation
nonconform 2.1.0 makes ConformalDetector a drop-in scikit-learn estimator and adds Python 3.11 support.
pip install -U nonconformAdded
ConformalDetectoris now a scikit-learnBaseEstimator, socloneworks and it can be the last step of aPipeline, whatever detector it wraps.predict(X)appliesselect(X, alpha=alpha)to the whole batch and returns-1for selected anomalies and1otherwise;alphais a new constructor parameter (default0.05), andpredictleaveslast_resultunchanged.n_features_in_andfeature_names_in_are set byfit()andcalibrate().strategyis optional and defaults toSplit(). Passing a string such as"split"or the classSplitinstead of an instance raises aTypeErrorthat names the fix.- The detector may be a plain scoring function
f(X) -> scores, treated as already fitted, or an object with onlyfitanddecision_function. With an identity function, precomputed scores can be calibrated and selected. ConformalResult.to_frame()returns the scores, p-values, and weights as a DataFrame that keeps the index of a pandas test batch.- Column names are checked at inference: a detector fitted on a DataFrame rejects renamed or reordered test columns and warns when test data has no column names, with scikit-learn's messages. SciPy sparse input raises a
TypeErrorthat suggestsX.toarray().
Changed
- nonconform now supports Python 3.11 (
requires-python = ">=3.11"). CI tests 3.11, 3.12 and 3.13. - The NumPy floor is now 2.0 (was 2.2). The test suite passes on the lowest declared versions: NumPy 2.0.0, pandas 2.2.2, SciPy 1.13.1 and scikit-learn 1.5.2.
- The SciPy floor is now 1.13.1, the first release built against NumPy 2.
- oddball (in the
dataandallextras) requires Python 3.12, so on Python 3.11 those extras install without it. PyArrow is still installed. - Omitting
score_polarityfor a detector nonconform does not recognize now logs a warning that higher-is-anomalous was assumed. The resolved polarity is unchanged. - "Detector has no random_state parameter" is now logged at debug level instead of as a warning, since it fired for every deterministic detector.
- The empty-selection p-value floor warning now also suggests checking
score_polarity, and the error for blocked PyOD detectors names detectors that work. - DataFrames now reach scikit-learn detectors and Pipelines unchanged instead of being converted to NumPy, so a
ColumnTransformercan select columns by name. PyOD and custom detectors still receive NumPy arrays. get_params()now returns the objects passed to the constructor orset_params(), as scikit-learn requires, instead of detached copies. The fitted detector still uses its own copies, so editing a returned object changes later clones but not the current detector.- Shape errors use scikit-learn's wording, for example "X has 2 features, but ConformalDetector is expecting 3 features as input."
Fixed
- A scikit-learn
Pipelinenow takes its score polarity from its final step. Before,make_pipeline(StandardScaler(), IsolationForest())withscore_polarityomitted was treated as higher-is-anomalous, which silently inverted every decision, andscore_polarity="auto"raised. Pipelines whose final step is a blocked batch-adaptive PyOD detector are now rejected too. seednow reaches everyPipelinestep that exposesrandom_state, andn_jobsandcontaminationreach the final step (for exampleisolationforest__random_state), so seeded pipeline runs are reproducible.LocalOutlierFactor()withoutnovelty=Truenow fails at construction with a message namingnovelty=True, instead of anAttributeErrorat scoring.
Full changelog: v2.0.1...v2.1.0