incerto.shift.ClassifierShiftDetector#

class incerto.shift.ClassifierShiftDetector(clf_factory=None, device=None)[source]#

Bases: BaseShiftDetector

Train a logistic regression to separate reference and test.

  • Lipton et al., 2018 (Black Box Shift Detection)

Parameters:

device (Optional[str])

__init__(clf_factory=None, device=None)[source]#
Parameters:

device (Optional[str])

Methods

__init__([clf_factory, device])

fit(reference_loader)

Fit the detector on reference (source) distribution.

load(path)

Load a detector from a file.

load_state_dict(state)

Load classifier shift detector state.

save(path)

Save detector state to a file.

score(test_loader)

Compute shift score between reference and test distributions.

state_dict()

Save classifier shift detector state.

__init__(clf_factory=None, device=None)[source]#
Parameters:

device (Optional[str])

state_dict()[source]#

Save classifier shift detector state.

Note: The classifier itself is not serialized because it is re-fitted on every call to score(). A fresh LogisticRegression will be used after loading. Pass clf_factory again if you need a different classifier.

Return type:

dict

load_state_dict(state)[source]#

Load classifier shift detector state.

Parameters:

state (dict)

Return type:

None