#!/bin/bash

echo "Generating Cluster Explanation Figures..."

########################
### CLASSIC DATASETS ###
########################

echo "  - Classic datasets evaluation..."

# Computation Time
python -m scripts.tools.evaluate_performance --data data/explanations/cluster/classic/individual_explanations.csv data/explanations/cluster/classic/cluster_explanations.csv --include-aggregated --output-dir figures/cluster/classic_datasets/ --min-cluster-size 10 --max-cluster-size 10

# Coverage, Importance Error, and Ranking Correlation
python -m scripts.tools.evaluate_explanations --individual-data data/explanations/cluster/classic/individual_explanations.csv --cluster-data data/explanations/cluster/classic/cluster_explanations.csv --include-aggregated --output-dir figures/cluster/classic_datasets/

###################
### SCALABILITY ###
###################

echo "  - Scalability analysis..."

# Number of Features

# Computation Time
python -m scripts.tools.evaluate_performance --data data/explanations/cluster/scalability/individual_explanations.csv data/explanations/cluster/scalability/cluster_explanations_by_num_features.csv --include-aggregated --output-dir figures/cluster/scalability/number_of_features/ --x-col-name "Number of Features" --min-cluster-size 10 --max-cluster-size 10 --title "Group explanations are faster to compute than aggregated explanations"

# Coverage, Importance Error, and Ranking Correlation
python -m scripts.tools.evaluate_explanations --individual-data data/explanations/cluster/scalability/individual_explanations.csv --cluster-data data/explanations/cluster/scalability/cluster_explanations_by_num_features.csv --include-aggregated --output-dir figures/cluster/scalability/number_of_features/ --x-col-name "Number of Features"

# Group Size

# Computation Time
python -m scripts.tools.evaluate_performance --data data/explanations/cluster/scalability/individual_explanations.csv data/explanations/cluster/scalability/cluster_explanations_by_cluster_size.csv --include-aggregated --output-dir figures/cluster/scalability/cluster_size/ --x-col-name "Group Size" --min-cluster-size 3 --max-cluster-size 20 --title "The computation time of group explanations is independent of group size"

# Coverage, Importance Error, and Ranking Correlation
python -m scripts.tools.evaluate_explanations --individual-data data/explanations/cluster/scalability/individual_explanations.csv --cluster-data data/explanations/cluster/scalability/cluster_explanations_by_cluster_size.csv --include-aggregated --output-dir figures/cluster/scalability/cluster_size/ --x-col-name "Group Size"


################
### EXAMPLES ###
################

echo "  - Example visualizations..."

# Individual Explanations
python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/individual_explanations.csv --dataset mnist --label 5 --sample-index 0 --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_0.pdf

python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/individual_explanations.csv --dataset mnist --label 5 --sample-index 1 --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_1.pdf

python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/individual_explanations.csv --dataset mnist --label 5 --sample-index 2 --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_2.pdf

# Cluster Explanation
python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/cluster_explanations.csv --dataset mnist --label 5 --cluster-index 0 --delta 0.3 --plot-explanation --output figures/cluster/examples/cluster_explanation_mnist_label_5_cluster_0_size_3_delta_0.3.pdf

# Ordering Explanations
python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/ordering_explanations.csv --dataset mnist --label 5 --sample-index 1 --ordering linear --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_1_ordering_linear.pdf

python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/ordering_explanations.csv --dataset mnist --label 5 --sample-index 1 --ordering random --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_1_ordering_random.pdf

python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/ordering_explanations.csv --dataset mnist --label 5 --sample-index 1 --ordering verix --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_1_ordering_verix.pdf

python -m scripts.tools.visualize_results --csv data/explanations/cluster/examples/ordering_explanations.csv --dataset mnist --label 5 --sample-index 1 --ordering sensitivity --plot-explanation --output figures/cluster/examples/individual_explanation_mnist_label_5_sample_1_ordering_sensitivity.pdf

echo "Cluster figures generation complete!"
