peal.teachers.human2model_teacher.Human2ModelTeacher¶
- class peal.teachers.human2model_teacher.Human2ModelTeacher[source]¶
Bases:
TeacherInterfaceTeacher whose feedback comes from a human through a local web form.
- Parameters:
port (
int) – Preferred port for the Flask app; incremented until a free port is found.
Notes
The constructor wipes and recreates a
staticdirectory in the current working directory, starts the Flask server on0.0.0.0in a daemon-less background thread and never stops it. Collages whose student prediction is wrong or whose target confidence stays below 0.5 are skipped and answered automatically instead of being shown.Methods
Show every collage to the human and wait for one answer each.
- __init__(port)[source]¶
Create the
staticfolder, pick a free port and start the server.- Raises:
ImportError – If the optional
flaskdependency is not installed.
- get_feedback(collage_path_list, y_target_end_confidence_list, y_source_list, y_list, **kwargs)[source]¶
Show every collage to the human and wait for one answer each.
- Parameters:
collage_path_list (
listofstr) – Collage images; each is copied tostatic/<basename>.y_target_end_confidence_list (
listoffloat) – Student confidence in the target class after the counterfactual edit.y_source_list (
list) – Student predictions on the original samples.y_list (
list) – Ground-truth labels; compared withy_source_listto mark samples the student got wrong.**kwargs – Ignored; present for interface compatibility with other teachers.
- Returns:
One entry per collage:
"true","false","ood","student incorrect!"or"student not swapped!". Polls once a second (up to 100000 times) until the list is complete, then resets the sharedDataStore.- Return type: