Table of Contents

Programming Assignment

Select one of the assignments below. Assignments marked with can be extended as a continution eg. as master thsis, or other projects. Projects marked with can be (with some additional work and depending on the results) published as scientific papers.

Select project: Put your names next to the project

1. Comparing Human and AI Attention in Visual Anomaly Detection

Difficulty: Intermediate

Project type: Experimental study, computer vision, eye tracking

Technologies: Python, Tobii-PyTracker, PyTorch, Anomalib, PatchCore, OpenCV, NumPy, SciPy

Project description

The goal of this project is to prepare a pilot study comparing the visual attention of human operators with the anomaly regions identified by an artificial intelligence model.

The study will use the CoinDefect6K dataset, which contains images of coins acquired in an industrial visual-inspection setting. A selected visual anomaly-detection method, preferably PatchCore from the Anomalib library, should be used to generate pixel-level anomaly maps for selected images. The same images will then be presented to human participants using Tobii-PyTracker, and their eye-gaze data will be collected.

The project should investigate whether human participants and the anomaly-detection model focus on similar image regions when evaluating whether a coin contains a defect.

Main tasks

Suggested comparison metrics

Human–AI similarity should also be compared with human–human similarity. This will provide a reference for interpreting whether the observed human–AI agreement is high or low.

Research questions

Expected deliverables

2. Comparing Human and AI Attention in Image Classification

Difficulty: Intermediate

Project type: Human-centered AI, image classification, explainable AI, eye tracking

Technologies: Python, Tobii-PyTracker, PyTorch, TorchVision, Captum, ResNet-50, Grad-CAM

Project description

The goal of this project is to compare human visual attention with image regions used by a pretrained image classifier. Unlike the anomaly-detection project, the model must assign an image to one of several semantic classes rather than identify a local defect.

The recommended setup is a pretrained ResNet-50 classifier with ImageNet-1K weights available through TorchVision. The model is already trained and can be used without additional model training. The project should therefore focus on designing and conducting the human study rather than developing a new classifier.

A carefully selected subset of approximately 30–50 images should be used. The subset should contain both correctly and incorrectly classified examples, images with one dominant object, images with multiple objects, and visually ambiguous examples.

Main tasks

Suggested study conditions

A within-subject experiment may include two conditions:

  1. Unaided condition: the participant sees only the image.
  2. AI-assisted condition: the participant sees the image, the model prediction, and optionally the model-attention map.

If both conditions are used, the order should be counterbalanced and the same image should not be shown twice to the same participant unless an appropriate washout or image-pair design is used.

Research questions

Suggested analysis

Expected deliverables

3. Ablation Study of Counterfactuals by Design

Difficulty: Intermediate

Project type: Time-series counterfactual explanations, experimental evaluation

Technologies: Python, PyTorch or TensorFlow depending on the implementation, NumPy, Pandas, SciPy

Project description

The goal of this project is to investigate the role of individual components of the objective function used in Counterfactuals by Design.

The first version of the paper and the available materials can be found at:

https://zenodo.org/records/22794856

The implementation of the second version of the method will be provided on request.

The main research task is to conduct controlled ablation experiments in which selected components of the objective function are removed or assigned different weights. The objective is to determine how each component affects validity, proximity, sparsity, plausibility, signal reconstruction, and the interpretability of generated counterfactuals.

Main tasks

Minimum ablation design

The exact names of the losses should follow the supplied implementation. The experiment should include:

For each loss component, test at least:

A complete Cartesian product is not required. Begin with one-factor-at-a-time ablations and select only the most informative interactions for additional experiments.

Evaluation criteria

The analysis should also include visual examples. For each important configuration, present the factual signal, reconstructed normal component, residual component, modified residual, and final counterfactual.

Research questions

Expected deliverables

4. Robustness of DANCE to Errors in the Feature-Relationship Graph

Difficulty: Intermediate

Project type: Counterfactual explanations, robustness testing, structured perturbation experiments

Technologies: Python, ACFX, DANCE, NumPy, Pandas, DirectLiNGAM or NOTEARS, scikit-learn, SciPy

