Skip to content

Commit

Permalink
adding ability to specify classes for Uskill calc
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentM-GEG committed Oct 29, 2024
1 parent c8a9fff commit f86c56b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions panoptes_aggregation/reducers/reducer_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def wrapper(argument, **kwargs):
kwargs_details['mode'] = kwargs['mode'].strip("\'")
if 'strategy' in kwargs:
kwargs_details['strategy'] = kwargs['strategy'].strip("\'")
if 'focus_classes' in kwargs:
kwargs_details['focus_classes'] = ast.literal_eval(kwargs['focus_classes'])

no_version = kwargs.pop('no_version', False)
if defaults_process is not None:
Expand Down
15 changes: 10 additions & 5 deletions panoptes_aggregation/reducers/user_skill_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ..feedback_strategies import FEEDBACK_STRATEGIES
from sklearn.metrics import confusion_matrix


# smallest possible value for difficulty so that
# subjects have a non-negligible effect on user skill
# in extreme cases
Expand All @@ -21,7 +20,7 @@

@reducer_wrapper(relevant_reduction=True)
def user_skill_reducer(extracts, relevant_reduction=[], mode='binary', null_class='NONE',
skill_threshold=0.7, count_threshold=10, strategy='mean'):
skill_threshold=0.7, count_threshold=10, strategy='mean', focus_classes=None):
'''
Parameters
----------
Expand Down Expand Up @@ -84,13 +83,19 @@ def user_skill_reducer(extracts, relevant_reduction=[], mode='binary', null_clas

# remove the null class from the skill array to calculate the mean skill
if mode == 'binary':
null_removed_classes = [classi for classi in classes if classi != 'False']
null_removed_counts = [ci for classi, ci in per_class_count.items() if classi != 'False']
mean_skill = np.sum([weighted_per_class_skill_dict[key] for key in null_removed_classes]) / (len(null_removed_classes) + 1.e-16)
null_class = 'False'
else:
null_class = null_class

# compute either on user-specified classes or perform mean skill calculation on all detected classes
if focus_classes is None:
null_removed_classes = [classi for classi in classes if classi != null_class]
null_removed_counts = [ci for classi, ci in per_class_count.items() if classi != null_class]
mean_skill = np.sum([weighted_per_class_skill_dict[key] for key in null_removed_classes]) / (len(null_removed_classes) + 1.e-16)
else:
null_removed_classes = [classi for classi in focus_classes if classi != null_class]
null_removed_counts = [ci for classi, ci in per_class_count.items() if classi in null_removed_classes]
mean_skill = np.sum([weighted_per_class_skill_dict[key] for key in null_removed_classes]) / (len(null_removed_classes) + 1.e-16)

# check the leveling up value
if strategy == 'mean':
Expand Down

0 comments on commit f86c56b

Please sign in to comment.