peal.teachers.human2model_teacher.Human2ModelTeacher

class peal.teachers.human2model_teacher.Human2ModelTeacher[source]

Bases: TeacherInterface

Teacher 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 static directory in the current working directory, starts the Flask server on 0.0.0.0 in 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

get_feedback

Show every collage to the human and wait for one answer each.

__init__(port)[source]

Create the static folder, pick a free port and start the server.

Raises:

ImportError – If the optional flask dependency 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 (list of str) – Collage images; each is copied to static/<basename>.

  • y_target_end_confidence_list (list of float) – 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 with y_source_list to 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 shared DataStore.

Return type:

list of str