Skip to content

Classifier-based filters

These filters compare the observed labels against predictions obtained from one or more base classifiers.

Overview

  • ClassificationFilter uses a single classifier and out-of-fold predictions.
  • CVCFFilter aggregates fold-wise committee votes.
  • FilterEnsembleFilter (FEF) combines several existing filters by vote and score.
  • EnsembleFiltering compares several estimators.
  • INFFC_old_wrong iteratively fuses a heterogeneous committee.
  • IterativePartitioningFilter repeatedly partitions the data and checks agreement.

ClassificationFilter

Bases: BaseEstimator

Cross-validated single-classifier noise filter.

Parameters:

Name Type Description Default
estimator estimator

Base learner cloned and trained on each fold.

required
cv int

Number of stratified folds used to generate out-of-fold predictions.

10
action (remove, detect)

Whether noisy samples are dropped or only detected.

"remove"
random_state int

Seed used by the stratified splitter.

33
Notes

A sample is flagged as noisy when its out-of-fold prediction differs from the observed label.

fit(X, y)

Fit the filter and cache out-of-fold predictions.

fit_resample(X, y)

Fit the filter and return the filtered or detected data.

get_filter_report()

Return a dictionary with the main fit diagnostics.

get_detection_report()

Return the stored detection report.

Summary of a single-classifier noise filtering run.

CVCFFilter

Bases: BaseEstimator

Cross-validated committees noise filter.

Parameters:

Name Type Description Default
estimator estimator

Base learner cloned for each fold of the committee.

c45_like
cv int

Number of stratified folds used to build the committee.

10
vote_rule (threshold, majority, consensus)

Rule used to flag samples as noisy from the fold disagreements.

"threshold"
threshold float

Minimum fraction of disagreeing folds required when vote_rule="threshold".

0.5
action (remove, detect)

Whether noisy samples are dropped or only detected.

"remove"
random_state int

Seed used by the stratified splitter.

33
Notes

Relabel is not implemented yet.

fit(X, y)

Fit the filter and cache fold-wise predictions and agreement scores.

fit_resample(X, y)

Fit the filter and return the filtered data.

get_filter_report()

Return a dictionary with the main fit diagnostics.

get_detection_report()

Return the stored detection report.

Summary of a cross-validated committees filtering run.

EnsembleFiltering

Bases: BaseEstimator

Ensemble-based noise filter using multiple classifiers.

Parameters:

Name Type Description Default
estimators sequence of estimators

Base learners combined in the ensemble committee.

required
cv int

Number of stratified folds used to compute out-of-fold predictions.

10
mode str

Decision rule used to flag samples as noisy. The current implementation accepts "threshold" and "consensus"; the signature default is kept for compatibility.

"S"
threshold float

Minimum fraction of disagreeing estimators required when mode="threshold".

0.5
action (remove, detect)

Whether noisy samples are dropped or only detected.

"remove"
random_state int

Seed used by the stratified splitter.

33
return_noisy_samples bool

Stored on the instance for compatibility; the current implementation does not branch on it.

False
Notes

A sample is flagged as noisy when enough estimators disagree with its observed label.

fit(X, y)

Fit the filter and cache ensemble disagreement counts.

fit_resample(X, y)

Fit the filter and return the filtered data.

get_filter_report()

Return a dictionary with the main fit diagnostics.

get_detection_report()

Return the stored detection report.

Summary of an ensemble-based noise filtering run.

FilterEnsembleFilter

FEF accepts either filter instances or (name, filter) pairs. It supports union, majority, consensus, k_of_m, threshold, and weighted_threshold strategies. The report includes per-filter votes, score matrices, normalized weights, support counts, support fractions, base reports, and class-protection metadata.

Bases: BaseEstimator

Combine several noise filters using vote and score aggregation.

Parameters:

Name Type Description Default
base_filters list

Sequence of fitted or unfitted filters. Each item can be either a filter instance or a (name, filter) pair.

required
strategy str

Decision rule used to flag samples as noisy. Supported values are "union", "majority", "consensus", "k_of_m", "threshold", and "weighted_threshold".

"majority"
min_votes int or None

Minimum number of votes required when strategy="k_of_m".

None
vote_threshold float

Fraction of filters that must vote noisy when strategy="threshold".

0.5
score_threshold float

Minimum aggregated ensemble score when strategy="weighted_threshold".

0.5
filter_weights list of float or None

Optional weight per base filter. If omitted, all filters receive equal weight. The weights are normalized internally.

None
refit_base_filters bool

Whether to clone and fit the base filters inside :meth:fit. When False, the provided filters are treated as already fitted.

True
use_filter_scores bool

If True, use each base filter's noise_score when available. Otherwise every filter contributes only its binary vote.

True
score_fallback str

Fallback strategy used when a base filter does not provide noise_score. Only "binary" is implemented.

"binary"
normalize_scores bool

Whether to normalize each base filter score to [0, 1] before aggregation.

False
min_class_count int

Minimum number of samples to keep per class after filtering.

2
action str

