Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Set the authentication threshold of a subject.
Parameters
----------
subject : hashable
Subject identity.
threshold : int, float
Threshold value.
ready : bool, optional
If True, `subject` is the internal classifier label.
"""
if not ready:
if not self.check_subject(subject):
raise SubjectError(subject)
subject = self._subject2label[subject]
try:
self._thresholds[subject]['auth'] = threshold
except KeyError:
self._thresholds[subject] = {'auth': threshold, 'id': None}
----------
subject : hashable
Subject identity.
ready : bool, optional
If True, `subject` is the internal classifier label.
Returns
-------
threshold : int, float
Threshold value.
"""
if not ready:
if not self.check_subject(subject):
raise SubjectError(subject)
subject = self._subject2label[subject]
return self._thresholds[subject].get('id', None)
"""Set the identification threshold of a subject.
Parameters
----------
subject : hashable
Subject identity.
threshold : int, float
Threshold value.
ready : bool, optional
If True, `subject` is the internal classifier label.
"""
if not ready:
if not self.check_subject(subject):
raise SubjectError(subject)
subject = self._subject2label[subject]
try:
self._thresholds[subject]['id'] = threshold
except KeyError:
self._thresholds[subject] = {'auth': None, 'id': threshold}
----------
subject : hashable
Subject identity.
ready : bool, optional
If True, `subject` is the internal classifier label.
Returns
-------
threshold : int, float
Threshold value.
"""
if not ready:
if not self.check_subject(subject):
raise SubjectError(subject)
subject = self._subject2label[subject]
return self._thresholds[subject].get('auth', None)
Authentication threshold.
Returns
-------
decision : array
Authentication decision for each input sample.
"""
# check train state
if not self.is_trained:
raise UntrainedError
# check subject
if not self.check_subject(subject):
raise SubjectError(subject)
label = self._subject2label[subject]
# check threshold
if threshold is None:
threshold = self.get_auth_thr(label, ready=True)
# prepare data
aux = self._prepare(data, targets=label)
# authenticate
decision = self._authenticate(aux, label, threshold)
return decision
SubjectError
If the subject to remove is not enrolled.
Notes
-----
* When using deferred calls, a dismiss overrides a previous enroll
for the same subject.
"""
# check inputs
if subject is None:
raise TypeError("Please specify the subject identity.")
if not self.check_subject(subject):
raise SubjectError(subject)
label = self._subject2label[subject]
del self._subject2label[subject]
del self._thresholds[label]
self._nbSubjects -= 1
self.io_del(label)
if deferred:
self._defer(label, 'dismiss')
else:
self._train(None, [label])
self._check_state()
self.update_thresholds()