courses:xai:pr_2026

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
courses:xai:pr_2026 [2026/11/29 12:10] – admincourses:xai:pr_2026 [2026/11/30 08:20] (current) – [Project description] admin
Line 4: Line 4:
 Projects marked with {{:courses:xai:contract.png?25|}} can be (with some additional work and depending on the results) published as scientific papers. Projects marked with {{:courses:xai:contract.png?25|}} can be (with some additional work and depending on the results) published as scientific papers.
  
 +Select project: [[https://pegaz.uj.edu.pl/mod/url/view.php?id=264256|Put your names next to the project]]
  
 ===== 1. Comparing Human and AI Attention in Visual Anomaly Detection ===== ===== 1. Comparing Human and AI Attention in Visual Anomaly Detection =====
Line 17: Line 18:
 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 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 study will use the [[https://zenodo.org/records/18773634|CoinDefect6K]] dataset, which contains images of coins acquired in an industrial visual-inspection setting. A selected visual anomaly-detection method, preferably PatchCore from the [[https://github.com/sbobek/coindefect6k|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 [[https://tobii-pytracker.readthedocs.io/en/latest/index.html|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. 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.
Line 33: Line 34:
   * Prepare a basic visual-inspection experiment using Tobii-PyTracker.   * Prepare a basic visual-inspection experiment using Tobii-PyTracker.
   * Present each image to participants and ask them to decide whether it contains a defect.   * Present each image to participants and ask them to decide whether it contains a defect.
-  * Optionally ask participants to indicate the suspected defect location using the mouse.+  * Ask participants to indicate the suspected defect location using verbal description (voice is recorded with tobii-pytracker and later is transcibed into description).
   * Record:   * Record:
     * gaze coordinates,     * gaze coordinates,
Line 39: Line 40:
     * inspection time,     * inspection time,
     * participant decision,     * participant decision,
-    * decision confidence, +    * voice 
-    * manually indicated defect location, if collected. +  * Conduct a pilot experiment. 
-  * Conduct a pilot experiment with approximately 5–10 participants. Students familiar with visual inspection may be treated as novice operators.+
   * Remove invalid gaze samples and transform the gaze coordinates into the coordinate system of the displayed image.   * Remove invalid gaze samples and transform the gaze coordinates into the coordinate system of the displayed image.
   * Generate individual and aggregated human-attention heatmaps.   * Generate individual and aggregated human-attention heatmaps.
Line 83: Line 83:
   * A short technical report describing the experiment, results, limitations, and recommendations for a larger study.   * A short technical report describing the experiment, results, limitations, and recommendations for a larger study.
  
-==== Important considerations ==== 
- 
-  * The displayed image must not be resized differently for AI-map generation and gaze analysis. 
-  * Screen coordinates must be transformed carefully into image coordinates. 
-  * The order of images should be randomized. 
-  * A short calibration and familiarization stage should be included. 
-  * Human participants should not be shown the AI anomaly maps before making their decisions. 
-  * As gaze and participant decisions are collected, the study must follow the applicable institutional requirements for research involving human participants. 
  
  
 ===== 2. Comparing Human and AI Attention in Image Classification ===== ===== 2. Comparing Human and AI Attention in Image Classification =====
  
-**Difficulty:** Advanced+**Difficulty:** Intermediate
  
 **Project type:** Human-centered AI, image classification, explainable AI, eye tracking **Project type:** Human-centered AI, image classification, explainable AI, eye tracking
Line 119: Line 111:
     * top-5 predictions,     * top-5 predictions,
     * class probabilities.     * class probabilities.
-  * Generate class-specific model-attention maps using Grad-CAM.+  * Generate class-specific model-attention maps using Grad-CAM (or SHAP - select appropriate).
   * Optionally compare Grad-CAM with one additional attribution method, such as Integrated Gradients or Occlusion.   * Optionally compare Grad-CAM with one additional attribution method, such as Integrated Gradients or Occlusion.
   * Implement an eye-tracking experiment using Tobii-PyTracker.   * Implement an eye-tracking experiment using Tobii-PyTracker.
Line 127: Line 119:
     * participant classification,     * participant classification,
     * response time,     * response time,
-    * confidence, +    * participant voice
-    * whether the participant changed their initial decision.+
   * Generate human-attention heatmaps.   * Generate human-attention heatmaps.
   * Compare human gaze with the attribution map generated for:   * Compare human gaze with the attribution map generated for:
Line 177: Line 168:
   * A technical report documenting the experimental procedure and results.   * A technical report documenting the experimental procedure and results.
  
-==== Important considerations ==== 
  
-  * Grad-CAM is a post-hoc approximation and should not be described as a direct measurement of where the model “looked.” 
-  * The attribution must be generated for a clearly specified class. 
-  * The displayed image should correspond exactly to the image crop received by the classifier. 
-  * ImageNet labels may be overly specific. A mapping to a smaller set of human-readable categories may be required. 
-  * The selected stimuli should be tested before the final study to ensure that the required classes are understandable to participants. 
  
  
 ===== 3. Ablation Study of Counterfactuals by Design ===== ===== 3. Ablation Study of Counterfactuals by Design =====
  
-**Difficulty:** Advanced+**Difficulty:** Intermediate
  
 **Project type:** Time-series counterfactual explanations, experimental evaluation **Project type:** Time-series counterfactual explanations, experimental evaluation
Line 198: Line 183:
 The goal of this project is to investigate the role of individual components of the objective function used in Counterfactuals by Design. The goal of this project is to investigate the role of individual components of the objective function used in Counterfactuals by Design.
  
-The student should first reproduce the original version of the method described in the paper “Counterfactuals by Design: Residual Decomposition and Back-to-Normality Editing for Time Series.” The first version of the paper and the available materials can be found at:+The first version of the paper and the available materials can be found at:
  
 https://zenodo.org/records/22794856 https://zenodo.org/records/22794856
Line 208: Line 193:
 ==== Main tasks ==== ==== Main tasks ====
  
-  * Run the available implementation of the first Counterfactuals by Design method. 
-  * Reproduce at least one experiment reported in the original work. 
   * Run the second version of the implementation provided by the supervisor.   * Run the second version of the implementation provided by the supervisor.
   * Identify all independently weighted components of the training and counterfactual-generation objectives.   * Identify all independently weighted components of the training and counterfactual-generation objectives.
Line 227: Line 210:
  
   * the complete objective function,   * the complete objective function,
-  * removal of each reconstruction-related component, +  * removal of each term from cost fuciton
-  * removal of each classification or validity component, +
-  * removal of each decomposition or separation component, +
-  * removal of regularization terms, +
-  * removal of constraints controlling the counterfactual residual, +
-  * removal of terms responsible for preserving the normal or morphology component, +
-  * selected weight sweeps for the most influential components.+
  
 For each loss component, test at least: For each loss component, test at least:
Line 282: Line 259:
   * A ranked summary of the practical importance of the loss components.   * A ranked summary of the practical importance of the loss components.
   * A report discussing which components are essential, beneficial, redundant, or potentially harmful.   * A report discussing which components are essential, beneficial, redundant, or potentially harmful.
- 
-==== Important considerations ==== 
- 
-  * An ablation must change only the examined component. 
-  * Hyperparameters unrelated to the ablated component must remain fixed. 
-  * Failure to generate a counterfactual is a valid result and must be recorded. 
-  * The analysis should not rely only on validity because removing constraints may improve validity while producing unrealistic counterfactuals. 
-  * Conclusions should be based on repeated experiments rather than individual examples. 
  
  
 ===== 4. Robustness of DANCE to Errors in the Feature-Relationship Graph ===== ===== 4. Robustness of DANCE to Errors in the Feature-Relationship Graph =====
  
-**Difficulty:** Advanced+**Difficulty:** Intermediate
  
 **Project type:** Counterfactual explanations, robustness testing, structured perturbation experiments **Project type:** Counterfactual explanations, robustness testing, structured perturbation experiments
Line 302: Line 271:
 ==== Project description ==== ==== Project description ====
  
-DANCE uses a feature-relationship graph to guide counterfactual generation. In practice, the supplied or learned graph may contain errors. Some relationships may be missing, spurious relationships may be present, and estimated edge weights may be inaccurate.+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 how robust DANCE is to controlled corruption of the feature-relationship graph. The experiments should use the ACFX implementation of DANCE and several tabular classification datasets containing continuous and categorical attributes.+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 [[https://acfx.readthedocs.io/en/latest/|ACFX]] implementation of [[https://arxiv.org/abs/2511.20236|DANCE]] and several tabular classification datasets containing continuous, categorical, or mixed attributes.
  
-The study should evaluate whether graph errors gradually reduce counterfactual quality or whether specific types of corruption cause abrupt failures.+A complete reference [[https://colab.research.google.com/drive/17Yf9FS_H3Ww9yW0fu9YtPxQocb9enFsf?usp=sharing|Google Colab]] notebook will be provided. It demonstrates how to: 
 + 
 +  * install and configure ACFX, 
 +  * prepare a tabular classification dataset, 
 +  * train a classifier, 
 +  * learn a feature-relationship graph using DirectLiNGAM, 
 +  * generate counterfactuals with DANCE, 
 +  * calculate the required counterfactual-quality metrics, 
 +  * handle unsuccessful generation attempts, 
 +  * save the evaluation results. 
 + 
 +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: 
 + 
 +  * a Google Colab notebook demonstrating a complete ACFX workflow, 
 +  * an example tabular classification dataset, 
 +  * code for training a basic classifier, 
 +  * code for learning a graph with DirectLiNGAM, 
 +  * code for generating counterfactuals using DANCE, 
 +  * implementations of the required evaluation metrics, 
 +  * an example showing how to store the results in a structured record. 
 + 
 +The student is expected to understand, adapt, and extend the provided code. The project is not limited to rerunning the reference notebook.
  
 ==== Main tasks ==== ==== Main tasks ====
  
-  * Configure and run DANCE using ACFX.+  * Run and understand the provided ACFX reference notebook. 
 +  * Verify that the reference experiment can be reproduced. 
 +  * Refactor the notebook where necessary to support repeated experiments.
   * Select approximately 5–10 tabular classification datasets.   * Select approximately 5–10 tabular classification datasets.
-  * Use datasets with different:+  * Include datasets with different:
     * numbers of features,     * numbers of features,
     * sample sizes,     * sample sizes,
Line 318: Line 318:
     * graph densities,     * graph densities,
     * proportions of categorical attributes.     * proportions of categorical attributes.
-  * Train or load one classifier per dataset. +  * Train or load one classifier for each dataset. 
-  * Learn or define a baseline feature-relationship graph. +  * Learn or define a baseline feature-relationship graph for each dataset. 
-  * Generate counterfactuals using the unmodified graph. +  * Generate counterfactuals using the original, unmodified graph. 
-  * Implement controlled graph-corruption operators. +  * Implement reusable graph-corruption operators. 
-  * Run DANCE with the corrupted graphs. +  * Generate multiple corrupted versions of each baseline graph. 
-  * Evaluate counterfactual quality using the same factual samples, target classes, model, and random seeds. +  * Run DANCE using the original and corrupted graphs. 
-  * Repeat each stochastic condition using at least 5 random graph-corruption seeds. +  * Evaluate counterfactual quality using the metrics provided in the reference notebook. 
-  * Save the corrupted adjacency matrices and experimental metadata so that every result can be reproduced.+  * Ensure that the same classifier, factual instances, desired classes, and experimental settings are used when comparing graph conditions. 
 +  * Repeat every stochastic graph-corruption condition using at least 5 random seeds. 
 +  * Save all corrupted adjacency matrices, random seeds, configuration parameters, and result records. 
 +  * Analyze which graph errors are most harmful to DANCE. 
 + 
 +==== Dataset selection ==== 
 + 
 +The selected datasets should provide a diverse evaluation environment. The collection should preferably contain: 
 + 
 +  * binary and multiclass classification problems, 
 +  * datasets with continuous attributes, 
 +  * datasets with categorical attributes, 
 +  * datasets with mixed attribute types, 
 +  * low-dimensional and higher-dimensional datasets, 
 +  * datasets with balanced and imbalanced classes. 
 + 
 +Datasets may be obtained from sources such as: 
 + 
 +  * OpenML, 
 +  * the UCI Machine Learning Repository, 
 +  * scikit-learn, 
 +  * established counterfactual-explanation benchmarks. 
 + 
 +The student should document: 
 + 
 +  * the dataset source, 
 +  * the prediction task, 
 +  * the number of instances, 
 +  * the number and types of features, 
 +  * the class distribution, 
 +  * preprocessing operations, 
 +  * train-test splitting, 
 +  * feature scaling, 
 +  * the method used to obtain the baseline graph. 
 + 
 +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: 
 + 
 +  * a fixed train-test split, 
 +  * a trained classifier, 
 +  * an unmodified feature-relationship graph, 
 +  * a fixed collection of factual instances, 
 +  * a defined desired class for every factual instance, 
 +  * counterfactuals generated with DANCE, 
 +  * all required evaluation metrics, 
 +  * counterfactual-generation time, 
 +  * successful and unsuccessful generation attempts. 
 + 
 +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 ==== ==== 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 === === Edge removal ===
  
-Randomly remove a selected percentage of existing edges.+Randomly remove a selected proportion of existing edges.
  
-Suggested levels:+Suggested corruption levels:
  
   * 0%,   * 0%,
Line 342: Line 399:
   * 60%.   * 60%.
  
-Include an additional targeted variant in which the strongest edges are removed first.+In addition to random removal, implement at least one targeted variant: 
 + 
 +  * remove the strongest edges first, or 
 +  * remove edges associated with the most influential features. 
 + 
 +The number of removed edges and their original weights must be recorded.
  
 === Edge addition === === Edge addition ===
  
-Add nonexistent edges while preventing self-loops.+Add edges that do not exist in the baseline graph. Self-loops must not be introduced.
  
-Suggested levels should be defined relative to the original number of edges:+Suggested corruption levels, defined relative to the original number of edges:
  
   * 5%,   * 5%,
Line 356: Line 418:
   * 60%.   * 60%.
  
-Test at least two variants:+Implement at least two variants:
  
   * random edge addition,   * random edge addition,
   * addition of edges conflicting with the original causal or topological order.   * addition of edges conflicting with the original causal or topological order.
 +
 +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 === === Edge-weight noise ===
  
-For every nonzero edge weight, apply additive noise:+Add noise to every nonzero edge weight:
  
 ''w_corrupted = w + epsilon'' ''w_corrupted = w + epsilon''
Line 371: Line 435:
 ''epsilon ~ Normal(0, sigma × s_w)'' ''epsilon ~ Normal(0, sigma × s_w)''
  
-and ''s_w'' is a scale derived from the nonzero weights in the original graph.+and ''s_w'' is a scale determined from the nonzero weights in the baseline graph.
  
 Suggested noise levels: Suggested noise levels:
  
-  * sigma = 0.05, +  * ''sigma = 0.05'', 
-  * sigma = 0.10, +  * ''sigma = 0.10'', 
-  * sigma = 0.25, +  * ''sigma = 0.25'', 
-  * sigma = 0.50, +  * ''sigma = 0.50'', 
-  * sigma = 1.00.+  * ''sigma = 1.00''. 
 + 
 +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 === === Edge-sign reversal ===
  
-Reverse the sign of a selected proportion of edge weights:+Reverse the sign of a selected proportion of existing nonzero edges. 
 + 
 +Suggested corruption levels:
  
   * 5%,   * 5%,
Line 389: Line 459:
   * 20%,   * 20%,
   * 40%.   * 40%.
 +
 +Random and targeted sign reversal may be compared. A targeted strategy could reverse the signs of the strongest edges first.
  
 === Combined corruption === === Combined corruption ===
  
-Apply edge removal, addition, and weight noise simultaneously. The combined condition should represent a realistic estimated graph containing several types of error.+Apply several corruption types simultaneously, for example: 
 + 
 +  * edge removal, 
 +  * edge addition, 
 +  * edge-weight noise. 
 + 
 +The combined condition should represent a realistic estimated graph containing several types of error. 
 + 
 +At least three combined corruption levels should be prepared: 
 + 
 +  * low corruption, 
 +  * medium corruption, 
 +  * high corruption. 
 + 
 +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: 
 + 
 +  * whether the corrupted graph contains self-loops, 
 +  * whether the graph remains acyclic, 
 +  * whether the original topological order is still valid, 
 +  * whether all matrix dimensions remain consistent, 
 +  * whether the corrupted graph contains non-finite weights. 
 + 
 +If DANCE requires a directed acyclic graph, the student should select and document one of the following strategies: 
 + 
 +  * reject graph modifications that introduce cycles, 
 +  * remove an edge responsible for each introduced cycle, 
 +  * restrict edge addition to edges consistent with a topological order, 
 +  * run a separate experiment comparing acyclic and cycle-producing corruption. 
 + 
 +The chosen strategy must remain consistent within a given experiment.
  
 ==== Required experiment controls ==== ==== Required experiment controls ====
  
   * The classifier must remain fixed across graph-corruption conditions.   * The classifier must remain fixed across graph-corruption conditions.
-  * The factual instances and desired classes must remain fixed. +  * The train-test split must remain fixed. 
-  * The same feature bounds and categorical-feature definitions must be used. +  * The factual instances must remain fixed. 
-  * Graph perturbations must not modify the dataset itself.+  * The desired class for each factual instance must remain fixed. 
 +  * The same feature bounds must be used. 
 +  * The same categorical-feature definitions must be used. 
 +  * The same counterfactual-generation hyperparameters must be used. 
 +  * Graph perturbations must not modify the dataset or classifier.
   * Results must include both successful and unsuccessful generation attempts.   * Results must include both successful and unsuccessful generation attempts.
-  * If DANCE requires an acyclic graph, the implementation must either preserve acyclicity or explicitly report when corruption violates this requirement. +  * Random corruption must be reproducible using stored random seeds. 
-  * Random corruption must be reproducible from a stored random seed.+  * The clean graph must be included as the 0% corruption condition. 
 +  * The same evaluation implementation must be used for all methods and conditions. 
 + 
 +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 ==== ==== Required metrics ====
  
-The project should implement and report at least:+The reference notebook contains implementations of the required metrics and demonstrates how to calculate them for counterfactuals generated by ACFX: [[https://colab.research.google.com/drive/17Yf9FS_H3Ww9yW0fu9YtPxQocb9enFsf?usp=sharing|Notebook]] 
 + 
 +The project should report at least:
  
   * number of generated counterfactuals,   * number of generated counterfactuals,
   * number of valid counterfactuals,   * number of valid counterfactuals,
   * fidelity or validity rate,   * fidelity or validity rate,
-  * mean target-class probability,+  * mean desired-class probability,
   * classification loss,   * classification loss,
   * proximity loss,   * proximity loss,
   * sparsity loss,   * sparsity loss,
-  * causality or graph-consistency loss,+  * graph-consistency or causality loss,
   * diversity,   * diversity,
   * Local Outlier Factor score,   * Local Outlier Factor score,
-  * counterfactual generation time,+  * counterfactual-generation time,
   * generation failure rate.   * generation failure rate.
  
-The accompanying reference notebook already uses classification loss, range-normalized proximity, sparsity, graph-based causal penalty, determinant-based diversity, and novelty-mode Local Outlier Factor. The implementation should preserve these definitions unless a change is clearly documented.+The provided implementation includes:
  
-==== Required Python module ====+  * classification loss based on the margin between the strongest alternative class and the desired class, 
 +  * range-normalized proximity for continuous attributes, 
 +  * change-based proximity for categorical attributes, 
 +  * sparsity measured as the proportion of modified features, 
 +  * graph-consistency penalty based on the supplied weighted relationship graph, 
 +  * determinant-based diversity, 
 +  * novelty-mode Local Outlier Factor.
  
-Prepare a standalone Python file named:+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: 
 + 
 +  * the change is clearly justified, 
 +  * the new definition is documented, 
 +  * the original metric is also retained for comparison. 
 + 
 +==== Use of the provided metrics module ==== 
 + 
 +The reference notebook creates and imports a reusable module named:
  
 ''counterfactual_metrics.py'' ''counterfactual_metrics.py''
  
-The file should provide reusable implementations of at least:+The module provides the following functions:
  
   * ''compute_yloss(...)''   * ''compute_yloss(...)''
Line 439: Line 571:
   * ''evaluate_counterfactuals(...)''   * ''evaluate_counterfactuals(...)''
  
-The implementations should be based on the provided reference notebook but must not depend on notebook-global variables.+Students are not required to reimplement these functions from scratch. 
 + 
 +However, they should: 
 + 
 +  * understand the meaning of every reported metric, 
 +  * verify that the input arrays have the expected shapes, 
 +  * correctly define continuous and categorical attributes, 
 +  * ensure that the desired-class probability column is selected correctly, 
 +  * preserve handling of empty counterfactual sets, 
 +  * preserve reporting of unsuccessful generation attempts, 
 +  * add tests if the module is extended, 
 +  * document every modification to the provided implementation.
  
-The main evaluation function should return a dictionary containing fields compatible with the following structure:+The main evaluation function returns a dictionary containing:
  
   * ''no_cfs''   * ''no_cfs''
Line 457: Line 600:
   * ''error''   * ''error''
  
-The module must:+This dictionary should be extended with experimental metadata, including:
  
-  * support binary and multiclass classifiers, +  * dataset name, 
-  * correctly identify the target-class probability column from ''model.classes_'', +  * factual-instance identifier, 
-  * support continuous and categorical attributes, +  * original class, 
-  * handle an empty counterfactual set without crashing, +  * desired class, 
-  * return ''NaN'' for metrics that cannot be computed, +  * corruption operator, 
-  * validate array dimensions, +  * corruption intensity, 
-  * avoid computing means over empty arrays, +  * graph-corruption seed, 
-  * include docstrings and type hints, +  * counterfactual-generation seed, 
-  * include a small collection of unit tests.+  * number of original graph edges, 
 +  * number of corrupted graph edges, 
 +  * graph density, 
 +  * acyclicity status, 
 +  * counterfactual-generation hyperparameters.
  
-==== Metrics output example ====+==== Interpretation of the metrics ====
  
-An evaluation record should follow the logic below: +  * ''no_cfs'' is the number of generated counterfactuals. 
- +  * ''no_valid_cfs'' is the number of counterfactuals classified as the desired class.
-  * ''no_valid_cfs'' is the number of counterfactuals predicted as the desired class.+
   * ''fidelity'' is the proportion of generated counterfactuals classified as the desired class.   * ''fidelity'' is the proportion of generated counterfactuals classified as the desired class.
   * ''probability'' is the mean probability assigned to the desired class.   * ''probability'' is the mean probability assigned to the desired class.
   * ''loss'' measures the margin between the strongest alternative class and the desired class.   * ''loss'' measures the margin between the strongest alternative class and the desired class.
-  * ''proximity_loss'' is the normalized distance from the factual instance. +  * ''proximity_loss'' measures the normalized distance between the factual instance and its counterfactuals. 
-  * ''sparsity_loss'' is the proportion of modified features.+  * ''sparsity_loss'' is the proportion of features modified in the counterfactual.
   * ''causality_loss'' measures inconsistency with the supplied feature-relationship graph.   * ''causality_loss'' measures inconsistency with the supplied feature-relationship graph.
   * ''diversity'' measures differences among counterfactuals generated for the same factual instance.   * ''diversity'' measures differences among counterfactuals generated for the same factual instance.
   * ''lof_factor'' measures how typical the counterfactuals are relative to the training data.   * ''lof_factor'' measures how typical the counterfactuals are relative to the training data.
 +  * ''execution_time'' records the time required to generate the counterfactuals.
 +  * ''status'' indicates whether evaluation was successful, no counterfactual was produced, or an error occurred.
 +  * ''error'' contains information about a generation or evaluation failure.
 +
 +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 ==== ==== Research questions ====
Line 487: Line 638:
   * How quickly does counterfactual quality deteriorate as graph corruption increases?   * How quickly does counterfactual quality deteriorate as graph corruption increases?
   * Is DANCE more sensitive to missing edges, additional edges, incorrect signs, or inaccurate weights?   * Is DANCE more sensitive to missing edges, additional edges, incorrect signs, or inaccurate weights?
-  * Does graph corruption affect validity and plausibility differently?+  * Does graph corruption affect validity, proximity, sparsity, and plausibility differently? 
 +  * Are strong graph relationships more important than weak relationships?
   * Are dense graphs more vulnerable to corruption than sparse graphs?   * Are dense graphs more vulnerable to corruption than sparse graphs?
 +  * Does sensitivity depend on the number of features?
 +  * Does sensitivity differ between continuous and categorical attributes?
   * Are some datasets more sensitive because their predictions depend on a small number of relationships?   * Are some datasets more sensitive because their predictions depend on a small number of relationships?
-  * Does DANCE remain competitive when the graph is only approximately correct?+  * Does DANCE remain useful when the feature-relationship graph is only approximately correct? 
 +  * Which corruption operators cause counterfactual-generation failures?
   * Can graph uncertainty be estimated from the variability of generated counterfactuals?   * Can graph uncertainty be estimated from the variability of generated counterfactuals?
 +  * Can counterfactual variability indicate that a graph should not be trusted?
 +
 +==== Suggested experimental procedure ====
 +
 +For each dataset:
 +
 +  - Prepare a fixed train-test split.
 +  - Train the classifier.
 +  - Learn or define the baseline graph.
 +  - Select a fixed collection of factual instances.
 +  - Generate counterfactuals using the baseline graph.
 +  - Calculate and store the baseline metrics.
 +  - Generate corrupted graphs using each required corruption operator.
 +  - Run DANCE using every corrupted graph.
 +  - Repeat stochastic corruption using at least 5 random seeds.
 +  - Calculate all metrics using the provided metrics module.
 +  - Store successful and unsuccessful runs.
 +  - Aggregate results by dataset, corruption operator, and corruption intensity.
 +  - 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 ==== ==== Suggested analysis ====
Line 497: Line 673:
 For each metric, report: For each metric, report:
  
-  * absolute metric value, +  * the absolute metric value, 
-  * difference relative to the clean-graph baseline, +  * the difference relative to the clean-graph baseline, 
-  * relative percentage degradation, +  * the relative percentage degradation, 
-  * mean and standard deviation across graph-corruption seeds.+  * the mean across graph-corruption seeds, 
 +  * the standard deviation across graph-corruption seeds, 
 +  * confidence intervals where appropriate, 
 +  * the number and rate of unsuccessful runs.
  
-Use degradation curves in which the x-axis represents corruption intensity and the y-axis represents counterfactual quality. Consider reporting the area under the degradation curve as a single robustness summary.+Use degradation curves in which: 
 + 
 +  * the x-axis represents graph-corruption intensity, 
 +  * the y-axis represents counterfactual quality, 
 +  * separate lines represent corruption operators, 
 +  * uncertainty bands represent variability across seeds or factual instances. 
 + 
 +Consider reporting the area under the degradation curve as a summary of robustness. Because metrics have different directions, the interpretation should be standardized: 
 + 
 +  * higher fidelity and target-class probability are better, 
 +  * lower classification, proximity, sparsity, and graph-consistency losses are generally better, 
 +  * higher LOF scores indicate more typical samples when using ''score_samples'', 
 +  * diversity should be interpreted jointly with validity and plausibility. 
 + 
 +The analysis should distinguish between: 
 + 
 +  * gradual quality degradation, 
 +  * sudden failure thresholds, 
 +  * dataset-specific sensitivity, 
 +  * corruption-specific sensitivity, 
 +  * variability caused by stochastic counterfactual generation, 
 +  * variability caused by graph corruption. 
 + 
 +==== Recommended result visualizations ==== 
 + 
 +  * Metric degradation curves. 
 +  * Counterfactual-generation failure-rate curves. 
 +  * Heatmaps comparing datasets and corruption operators. 
 +  * Box plots showing variability across corruption seeds. 
 +  * Graph visualizations before and after corruption. 
 +  * Scatter plots comparing graph distance with counterfactual-quality degradation. 
 +  * Pareto plots comparing validity, proximity, sparsity, and graph consistency. 
 +  * Representative factual-counterfactual pairs for low, medium, and high graph corruption.
  
 ==== Expected deliverables ==== ==== Expected deliverables ====
  
 +  * An extended version of the provided Google Colab notebook.
   * A reusable graph-corruption module.   * A reusable graph-corruption module.
-  * A standalone ''counterfactual_metrics.py'' file. +  * Implementations of all required graph-corruption operators. 
-  * Unit tests for the metric implementations.+  * Tests for graph-corruption functions. 
 +  * Any documented extensions to ''counterfactual_metrics.py''.
   * A reproducible DANCE experiment pipeline.   * A reproducible DANCE experiment pipeline.
-  * Clean and corrupted graph files. +  * Configuration files or dictionaries defining all experiments. 
-  * A CSV file containing per-sample and aggregated results. +  * Original and corrupted adjacency matrices. 
-  * Robustness curves for every corruption operator.+  * Stored random seeds and graph-corruption metadata. 
 +  * A CSV or Parquet file containing per-instance results. 
 +  * A CSV or Parquet file containing aggregated results. 
 +  * Robustness curves for every graph-corruption operator.
   * A comparison of dataset-level sensitivity.   * A comparison of dataset-level sensitivity.
-  * A report identifying the graph errors that are most harmful to DANCE.+  * Representative visualizations of clean and corrupted graphs. 
 +  * A report identifying which graph errors are most harmful to DANCE. 
 +  * Instructions for reproducing the experiments in Google Colab or a local Python environment. 
 + 
 +==== Minimum completion criteria ==== 
 + 
 +To complete the project successfully, the student must: 
 + 
 +  * reproduce the provided baseline notebook, 
 +  * evaluate at least 5 datasets, 
 +  * implement edge removal, edge addition, edge-weight noise, and edge-sign reversal, 
 +  * include at least one combined corruption condition, 
 +  * use at least 5 graph-corruption seeds per stochastic condition, 
 +  * include a clean-graph baseline, 
 +  * evaluate the same factual instances across graph conditions, 
 +  * report all required metrics, 
 +  * record unsuccessful generation attempts, 
 +  * provide reproducible result files, 
 +  * analyze the relationship between corruption intensity and counterfactual quality. 
 + 
 +==== Optional extensions ====
  
 +  * Compare DirectLiNGAM and NOTEARS graphs.
 +  * Compare learned graphs with expert-defined graphs.
 +  * Introduce uncertainty estimates for graph edges.
 +  * Weight graph penalties according to edge confidence.
 +  * Develop corruption operators that preserve a selected topological order.
 +  * Compare random and adversarial graph corruption.
 +  * Identify the smallest graph modification that substantially changes a counterfactual.
 +  * Analyze whether ensemble graphs improve DANCE robustness.
 +  * Compare DANCE with a counterfactual method that does not use a feature-relationship graph.
  
 ===== 5. Comparison of Counterfactual Generators for ECG Classification ===== ===== 5. Comparison of Counterfactual Generators for ECG Classification =====
Line 531: Line 776:
 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. 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.+The recommended dataset is [[https://physionet.org/content/ptb-xl/1.0.3/|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 ==== ==== Required types of counterfactual generator ====
  • courses/xai/pr_2026.1795954254.txt.gz
  • Last modified: 5 days ago
  • by admin