Post-fit action. "remove" and "detect" are executed now. "weight" and "relabel" are reserved for future support.

"remove"
random_state int or None

Optional seed propagated to cloned base filters when they expose a random_state parameter set to None.

None
n_jobs int or None

Reserved for future parallel execution.

None
Notes

The final detection report preserves the common structure used by the rest of the library and adds ensemble-specific diagnostics such as the vote and score matrices.

fit(X, y)

Fit the ensemble filter and cache the detection report.

fit_resample(X, y)

Fit the filter and return the filtered data.

fit_filter(X, y)

Fit the filter and return the filtered data plus the report.

get_support_matrix()

Return the binary vote matrix of the base filters.

get_score_matrix()

Return the per-filter score matrix used by the ensemble.

get_ensemble_score()

Return the aggregated ensemble noise score.

get_sample_weight(mode='linear')

Return instance weights derived from the ensemble noise score.

get_filter_report()

Return a compact summary of the ensemble run.

get_detection_report()

Return the stored detection report.

Summary of a filter-ensemble noise filtering run.

NoiseScoreFilter

NoiseScoreFilter thresholds an existing score vector or the noise_score_ exposed by another fitted filter. It supports fixed numeric thresholds, mean, quantile, beta-adaptive thresholding, and rational-valley thresholding with a detailed threshold_report_.

Bases: BaseSampler

Filter samples using a threshold on their noise scores.

Parameters:

Name Type Description Default
sampling_strategy str or dict

Passed to :class:imblearn.base.BaseSampler.

"auto"
noise_filter object or None

Existing filter exposing a noise_score_ attribute. When fit_filter=True and the filter is not already fitted, it is trained during :meth:fit to obtain those scores.

None
noise_scores array - like or None

Precomputed noise scores. Values are clipped to [0, 1] during fit.

None
fit_filter bool

Whether to fit noise_filter inside :meth:fit when it does not yet expose noise_score_.

False
threshold (mean, quantile, adaptative, rational_valley, adaptative_quadratic)

Thresholding rule. "mean" uses the average noise score. "quantile" uses the requested quantile of the score distribution. "adaptative" fits two beta-shaped score populations and uses their intersection as the threshold. "rational_valley" fits a rational surrogate to a density estimate and only accepts internal minima that are stable enough. Numeric values are used directly.

"mean"
quantile float or None

Quantile used when threshold="quantile".

None
Notes

The adaptive branch stores overlap_ as the area shared by the two fitted densities. Lower values mean a cleaner separation between the low-score and high-score regions.

fit(X, y)

Cache the noise scores, optionally fit the nested filter and compute the threshold.

fit_resample(X, y)

Fit the filter and return the cleaned sample set.

INFFC_old_wrong

Bases: BaseEstimator

Legacy iterative fusion-of-classifiers noise filter.

Parameters:

Name Type Description Default
estimators sequence of estimators or None

Base learners used by the committee. If None, a default trio of C4.5-like tree, 1-NN and LDA is used.

None
cv int

Number of stratified folds used inside each iteration.

10
decision_rule (majority, consensus, threshold)

Rule used to flag a sample as noisy from the committee disagreements.

"majority"
threshold float

Minimum disagreement fraction required when decision_rule="threshold".

0.5
action (remove, detect)

Whether noisy samples are dropped or only detected.

"remove"
max_iter int

Maximum number of cleaning iterations.

20
max_removed_frac float

Stop once this fraction of the original training set has been removed.

0.5
random_state int

Seed used by the stratified splitter in each iteration.

33
Notes

Relabel is not implemented yet.

fit(X, y)

Fit the filter and iteratively remove noisy samples.

fit_resample(X, y)

Fit the filter and return the filtered or detected data.

get_filter_report()

Return a dictionary with the main fit diagnostics.

get_detection_report()

Return the stored detection report.

Summary of a legacy INFFC filtering run.

Per-iteration diagnostics for the legacy INFFC variant.

IterativePartitioningFilter

Bases: BaseEstimator

Iterative partitioning noise filter.

Parameters:

Name Type Description Default
estimator estimator

Base learner fitted on each partition.

c45_like
n_partitions int

Number of stratified partitions built at each iteration.

10
vote_rule (majority, consensus)

Rule used to flag a sample as noisy from the partition disagreements.

"majority"
action (remove, detect)

Whether noisy samples are dropped or only detected.

"remove"
p_stop float

Patience threshold expressed as a fraction of the original dataset.

0.01
k_patience int

Number of consecutive low-yield iterations tolerated before stopping.

3
max_iter int

Maximum number of cleaning iterations.

20
random_state int

Seed used by the stratified splitter in each iteration.

33
Notes

Relabel is not implemented yet.

fit(X, y)

Fit the filter and iteratively partition the training data.

fit_resample(X, y)

Fit the filter and return the filtered or detected data.

get_filter_report()

Return a dictionary with the main fit diagnostics.

get_detection_report()

Return the stored detection report.

Summary of an iterative partitioning filtering run.

Per-iteration diagnostics for iterative partitioning filtering.