<jupyter_start><jupyter_text>De acordo com o teste de Wilcoxon, não houve diferença significativa entre os resultados obtidos com 5 e com 30 enxames de partículas. Portanto, o critério adotado para a escolha da quantidade de enxames foi a menor ocorrência de valores zero em cada evento e a maior mediana entre os valores de hipervolume em cada evento. Segundo esse critério, foi adotada a configuração com 30 enxames de 60 partículas cada.<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import wilcoxon

%matplotlib inline

def algorithm_dataset(raw_data, algorithm_id, sorted_by="event", zero_values=False):
    data = raw_data.loc[[algorithm_id]]
    data = data.sort_values(by=sorted_by)
    if not zero_values:
        data = data[data.hypervolume != 0]
    return data

def comparison_dataset(ds):
    return ds.groupby(["algorithm","event"], as_index=False)["hypervolume"].mean()

def max_event(ds):
    return ds["event"].max()

column_labels = ["algorithm", "instance", "execution", "event", "hypervolume"] 
# data_5_200 = pd.read_csv("../hypervolume/metrics-ms2mo-5-200.csv", 
#                    delimiter=" ", 
#                    header=None,     
#                    names=column_labels,
#                    index_col=column_labels[0])
# data_30_60 = pd.read_csv("../hypervolume/metrics-ms2mo-30-60.csv", 
#                    delimiter=" ", 
#                    header=None,     
#                    names=column_labels,
#                    index_col=column_labels[0])

# data = data_5_200.append(data_30_60)
data = pd.read_csv("../hypervolume/metrics.csv", 
                   delimiter=" ", 
                   header=None,     
                   names=column_labels,
                   index_col=column_labels[0])
data.describe()
ds_30_60 = algorithm_dataset(data, "ms2mo_30s60p", zero_values=True)
ds_5_200 = algorithm_dataset(data, "ms2mo_5s200p", zero_values=True)
ds_30_60_nz = algorithm_dataset(data, "ms2mo_30s60p")
ds_5_200_nz = algorithm_dataset(data, "ms2mo_5s200p")

datasets = {
    "poucos": comparison_dataset(ds_5_200),
    "muitos": comparison_dataset(ds_30_60),
    "poucos_nz": comparison_dataset(ds_5_200_nz),
    "muitos_nz": comparison_dataset(ds_30_60_nz),
}

min_event = min([max_event(ds) for ds in datasets.values()])

for k in datasets.keys():
    datasets[k] = datasets[k][:min_event+1]
plt.title("Poucos Enxames x Muitos Enxames")
plt.xlabel("Eventos dinâmicos (pontos de reescalonamento)")
plt.ylabel("Hipervolume")
plt.plot(datasets["poucos"].event, datasets["poucos"].hypervolume, "-ro", markersize=3, lw=.5, label="5s200p")
plt.plot(datasets["muitos"].event, datasets["muitos"].hypervolume, "-go", markersize=3, lw=.5, label="30s60p")
plt.legend()
plt.show()
s, p = wilcoxon(datasets["poucos"].hypervolume, datasets["muitos"].hypervolume)

if (p <= 0.05):
    print("p-value = ", p, "Há diferença significativa!")
else:
    print("p-value = ", p, "Não há diferença significativa.")
plt.title("Poucos Enxames x Muitos Enxames (sem zeros)")
plt.xlabel("Eventos dinâmicos (pontos de reescalonamento)")
plt.ylabel("Hipervolume")
plt.plot(datasets["poucos_nz"].event, datasets["poucos_nz"].hypervolume, "-ro", markersize=3, lw=.5, label="5s200p")
plt.plot(datasets["muitos_nz"].event, datasets["muitos_nz"].hypervolume, "-go", markersize=3, lw=.5, label="30s60p")
plt.legend()
plt.show()
ds_30_60_nz.hypervolume.describe()
ds_30_60_nz.hypervolume.median()
ds_5_200_nz.hypervolume.describe()
ds_5_200_nz.hypervolume.median()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13571227872998032, 'fraction_numerical': 0.03737004776622647, 'mean_word_length': 4.151953690303907, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '171711', 'license': 'MIT', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1246, 'n_words': 250, 'path': 'dspsp-analysis/comp_numero_enxames_ms2mo.ipynb', 'repo_name': 'lclpsoz/spsp-jmetal', 'size': '3559'}