From 6831e847ffa69ff287dc8cfa61c6a0a272d638e8 Mon Sep 17 00:00:00 2001 From: Daniel Svitan Date: Mon, 23 Dec 2024 18:08:18 +0100 Subject: [PATCH] :zap: Adds automatic output saving --- analyze.py | 7 +++++-- analyze.sh | 25 +++++++++++++++++-------- distribution.py | 4 ++-- requirements.txt | 4 ++++ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/analyze.py b/analyze.py index 3b9117e..1f47507 100644 --- a/analyze.py +++ b/analyze.py @@ -3,6 +3,7 @@ import argparse import numpy as np import scipy.stats as stats +import scikit_posthocs as sp import matplotlib.pyplot as plt parser = argparse.ArgumentParser() @@ -38,8 +39,10 @@ def analyze(name: str, data: List[np.ndarray]): return F, p print("statistically significant") - tukey_results = stats.tukey_hsd(*filtered_data) - print(tukey_results) + #tukey_results = stats.tukey_hsd(*filtered_data) + #print(tukey_results) + ps = sp.posthoc_dunn(filtered_data, val_col='Values', group_col='Group', p_adjust='bonferroni') + print(ps) return F, p diff --git a/analyze.sh b/analyze.sh index 77206c3..cdef7ae 100755 --- a/analyze.sh +++ b/analyze.sh @@ -1,10 +1,19 @@ #!/usr/bin/bash -./venv/bin/python3 distribution.py --graph --save -./venv/bin/python3 analyze_sex.py --graph --save "Figure_13.png" -./venv/bin/python3 analyze_ses.py --graph --save "Figure_14.png" -./venv/bin/python3 analyze_occupation.py --graph --save "Figure_15.png" -./venv/bin/python3 analyze_living.py --graph --save "Figure_16.png" -./venv/bin/python3 analyze_commute.py --graph --save "Figure_17.png" -./venv/bin/python3 analyze_sleep.py --graph --save "Figure_18.png" -./venv/bin/python3 analyze_absence.py --graph --save "Figure_19.png" +find results ! -name 'train.txt' -type f -exec rm -f {} + + +./venv/bin/python3 distribution.py --graph --save | tee results/distribution.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_sex.py --graph --save "results/Figure_13.png" | tee results/sex.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_ses.py --graph --save "results/Figure_14.png" | tee results/ses.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_occupation.py --graph --save "results/Figure_15.png" | tee results/occupation.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_living.py --graph --save "results/Figure_16.png" | tee results/living.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_commute.py --graph --save "results/Figure_17.png" | tee results/commute.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_sleep.py --graph --save "results/Figure_18.png" | tee results/sleep.txt +echo -e "\n\n\n\n" +./venv/bin/python3 analyze_absence.py --graph --save "results/Figure_19.png" | tee results/absence.txt diff --git a/distribution.py b/distribution.py index aebded1..8bfc1c2 100644 --- a/distribution.py +++ b/distribution.py @@ -40,7 +40,7 @@ def plot_pie(data, labels, title, explode=None): plt.tight_layout() if save: - plt.savefig(f"Figure_{graph_index}.png") + plt.savefig(f"results/Figure_{graph_index}.png") graph_index += 1 else: plt.show() @@ -59,7 +59,7 @@ def plot_hist(data, title, xlabel, ylabel): plt.tight_layout() if save: - plt.savefig(f"Figure_{graph_index}.png") + plt.savefig(f"results/Figure_{graph_index}.png") graph_index += 1 else: plt.show() diff --git a/requirements.txt b/requirements.txt index cf5c7e5..e1052c0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,14 +25,18 @@ nvidia-nvjitlink-cu12==12.4.127 nvidia-nvtx-cu12==12.4.127 packaging==24.2 pandas==2.2.3 +patsy==1.0.1 pillow==11.0.0 pyparsing==3.2.0 python-dateutil==2.9.0.post0 pytz==2024.2 scikit-learn==1.6.0 +scikit-posthocs==0.11.2 scipy==1.14.1 +seaborn==0.13.2 setuptools==75.6.0 six==1.17.0 +statsmodels==0.14.4 sympy==1.13.1 threadpoolctl==3.5.0 torch==2.5.1