-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f33ea9
commit 8e270be
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,9 @@ | |
@email: [email protected] | ||
""" | ||
|
||
from .import base | ||
from .import base | ||
from .fixed_uncertainty import FixedUncertainty | ||
from .random_variable_uncertainty import RandomVariableUncertainty | ||
from .variable_uncertainty import VariableUncertainty | ||
|
||
__all__ = ["base", "FixedUncertainty", "RandomVariableUncertainty", "VariableUncertainty"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
""" | ||
Active Learning 18 | ||
@author: Albert França Josuá Costa | ||
@email: [email protected] | ||
""" | ||
|
||
|
||
from .base import ActiveLearningBase | ||
|
||
|
||
|
||
class FixedUncertainty(ActiveLearningBase): | ||
|
||
"""Strategy of Active Learning to select instances more significative based on uncertainty. | ||
The fixed uncertainty sampler selects samples for labeling based on the uncertainty of the prediction. | ||
The higher the uncertainty, the more likely the sample will be selected for labeling. The uncertainty | ||
measure is compared with a fixed uncertainty limit. | ||
References | ||
---------- | ||
[^1]: I. Zliobaite, A. Bifet, B.Pfahringer, G. Holmes. “Active Learning with Drifting Streaming Data”, IEEE Transactions on Neural Netowrks and Learning Systems, Vol.25 (1), pp.27-39, 2014. | ||
""" | ||
|
||
def __init__(self, theta: float = 0.95, seed=None): | ||
super().__init__() | ||
self.theta = theta | ||
|
||
|
||
def describe(self): | ||
print('Strategy of Active Learning to select instances more significative based on uncertainty.'+ | ||
'The fixed uncertainty sampler selects samples for labeling based on the uncertainty of the prediction.'+ | ||
'The higher the uncertainty, the more likely the sample will be selected for labeling. The uncertainty'+ | ||
'measure is compared with a fixed uncertainty limit.'+ | ||
'References [^1]: I. Zliobaite, A. Bifet, B.Pfahringer, G. Holmes. “Active Learning with Drifting Streaming Data”, IEEE Transactions on Neural Netowrks and Learning Systems, Vol.25 (1), pp.27-39, 2014.') | ||
|
||
def isSignificative(self, x, y_pred) -> bool: | ||
"""Ask for the label of a current instance. | ||
Based on the uncertainty of the base classifier, it checks whether the current instance should be labeled. | ||
Parameters | ||
---------- | ||
x | ||
Instance | ||
y_pred | ||
Arrays of predicted labels | ||
Returns | ||
------- | ||
selected | ||
A boolean indicating whether a label is needed. | ||
True for selected instance. | ||
False for not selecte instance. | ||
""" | ||
maximum_posteriori = max(y_pred.values()) | ||
selected = False | ||
if maximum_posteriori < self.theta: | ||
selected = True | ||
return selected |