<jupyter_start><jupyter_text>Plotting some graphs:<jupyter_code>INPUT_COLS = data.columns[0:112]
INPUT_COLS
INPUT_COLS_1stday = list(data.columns[[92, 99, 102]])
INPUT_COLS_1stday
INPUT_COLS_2ndday = list(data.columns[[93, 100, 103]])
INPUT_COLS_2ndday
INPUT_COLS_3rdday = list(data.columns[[94, 101, 104]])
INPUT_COLS_3rdday
OUTPUT_COLS = data.columns[112:]
OUTPUT_COLS
ID_COLS = ['ID']
TARGET_COLS = ['FIBR_PREDS', 'PREDS_TAH', 'JELUD_TAH', 'FIBR_JELUD', 'A_V_BLOK',
               'OTEK_LANC', 'RAZRIV', 'DRESSLER', 'ZSN', 'REC_IM', 'P_IM_STEN', 'LET_IS']
TARGET_COL = 'LET_IS'
FEATURE_COLS = np.array(data.columns[~np.isin(data.columns, ID_COLS+TARGET_COLS)])
FEATURE_COLS
boxplot_cols = list(data_desc.sort_values(by='mean', ascending=False).index[~np.isin(data_desc.index, ID_COLS+TARGET_COLS)])
vis.plot_feature_boxplots(data, TARGET_COLS, figsize=(15, 3), subplot_layout=(1, 2))
vis.plot_feature_boxplots(data, boxplot_cols, figsize=(15, 25), subplot_layout=(8, 2))<jupyter_output><empty_output><jupyter_text>Complications and lethal outcome:<jupyter_code>COMPLICATIONS_COLS = ['FIBR_PREDS', 'PREDS_TAH', 'JELUD_TAH', 'FIBR_JELUD', 'A_V_BLOK',
                      'OTEK_LANC', 'RAZRIV', 'DRESSLER', 'ZSN', 'REC_IM', 'P_IM_STEN']
COMPLICATIONS_NAMES = ['Atrial fibrillation', 'Supraventricular tachycardia', 'Ventricular tachycardia', 'Ventricular fibrillation', 'Third-degree AV block',
                       'Pulmonary edema', 'Myocardial rupture', 'Dressler syndrome', 'Chronic heart failure', 'Relapse of the myocardial infarction', 'Post-infarction angina']
TARGET_NAMES = ['Alive', 'Cardiogenic shock', 'Pulmonary edema', 'Myocardial rupture',
                'Progress of congestive heart failure',
                'Thromboembolism', 'Asystole', 'Ventricular fibrillation']
# Complications counts:
complications_counts = pd.DataFrame(data[COMPLICATIONS_COLS].sum(axis=0))
complications_counts.index = COMPLICATIONS_NAMES
complications_counts = complications_counts.sort_values(by=0, ascending=False)
complications_counts

plt.figure(figsize=(12, 8))
plt.title('Complications occurrences')
plt.bar(complications_counts.index, complications_counts[0])
plt.xticks(rotation=90)
plt.xlabel('Complications')
plt.ylabel('nº of occurrences')
plt.tight_layout()
plt.savefig('./imgs/Complications occurrences.png', dpi=100)
plt.show()
# Lethal Outcome counts:
plt.figure(figsize=(12, 8))
plt.title('Lethal Outcomes occurrences')
plt.bar(TARGET_NAMES, data['LET_IS'].value_counts(dropna=False))
plt.xticks(rotation=90)
plt.xlabel('Lethal Outcome')
plt.ylabel('nº of occurrences')
plt.tight_layout()
plt.savefig('./imgs/Lethal Outcomes occurrences.png', dpi=100)
plt.show()
data['LET_IS'].value_counts(dropna=False)
# Complication ration per Lethal Outcome:
results = []
for y in data[TARGET_COL].unique():
    dftmp = data[data[TARGET_COL] == y]
    results.append(dftmp[COMPLICATIONS_COLS].mean(axis=0).to_dict())
    results[-1][TARGET_COL] = y
results = pd.DataFrame(results)
results = results.sort_values(by=TARGET_COL).drop(columns=[TARGET_COL])
results.index = TARGET_NAMES
results.columns = COMPLICATIONS_NAMES

plt.figure(figsize=(16, 10))
plt.title('Complication ratio per Lethal Outcome')
sns.heatmap(results, cmap='coolwarm', annot=results.values.round(2))
plt.xlabel('Complications')
plt.ylabel('Lethal outcome')
plt.tight_layout()
plt.savefig('./imgs/Complication ratio per Lethal Outcome.png', dpi=100)
plt.show()<jupyter_output><empty_output><jupyter_text>Daily measurements:<jupyter_code>data[INPUT_COLS_1stday+INPUT_COLS_2ndday+INPUT_COLS_3rdday].isnull().sum(axis=0)
data[TARGET_COL][data[INPUT_COLS_1stday].isnull().sum(axis=1).astype(bool)].value_counts()
data[TARGET_COL][data[INPUT_COLS_2ndday].isnull().sum(axis=1).astype(bool)].value_counts()
data[TARGET_COL][data[INPUT_COLS_3rdday].isnull().sum(axis=1).astype(bool)].value_counts()
data[INPUT_COLS_1stday+INPUT_COLS_2ndday+INPUT_COLS_3rdday+[TARGET_COL]][data[INPUT_COLS_1stday+INPUT_COLS_2ndday+INPUT_COLS_3rdday].isnull().sum(axis=1).astype(bool)]
data[TARGET_COL][data[INPUT_COLS_1stday+INPUT_COLS_2ndday+INPUT_COLS_3rdday].isnull().sum(axis=1).astype(bool)].value_counts()
data[TARGET_COL][data[INPUT_COLS_1stday+INPUT_COLS_2ndday+INPUT_COLS_3rdday].isnull().sum(axis=1).astype(bool)].value_counts().sum()
model_number = [0, 1, 2, 3]
acc_simple = [0.89, 0.89, 0.90, 0.92]
acc_balanced = [0.69, 0.68, 0.72, 0.76]

plt.figure(figsize=(8, 6))
plt.plot(model_number, acc_simple, label='Acc (simple)', alpha=0.75)
plt.plot(model_number, acc_balanced, label='Acc (balanced)', alpha=0.75)

plt.xticks(model_number)
plt.xlabel('Model number')
plt.ylabel('Metric valuer')
plt.legend(loc='best', prop={'size': 10})
plt.tight_layout()
plt.savefig('./imgs/models_summary.png', dpi=100)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15770833333333334, 'fraction_numerical': 0.029583333333333333, 'mean_word_length': 8.197318007662835, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '513339', 'license': 'MIT', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1838, 'n_words': 259, 'path': 'notebooks/lucas/nbk00_data_exploration.ipynb', 'repo_name': 'dwelcaslu/IFSP-Projeto-Interdisciplinar', 'size': '4800'}