Classifier-based filters¶
These filters compare the observed labels against predictions obtained from one or more base classifiers.
Overview¶
ClassificationFilteruses a single classifier and out-of-fold predictions.CVCFFilteraggregates fold-wise committee votes.FilterEnsembleFilter(FEF) combines several existing filters by vote and score.EnsembleFilteringcompares several estimators.INFFC_old_wrongiteratively fuses a heterogeneous committee.IterativePartitioningFilterrepeatedly 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.
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 |
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.
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 |
"S"
|
threshold
|
float
|
Minimum fraction of disagreeing estimators required when |
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.
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 |
required |
strategy
|
str
|
Decision rule used to flag samples as noisy. Supported values are
|
"majority"
|
min_votes
|
int or None
|
Minimum number of votes required when |
None
|
vote_threshold
|
float
|
Fraction of filters that must vote noisy when |
0.5
|
score_threshold
|
float
|
Minimum aggregated ensemble score when |
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: |
True
|
use_filter_scores
|
bool
|
If True, use each base filter's |
True
|
score_fallback
|
str
|
Fallback strategy used when a base filter does not provide
|
"binary"
|
normalize_scores
|
bool
|
Whether to normalize each base filter score to |
False
|
min_class_count
|
int
|
Minimum number of samples to keep per class after filtering. |
2
|
action
|
str
|
Post-fit action. |
"remove"
|
random_state
|
int or None
|
Optional seed propagated to cloned base filters when they expose a
|
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.
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: |
"auto"
|
noise_filter
|
object or None
|
Existing filter exposing a |
None
|
noise_scores
|
array - like or None
|
Precomputed noise scores. Values are clipped to |
None
|
fit_filter
|
bool
|
Whether to fit |
False
|
threshold
|
(mean, quantile, adaptative, rational_valley, adaptative_quadratic)
|
Thresholding rule. |
"mean"
|
quantile
|
float or None
|
Quantile used when |
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.
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
|
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 |
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.
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.