Project description

DANCE uses a feature-relationship graph to guide counterfactual generation. In practice, such a graph may be incomplete or inaccurate. Some actual relationships may be missing, spurious relationships may be present, and estimated edge weights may differ from the true dependencies between features.

The goal of this project is to evaluate the robustness of DANCE to controlled errors in the feature-relationship graph. The experiments should use the ACFX implementation of DANCE and several tabular classification datasets containing continuous, categorical, or mixed attributes.

A complete reference Google Colab notebook will be provided. It demonstrates how to:

The reference notebook also contains the implementation of the evaluation metrics. Students should reuse and, when necessary, extend this implementation rather than reimplementing the complete evaluation framework from scratch.

The main contribution of the project should be the systematic corruption of feature-relationship graphs and the experimental analysis of how different graph errors affect the quality of counterfactual explanations.

The study should determine whether counterfactual quality decreases gradually as the graph becomes less accurate, or whether specific types and levels of graph corruption cause abrupt failures.

Starting materials

The following materials will be provided:

The student is expected to understand, adapt, and extend the provided code. The project is not limited to rerunning the reference notebook.

Main tasks

Dataset selection

The selected datasets should provide a diverse evaluation environment. The collection should preferably contain:

Datasets may be obtained from sources such as:

The student should document:

The exact selection of datasets should be agreed upon with the supervisor before running the full experiment.

Baseline experiment

For each dataset, the student should first establish a clean-graph baseline.

The baseline should include:

The clean-graph baseline must be completed before introducing graph corruption.

Whenever possible, factual instances should initially be classified correctly by the classifier. The same factual instances must subsequently be used in every graph-corruption condition.

Required graph-corruption operators

The graph representation and orientation must remain consistent with the convention used by ACFX and the graph-learning method. For example, when using a DirectLiNGAM adjacency matrix, the student must verify which matrix dimension represents a parent and which represents a child before modifying the graph.

Edge removal

Randomly remove a selected proportion of existing edges.

Suggested corruption levels:

In addition to random removal, implement at least one targeted variant:

The number of removed edges and their original weights must be recorded.

Edge addition

Add edges that do not exist in the baseline graph. Self-loops must not be introduced.

Suggested corruption levels, defined relative to the original number of edges:

Implement at least two variants:

The weight of a newly added edge should be sampled using a documented strategy. For example, its absolute value may be sampled from the distribution of nonzero weights in the original graph.

Edge-weight noise

Add noise to every nonzero edge weight:

w_corrupted = w + epsilon

where:

epsilon ~ Normal(0, sigma × s_w)

and s_w is a scale determined from the nonzero weights in the baseline graph.

Suggested noise levels:

The definition of s_w must be documented. It may, for example, be the standard deviation or mean absolute value of the nonzero graph weights.

The student should also report how often the added noise changes the sign of an edge.

Edge-sign reversal

Reverse the sign of a selected proportion of existing nonzero edges.

Suggested corruption levels:

Random and targeted sign reversal may be compared. A targeted strategy could reverse the signs of the strongest edges first.

Combined corruption

Apply several corruption types simultaneously, for example:

The combined condition should represent a realistic estimated graph containing several types of error.

At least three combined corruption levels should be prepared:

The exact parameters of these levels must be documented and applied consistently across repeated runs.

Graph validity and acyclicity

Some corruption operators may introduce cycles or invalidate the original feature ordering.

The implementation must explicitly check:

If DANCE requires a directed acyclic graph, the student should select and document one of the following strategies:

The chosen strategy must remain consistent within a given experiment.

Required experiment controls

If a graph corruption makes DANCE unable to generate a counterfactual, this must be recorded as an experimental result rather than removed from the analysis.

Required metrics

The reference notebook contains implementations of the required metrics and demonstrates how to calculate them for counterfactuals generated by ACFX: Notebook

The project should report at least:

The provided implementation includes:

Students should preserve the provided metric definitions to ensure that results are comparable across datasets and graph-corruption conditions.

