From fed6b3c77616cd271e46851a1ea3d60a67f6d347 Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Wed, 14 May 2025 17:43:01 -0300 Subject: [PATCH 1/9] feat: Add to teste do a-topsis a partir da leitura de um arquivo csv --- scripts/atopsis_test_from_file.py | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/atopsis_test_from_file.py diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_test_from_file.py new file mode 100644 index 0000000..e5cfd84 --- /dev/null +++ b/scripts/atopsis_test_from_file.py @@ -0,0 +1,51 @@ +import os +import pandas as pd +import numpy as np +import sys +sys.path.append("../src") +from decision_making import ATOPSIS + +def load_dataset(file_folder_path): + try: + dataset = pd.read_csv(file_folder_path, sep=",") + return dataset + except Exception as e: + print(f"Erro ao carregar os dados! Error:{e}\n") + return None + + +if __name__=="__main__": + file_folder_path = "../dataset/agg_metablockse_jbhi.csv" + dataset = load_dataset(file_folder_path) + ## Filtrar pelo modelo desejado + # dataset = dataset[dataset['visual-feature-extractor']=="resnet-50"] + + ## Filtrar os dados pela métrica desejada + dataset = dataset[dataset['missing-data-percenteage']==0] + + ## Para os dados referentes aos parâmetros desejos + # dataset = dataset[dataset['metric']!=('auc' and 'f1_score')] + + + print(dataset) + # Os algoritmos a serem testados + alg_names = dataset['method'].unique() + + # Ordenar as saídas dos dados por parâmetro + avg_mat = np.array(dataset['AVG']).reshape(len(alg_names),-1) + std_mat = np.array(dataset['STD']).reshape(len(alg_names),-1) + + # Pesos das decisões + weights = [0.7, 0.3] + + try: + atop = ATOPSIS(avg_mat, std_mat, avg_cost_ben="benefit", std_cost_ben="cost", weights=weights) + atop.get_ranking(True) + atop.plot_ranking(alg_names=alg_names) + except Exception as e: + print(f"An error occurred during A-TOPSIS processing: {e}") + + print("-" * 50) + print("") + + From f48bde3e2abe52cb0b89eda97cd8e9ca7e17987b Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Wed, 14 May 2025 18:27:26 -0300 Subject: [PATCH 2/9] feat: add dos arquivos usados de teste no gitignore --- scripts/atopsis_test_from_file.py | 46 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_test_from_file.py index e5cfd84..9672d5a 100644 --- a/scripts/atopsis_test_from_file.py +++ b/scripts/atopsis_test_from_file.py @@ -14,30 +14,40 @@ def load_dataset(file_folder_path): return None -if __name__=="__main__": - file_folder_path = "../dataset/agg_metablockse_jbhi.csv" +if __name__ == "__main__": + file_folder_path = "../dataset/agg_metablockse_jbhi_pad-25.csv" dataset = load_dataset(file_folder_path) - ## Filtrar pelo modelo desejado - # dataset = dataset[dataset['visual-feature-extractor']=="resnet-50"] + + if dataset is None: + sys.exit("Dataset could not be loaded. Exiting...") - ## Filtrar os dados pela métrica desejada - dataset = dataset[dataset['missing-data-percenteage']==0] + # Group the dataset by the 'comb_method' + grouped_data = dataset.groupby('comb_method') - ## Para os dados referentes aos parâmetros desejos - # dataset = dataset[dataset['metric']!=('auc' and 'f1_score')] + # Initialize an empty list to store the ordered groups + ordered_dataset = [] + # Iterate through each group (i.e., each unique comb_method) + for comb_method, group in grouped_data: + ordered_dataset.append(group) # Append each group to the list - print(dataset) - # Os algoritmos a serem testados - alg_names = dataset['method'].unique() + # Concatenate all the groups into a single ordered DataFrame + ordered_dataset = pd.concat(ordered_dataset) - # Ordenar as saídas dos dados por parâmetro - avg_mat = np.array(dataset['AVG']).reshape(len(alg_names),-1) - std_mat = np.array(dataset['STD']).reshape(len(alg_names),-1) - - # Pesos das decisões - weights = [0.7, 0.3] + print(f"Dataset reordenado:\n{ordered_dataset}\n") + # Get the unique 'alg_names' for the ordered dataset + alg_names = ordered_dataset['comb_method'].unique() + + # Prepare the matrices for A-TOPSIS + avg_mat = np.array(ordered_dataset['AVG']).reshape(len(alg_names), -1) + std_mat = np.array(ordered_dataset['STD']).reshape(len(alg_names), -1) + print("Average matrix:") + print(avg_mat) + + # Weights for decision-making + weights = [0.7, 0.3] + try: atop = ATOPSIS(avg_mat, std_mat, avg_cost_ben="benefit", std_cost_ben="cost", weights=weights) atop.get_ranking(True) @@ -47,5 +57,3 @@ def load_dataset(file_folder_path): print("-" * 50) print("") - - From 4b43540fe2b758a5efbdd46bca047dff9359ad6d Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Thu, 15 May 2025 14:36:13 -0300 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20Add=20descri=C3=A7=C3=A3o=20dos=20d?= =?UTF-8?q?ados=20dos=20eixos=20'x'=20e=20'y',=20al=C3=A9m=20da=20leitura?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/atopsis_test_from_file.py | 34 ++++++-- ...ted-cross-attention-models-atopsis-test.py | 87 +++++++++++++++++++ 2 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 scripts/gated-cross-attention-models-atopsis-test.py diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_test_from_file.py index 9672d5a..25877d1 100644 --- a/scripts/atopsis_test_from_file.py +++ b/scripts/atopsis_test_from_file.py @@ -34,7 +34,10 @@ def load_dataset(file_folder_path): # Concatenate all the groups into a single ordered DataFrame ordered_dataset = pd.concat(ordered_dataset) + # ordered_dataset = ordered_dataset[ordered_dataset["metric"]] print(f"Dataset reordenado:\n{ordered_dataset}\n") + + # Filtrar os dados do # Get the unique 'alg_names' for the ordered dataset alg_names = ordered_dataset['comb_method'].unique() @@ -42,18 +45,35 @@ def load_dataset(file_folder_path): avg_mat = np.array(ordered_dataset['AVG']).reshape(len(alg_names), -1) std_mat = np.array(ordered_dataset['STD']).reshape(len(alg_names), -1) - print("Average matrix:") - print(avg_mat) - # Weights for decision-making weights = [0.7, 0.3] try: - atop = ATOPSIS(avg_mat, std_mat, avg_cost_ben="benefit", std_cost_ben="cost", weights=weights) + atop = ATOPSIS(avg_mat, std_mat, avg_cost_ben="benefit", std_cost_ben="cost", weights=weights, normalize=False) atop.get_ranking(True) - atop.plot_ranking(alg_names=alg_names) + # atop.plot_ranking(alg_names=alg_names) except Exception as e: print(f"An error occurred during A-TOPSIS processing: {e}") - print("-" * 50) - print("") + # 2) Extrai scores do atributo final_ranking + scores = atop.final_ranking + + # 3) Monta o DataFrame de resultado + result = pd.DataFrame({ + "attention_mecanism": alg_names, + "atopsis_score": scores + }) + + # 4) Calcula o rank (maior score = melhor posição) + result["rank"] = ( + result["atopsis_score"] + .rank(ascending=False, method="min") + .astype(int) + ) + + print("\n=== Ranking Final ===") + print(result.sort_values("rank")) + + # 6) Plota com os próprios nomes + atop.plot_ranking(save_path="../images/a_topsis.png", alg_names=alg_names, show=True, font_size=22, title="A-TOPSIS for PAD-UFES-25 dataset", y_axis_title="Scores", x_axis_title="Methods") + diff --git a/scripts/gated-cross-attention-models-atopsis-test.py b/scripts/gated-cross-attention-models-atopsis-test.py new file mode 100644 index 0000000..4d2702c --- /dev/null +++ b/scripts/gated-cross-attention-models-atopsis-test.py @@ -0,0 +1,87 @@ +import sys +import pandas as pd +import numpy as np + +# 1) Ajuste do path para importar o ATOPSIS +sys.path.append("../../src") +from decision_making import ATOPSIS + + +def main(file_path): + # 2) Carrega o CSV e limpa nomes de coluna + df = pd.read_csv(file_path, sep=",") + df.columns = df.columns.str.strip() + print("Column names:", df.columns.tolist()) + + # 3) Métricas consideradas + metrics = ["accuracy", "balanced_accuracy", "auc"] + + + # wanted_model_name = "densenet169" + + # Obter as informações referentes ao modelo desejado + # df=df[df['model_name'] == wanted_model_name] + # df = df[df['attention_mecanism']==["no-metadata", "att-intramodal+residual+cross-attention-metadados"]] + print(df) + # 4) Extrai média e desvio padrão + for m in metrics: + df[[f"{m}_mean", f"{m}_std"]] = ( + df[m] + .str.extract(r"([\d\.]+)\s*±\s*([\d\.]+)") + .astype(float) + ) + + # 5) Agrupa por attention_mecanism e computa média de cada grupo + grouped = df.groupby("attention_mecanism").agg( + **{f"{m}_mean": (f"{m}_mean", "mean") for m in metrics}, + **{f"{m}_std": (f"{m}_std", "mean") for m in metrics}, + ).reset_index() + + # 6) Prepara as matrizes em memória + avg_mat = grouped[[f"{m}_mean" for m in metrics]].values.tolist() + std_mat = grouped[[f"{m}_std" for m in metrics]].values.tolist() + alg_names = grouped["attention_mecanism"].tolist() + + # 7) Executa A‑TOPSIS (listas de listas) + # avg_cost_ben="benefit" + # std_cost_ben="cost" + weights_presetted = [0.75, 0.25] + + # Executa A‑TOPSIS em memória (listas de listas) + atop = ATOPSIS( + avg_mat, + std_mat, + avg_cost_ben="benefit", + std_cost_ben="cost", + weights=weights_presetted, + normalize=True + ) + # 1) Gera o ranking (printa se verbose=True) + atop.get_ranking(verbose=True) + + # 2) Extrai scores do atributo final_ranking + scores = atop.final_ranking + + # 3) Monta o DataFrame de resultado + result = pd.DataFrame({ + "attention_mecanism": alg_names, + "atopsis_score": scores + }) + + # 4) Calcula o rank (maior score = melhor posição) + result["rank"] = ( + result["atopsis_score"] + .rank(ascending=False, method="min") + .astype(int) + ) + + print("\n=== Ranking Final ===") + print(result.sort_values("rank")) + + # 6) Plota com os próprios nomes + atop.plot_ranking(save_path="../../data/images/a_topsis.png", alg_names=alg_names, show=True, font_size=22, title="A-TOPSIS for PAD-UFES-20 dataset", y_axis_title="Scores", x_axis_title="Methods") + +if __name__=="__main__": + file_path = "../../data/metrics.csv" + # Função principal + main(file_path=file_path) \ No newline at end of file From fa9d0dfbc6bdd4f20ece7720d9216666a6c39914 Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Thu, 15 May 2025 16:40:31 -0300 Subject: [PATCH 4/9] feat: Fix tamanho da fonte --- scripts/atopsis_test_from_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_test_from_file.py index 25877d1..d99548a 100644 --- a/scripts/atopsis_test_from_file.py +++ b/scripts/atopsis_test_from_file.py @@ -67,7 +67,7 @@ def load_dataset(file_folder_path): # 4) Calcula o rank (maior score = melhor posição) result["rank"] = ( result["atopsis_score"] - .rank(ascending=False, method="min") + .rank(ascending=True, method="min") .astype(int) ) @@ -75,5 +75,5 @@ def load_dataset(file_folder_path): print(result.sort_values("rank")) # 6) Plota com os próprios nomes - atop.plot_ranking(save_path="../images/a_topsis.png", alg_names=alg_names, show=True, font_size=22, title="A-TOPSIS for PAD-UFES-25 dataset", y_axis_title="Scores", x_axis_title="Methods") + atop.plot_ranking(save_path="../images/a_topsis.png", alg_names=alg_names, show=True, font_size=22, title="A-TOPSIS for PAD-UFES-20-Extended dataset", y_axis_title="Scores", x_axis_title="Methods", ascending=True) From 4ce05181a06c4852ed2ddc41623debd4175de7bf Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Tue, 20 May 2025 17:09:51 -0300 Subject: [PATCH 5/9] =?UTF-8?q?feat:=20Altera=C3=A7=C3=A3o=20da=20cor=20do?= =?UTF-8?q?s=20gr=C3=A1ficos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/atopsis_test_from_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_test_from_file.py index d99548a..91bbe72 100644 --- a/scripts/atopsis_test_from_file.py +++ b/scripts/atopsis_test_from_file.py @@ -46,7 +46,7 @@ def load_dataset(file_folder_path): std_mat = np.array(ordered_dataset['STD']).reshape(len(alg_names), -1) # Weights for decision-making - weights = [0.7, 0.3] + weights = [0.5, 0.5] try: atop = ATOPSIS(avg_mat, std_mat, avg_cost_ben="benefit", std_cost_ben="cost", weights=weights, normalize=False) @@ -75,5 +75,5 @@ def load_dataset(file_folder_path): print(result.sort_values("rank")) # 6) Plota com os próprios nomes - atop.plot_ranking(save_path="../images/a_topsis.png", alg_names=alg_names, show=True, font_size=22, title="A-TOPSIS for PAD-UFES-20-Extended dataset", y_axis_title="Scores", x_axis_title="Methods", ascending=True) + atop.plot_ranking(save_path="../images/a_topsis.png", alg_names=alg_names, show=True, font_size=25, title="A-TOPSIS for PAD-UFES-20-Extended dataset", y_axis_title="Scores", x_axis_title="Methods", ascending=True) From 794b5d85aba587e07bee2aaaa934c8b123c96713 Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Thu, 22 May 2025 10:36:08 -0300 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20Add=20'fig=5Fsize'=20para=20salvar?= =?UTF-8?q?=20a=20imagem=20no=20formato=20pr=C3=A9-definido?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/atopsis_test_from_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_test_from_file.py index 91bbe72..d759739 100644 --- a/scripts/atopsis_test_from_file.py +++ b/scripts/atopsis_test_from_file.py @@ -75,5 +75,5 @@ def load_dataset(file_folder_path): print(result.sort_values("rank")) # 6) Plota com os próprios nomes - atop.plot_ranking(save_path="../images/a_topsis.png", alg_names=alg_names, show=True, font_size=25, title="A-TOPSIS for PAD-UFES-20-Extended dataset", y_axis_title="Scores", x_axis_title="Methods", ascending=True) + atop.plot_ranking(save_path="../images/a_topsis_PAD_20_extended.png", alg_names=alg_names, show=True, font_size=25, title="", y_axis_title="Scores", x_axis_title="", ascending=True, fig_size=(21, 14)) From a01d1583da9ef411d226f06d4bfb0a35817ad5ee Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Mon, 26 May 2025 17:19:39 -0300 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20Add=20modifica=C3=A7=C3=B5es=20nos?= =?UTF-8?q?=20scripts=20para=20rodar=20o=20teste=20com=20o=20A-TOPSIS=20de?= =?UTF-8?q?=20forma=20autom=C3=A1tica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 8 +- README.md | 6 ++ ...test_from_file.py => atopsis_from_file.py} | 6 +- ...ted-cross-attention-models-atopsis-test.py | 11 +-- src/decision_making/a_topsis.py | 4 +- src/decision_making/topsis.py | 87 +++++++++++++------ 6 files changed, 83 insertions(+), 39 deletions(-) rename scripts/{atopsis_test_from_file.py => atopsis_from_file.py} (86%) diff --git a/.gitignore b/.gitignore index cb18546..fc175df 100644 --- a/.gitignore +++ b/.gitignore @@ -150,4 +150,10 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ \ No newline at end of file +#.idea/ +dataset/agg_metablockse_jbhi.csv +dataset/arquivo_de_teste_pad-25.csv +dataset/agg_metablockse_jbhi_pad-25.csv +a_topsis.png +images/* +dataset/agg_residual-block-pad-ufes-20.csv diff --git a/README.md b/README.md index ffb9777..f16e1f1 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ inside the folder :test_tube: All methods are documented using the docstring format. However, to understand how the algorithms work, you must refer to their paper linked in the [references section](#references). +# Running an automatic A-TOPSIS test + +Now, you can export your benchmarck's results from `deep` + +Add your aggregated results inside the folder 'dataset', change the configuration of the a-topsis in the script 'scripts/atopsis_from_file.py' and then run the command: `python3 scripts/atopsis_from_file.py` + ## References All implementations follow the standard approach described in the paper. However, for TODIM algorithm, we included the diff --git a/scripts/atopsis_test_from_file.py b/scripts/atopsis_from_file.py similarity index 86% rename from scripts/atopsis_test_from_file.py rename to scripts/atopsis_from_file.py index d759739..edf8731 100644 --- a/scripts/atopsis_test_from_file.py +++ b/scripts/atopsis_from_file.py @@ -2,7 +2,7 @@ import pandas as pd import numpy as np import sys -sys.path.append("../src") +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) from decision_making import ATOPSIS def load_dataset(file_folder_path): @@ -15,7 +15,7 @@ def load_dataset(file_folder_path): if __name__ == "__main__": - file_folder_path = "../dataset/agg_metablockse_jbhi_pad-25.csv" + file_folder_path = "./dataset/agg_metablockse_jbhi_pad-25.csv" dataset = load_dataset(file_folder_path) if dataset is None: @@ -75,5 +75,5 @@ def load_dataset(file_folder_path): print(result.sort_values("rank")) # 6) Plota com os próprios nomes - atop.plot_ranking(save_path="../images/a_topsis_PAD_20_extended.png", alg_names=alg_names, show=True, font_size=25, title="", y_axis_title="Scores", x_axis_title="", ascending=True, fig_size=(21, 14)) + atop.plot_ranking(save_path="./images/a_topsis_PAD_20_extended.png", alg_names=alg_names, show=True, font_size=25, title="", y_axis_title="Scores", x_axis_title="", ascending=True, fig_size=(21, 14)) diff --git a/scripts/gated-cross-attention-models-atopsis-test.py b/scripts/gated-cross-attention-models-atopsis-test.py index 4d2702c..eeab82b 100644 --- a/scripts/gated-cross-attention-models-atopsis-test.py +++ b/scripts/gated-cross-attention-models-atopsis-test.py @@ -1,9 +1,10 @@ +import os import sys import pandas as pd import numpy as np # 1) Ajuste do path para importar o ATOPSIS -sys.path.append("../../src") +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) from decision_making import ATOPSIS @@ -41,11 +42,11 @@ def main(file_path): avg_mat = grouped[[f"{m}_mean" for m in metrics]].values.tolist() std_mat = grouped[[f"{m}_std" for m in metrics]].values.tolist() alg_names = grouped["attention_mecanism"].tolist() - + # alg_names = grouped["model_name"].tolist() # 7) Executa A‑TOPSIS (listas de listas) # avg_cost_ben="benefit" # std_cost_ben="cost" - weights_presetted = [0.75, 0.25] + weights_presetted = [0.7, 0.3] # Executa A‑TOPSIS em memória (listas de listas) atop = ATOPSIS( @@ -79,9 +80,9 @@ def main(file_path): print(result.sort_values("rank")) # 6) Plota com os próprios nomes - atop.plot_ranking(save_path="../../data/images/a_topsis.png", alg_names=alg_names, show=True, font_size=22, title="A-TOPSIS for PAD-UFES-20 dataset", y_axis_title="Scores", x_axis_title="Methods") + atop.plot_ranking(save_path="./images/a_topsis_PAD_UFES_20.png", alg_names=alg_names, show=True, font_size=16, title="", y_axis_title="Scores", x_axis_title="Methods", ascending=True) if __name__=="__main__": - file_path = "../../data/metrics.csv" + file_path = "dataset/agg_residual-block-pad-ufes-20.csv" # Função principal main(file_path=file_path) \ No newline at end of file diff --git a/src/decision_making/a_topsis.py b/src/decision_making/a_topsis.py index 1a4871b..04f51e3 100644 --- a/src/decision_making/a_topsis.py +++ b/src/decision_making/a_topsis.py @@ -104,7 +104,7 @@ def get_ranking(self, verbose=True): self.final_topsis.get_closeness_coefficient(verbose) self.final_ranking = self.final_topsis.clos_coefficient - def plot_ranking(self, alg_names=None, save_path=None, show=True): + def plot_ranking(self, alg_names=None, save_path=None, show=True, font_size=16, title="A-TOPSIS test", y_axis_title="Scores", x_axis_title="Methods", ascending=False, fig_size=(6,4)): """ This method plots the ranking, according to the final_ranking, in a bar plot. @@ -125,7 +125,7 @@ def plot_ranking(self, alg_names=None, save_path=None, show=True): """ if alg_names is None: alg_names = self.final_topsis.alternatives - self.final_topsis.plot_ranking(alg_names, save_path, show) + self.final_topsis.plot_ranking(alg_names, save_path, show, font_size, title, y_axis_title, x_axis_title, ascending=ascending, fig_size=fig_size) diff --git a/src/decision_making/topsis.py b/src/decision_making/topsis.py index 366171a..49173aa 100644 --- a/src/decision_making/topsis.py +++ b/src/decision_making/topsis.py @@ -214,43 +214,74 @@ def get_closeness_coefficient(self, verbose=False, compute_distance_ideal=True): if verbose: print (self.clos_coefficient) - def plot_ranking(self, alt_names=None, save_path=None, show=True): + def plot_ranking(self, alt_names=None, save_path=None, show=True, font_size=16, + title="A-TOPSIS Test", y_axis_title="Scores", x_axis_title="Methods", + ascending=True, fig_size=(6, 4)): """ - This method plots the ranking, according to the closeness coefficient, in a bar plot. + Plots a bar chart representing the ranking based on the closeness coefficient. - Parameters: - ----------- - alt_names: (list), optional - This is a list of names for each alternative within the decision matrix. If you're using a DataFrame, you have - already defined when you set the alt_col_name. So, you may let it as None. However, if you're using a matrix - list or a numpy array, you may pass the alternatives name here. If you let it as None, there will be a default - alternatives name in the plot (ex: A1, A2, etc). Default is None - - save_path: (str), optional - It's the full path (including the figure name and extension) to save the plot. If you let it None, the plot - won't be saved. Default is None. - - show: (boolean), optional - Set is as True if you want to show the plot on the screen. Default is False. + Parameters + ---------- + alt_names : list, optional + Names for each alternative. If None and using a DataFrame, the names from `self.alternatives` are used. + Otherwise, defaults to ["A1", "A2", ...]. + + save_path : str, optional + Full path (including filename and extension) to save the plot. If None, the plot is not saved. + + show : bool, optional + If True, displays the plot. + + font_size : int, optional + Base font size for labels and ticks. + + title : str, optional + Title of the plot. + + y_axis_title : str, optional + Label for the Y-axis. + + x_axis_title : str, optional + Label for the X-axis. + + ascending : bool, optional + If True, sorts the alternatives by score in ascending order. Default is False (descending). """ sns.set_style("whitegrid") - if self.alternatives is not None: - alt_names = self.alternatives - if alt_names is not None: - a = sns.barplot(alt_names, self.clos_coefficient, palette="BuGn_d") - else: - temp = [f"A{n}" for n in range(1, len(self.clos_coefficient)+1, 1)] - a = sns.barplot(temp, self.clos_coefficient, palette="BuGn_d") - a.set_ylabel("Closeness Coefficient") - a.set_xlabel('Alternatives') - fig = a.get_figure() + # Determine alternative names + if alt_names is None: + if hasattr(self, 'alternatives') and self.alternatives is not None: + alt_names = self.alternatives + else: + alt_names = [f"A{i+1}" for i in range(len(self.clos_coefficient))] + + # Sort based on closeness coefficient + sorted_data = sorted(zip(alt_names, self.clos_coefficient), key=lambda x: x[1], reverse=not ascending) + sorted_names, sorted_scores = zip(*sorted_data) + + # Criar figura com tamanho específico + fig, ax = plt.subplots(figsize=fig_size) + + # Plot + sns.barplot(x=list(sorted_names), y=list(sorted_scores), palette="Blues", ax=ax) + ax.set_title(title, fontsize=font_size) + ax.set_ylabel(y_axis_title, fontsize=font_size) + ax.set_xlabel(x_axis_title, fontsize=font_size) + ax.tick_params(labelsize=font_size) + # plt.xticks(rotation=30, ha='right') + + if show: plt.show() + # Save or show + if save_path: + fig.savefig(save_path, dpi=400, bbox_inches='tight') + else: + plt.close(fig) - if save_path is not None: - fig.savefig(save_path) + return fig ######################################################################################################################## # Static methods From 57f0629b015da2db845b7e12f325b92e7e3f3cfe Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Mon, 26 May 2025 17:27:01 -0300 Subject: [PATCH 8/9] =?UTF-8?q?feat:=20Ignorar=20todos=20os=20dados=20de?= =?UTF-8?q?=20agrega=C3=A7=C3=A3o=20dos=20experimentos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fc175df..b7e4df3 100644 --- a/.gitignore +++ b/.gitignore @@ -156,4 +156,4 @@ dataset/arquivo_de_teste_pad-25.csv dataset/agg_metablockse_jbhi_pad-25.csv a_topsis.png images/* -dataset/agg_residual-block-pad-ufes-20.csv +dataset/* From 4a1c2bdd340f9fd8c4b13d786e9706cd290537b6 Mon Sep 17 00:00:00 2001 From: wyctorfogos Date: Mon, 26 May 2025 17:38:36 -0300 Subject: [PATCH 9/9] =?UTF-8?q?docs:=20Atualiza=C3=A7=C3=A3o=20da=20docume?= =?UTF-8?q?nta=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f16e1f1..1259083 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ refer to their paper linked in the [references section](#references). # Running an automatic A-TOPSIS test -Now, you can export your benchmarck's results from `deep` +Now, you can export your benchmarck's results from `deep-hub-pipelines` Add your aggregated results inside the folder 'dataset', change the configuration of the a-topsis in the script 'scripts/atopsis_from_file.py' and then run the command: `python3 scripts/atopsis_from_file.py`