A metric may be modified or extended only when:

Use of the provided metrics module

The reference notebook creates and imports a reusable module named:

counterfactual_metrics.py

The module provides the following functions:

Students are not required to reimplement these functions from scratch.

However, they should:

The main evaluation function returns a dictionary containing:

This dictionary should be extended with experimental metadata, including:

Interpretation of the metrics

The term causality_loss should be interpreted carefully. If the graph was learned from observational data, the metric measures consistency with the supplied graph. It does not by itself prove that a counterfactual is causally valid.

Research questions

Suggested experimental procedure

For each dataset:

  1. Prepare a fixed train-test split.
  2. Train the classifier.
  3. Learn or define the baseline graph.
  4. Select a fixed collection of factual instances.
  5. Generate counterfactuals using the baseline graph.
  6. Calculate and store the baseline metrics.
  7. Generate corrupted graphs using each required corruption operator.
  8. Run DANCE using every corrupted graph.
  9. Repeat stochastic corruption using at least 5 random seeds.
  10. Calculate all metrics using the provided metrics module.
  11. Store successful and unsuccessful runs.
  12. Aggregate results by dataset, corruption operator, and corruption intensity.
  13. Compare all conditions with the clean-graph baseline.

As a practical minimum, the student should evaluate approximately 50 factual instances per dataset. If runtime permits, 100 or more instances per dataset are recommended.

Suggested analysis

For each metric, report:

Use degradation curves in which:

Consider reporting the area under the degradation curve as a summary of robustness. Because metrics have different directions, the interpretation should be standardized:

The analysis should distinguish between:

Expected deliverables

Minimum completion criteria

To complete the project successfully, the student must:

Optional extensions

5. Comparison of Counterfactual Generators for ECG Classification

Difficulty: Advanced

Project type: Time-series explainability, ECG classification, counterfactual explanations

Technologies: Python, PyTorch or TensorFlow, PTB-XL, NumPy, SciPy, wfdb

Project description

The goal of this project is to compare at least three counterfactual-generation methods for ECG classification.

A common ECG classifier and the same factual test signals must be used for all methods. The evaluation should determine whether the generated signals are valid counterfactuals, whether they remain close to the original ECG, and whether their modifications are plausible and interpretable rather than merely adversarial.

The recommended dataset is PTB-XL. The initial comparison may focus on a binary task, such as normal versus abnormal ECG, or on selected diagnostic superclasses. The exact classification task should be fixed before the counterfactual methods are compared.

Required types of counterfactual generator

The comparison should contain at least three substantially different approaches:

  1. Direct optimization method: optimize the ECG samples or a constrained perturbation to change the classifier decision.
  2. Generative or latent-space method: search for a counterfactual in the latent space of an autoencoder, variational autoencoder, or another generative model.
  3. Structure-aware method: use Counterfactuals by Design, a residual-editing method, or another approach explicitly designed to preserve signal structure.

An optional fourth baseline may use a nearest unlike neighbor from the test or reference set.

Existing ECG-oriented counterfactual code, such as VCCE, may be investigated, but all selected methods must ultimately be evaluated using a consistent classifier, task, and metric implementation.

Main tasks

Minimum evaluation metrics

If feasible, include general signal-quality indicators or an anomaly detector trained on real ECG signals. Domain-specific physiological constraints may be used as an additional analysis, but the main comparison should not depend solely on manually encoded ECG knowledge.

Level 1: Binary classification

Begin with a normal-versus-abnormal task. This simplifies target-class definition and facilitates visual comparison of counterfactuals.

Level 2: Diagnostic superclass classification

If the binary experiment is successful, extend the evaluation to selected PTB-XL diagnostic superclasses, for example:

Level 3: Cross-model validation

Evaluate generated counterfactuals using an independently trained classifier. This helps detect counterfactuals that exploit only the original classifier’s decision boundary.

Research questions

Required visual analysis

For representative examples, display:

The report should include examples of:

Expected deliverables

Important considerations

General Requirements for All Projects