image_output_11.png text_plain_output_56.png text_plain_output_35.png image_output_24.png text_plain_output_43.png image_output_46.png text_plain_output_37.png image_output_25.png text_plain_output_5.png text_plain_output_48.png text_plain_output_30.png image_output_47.png text_plain_output_15.png image_output_17.png image_output_30.png text_plain_output_9.png text_plain_output_44.png image_output_14.png image_output_59.png image_output_39.png text_plain_output_40.png image_output_28.png text_plain_output_31.png text_plain_output_20.png image_output_23.png text_plain_output_60.png image_output_34.png image_output_64.png text_plain_output_4.png text_plain_output_64.png text_plain_output_13.png image_output_13.png text_plain_output_52.png text_plain_output_45.png image_output_40.png image_output_5.png image_output_48.png text_plain_output_14.png image_output_18.png text_plain_output_32.png text_plain_output_29.png image_output_58.png text_plain_output_58.png image_output_21.png text_plain_output_49.png text_plain_output_63.png text_plain_output_27.png image_output_52.png text_plain_output_54.png text_plain_output_10.png image_output_60.png text_plain_output_6.png image_output_7.png text_plain_output_57.png image_output_62.png text_plain_output_24.png text_plain_output_21.png image_output_56.png image_output_31.png text_plain_output_47.png text_plain_output_25.png image_output_20.png text_plain_output_18.png text_plain_output_50.png text_plain_output_36.png image_output_32.png image_output_53.png text_plain_output_3.png image_output_4.png image_output_51.png text_plain_output_22.png image_output_42.png image_output_35.png text_plain_output_38.png image_output_41.png image_output_57.png text_plain_output_7.png image_output_36.png image_output_8.png image_output_37.png text_plain_output_16.png image_output_16.png text_plain_output_59.png text_plain_output_8.png text_plain_output_26.png image_output_27.png image_output_54.png image_output_6.png text_plain_output_41.png text_plain_output_34.png image_output_45.png text_plain_output_42.png image_output_63.png text_plain_output_53.png text_plain_output_23.png text_plain_output_51.png image_output_12.png text_plain_output_28.png image_output_22.png text_plain_output_2.png image_output_55.png text_plain_output_1.png text_plain_output_33.png text_plain_output_39.png image_output_3.png image_output_29.png text_plain_output_55.png image_output_44.png image_output_43.png text_plain_output_19.png image_output_2.png image_output_1.png image_output_10.png text_plain_output_17.png text_plain_output_11.png text_plain_output_12.png image_output_33.png text_plain_output_62.png image_output_50.png image_output_15.png image_output_49.png text_plain_output_61.png image_output_9.png image_output_19.png image_output_61.png image_output_38.png image_output_26.png text_plain_output_46.png
from colorama import Style, Fore

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import seaborn as sns

import warnings

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
rc = {'axes.facecolor': '#F8F8F8', 'figure.facecolor': '#F8F8F8', 'axes.edgecolor': '#000000', 'grid.color': '#EBEBE7' + '30', 'font.family': 'serif', 'axes.labelcolor': '#000000', 'xtick.color': '#000000', 'ytick.color': '#000000', 'grid.alpha': 0.4}
sns.set(rc=rc)
palette = ['#302c36', '#037d97', '#91013E', '#C09741', '#EC5B6D', '#90A6B1', '#6ca957', '#D8E3E2']
from sklearn.ensemble import RandomForestClassifier
from vecstack import stacking
from sklearn.linear_model import LogisticRegression
from lightgbm import LGBMClassifier
from sklearn.naive_bayes import GaussianNB
from xgboost import XGBClassifier
from sklearn.metrics import roc_auc_score, accuracy_score, log_loss
from sklearn.model_selection import cross_val_score, train_test_split, RepeatedStratifiedKFold, StratifiedKFold
from sklearn.preprocessing import StandardScaler, MinMaxScaler
from sklearn.cluster import KMeans
import warnings
warnings.filterwarnings('ignore')
from sklearn.naive_bayes import BernoulliNB
import plotly.express as px
import random
import os
from copy import deepcopy
from functools import partial
from itertools import combinations
import random
import gc
import xgboost as xgb
from xgboost.callback import EarlyStopping
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier
from catboost import CatBoost, CatBoostClassifier
from catboost import Pool
from colorama import Style, Fore
blk = Style.BRIGHT + Fore.BLACK
mgt = Style.BRIGHT + Fore.MAGENTA
red = Style.BRIGHT + Fore.RED
blu = Style.BRIGHT + Fore.BLUE
res = Style.RESET_ALL

df_train = pd.read_csv('/kaggle/input/playground-series-s3e13/train.csv')
df_test = pd.read_csv('/kaggle/input/playground-series-s3e13/test.csv')
df_orig_train = pd.read_csv('/kaggle/input/vector-borne-disease-prediction/trainn.csv')
df_orig_test = pd.read_csv('/kaggle/input/vector-borne-disease-prediction/testt.csv')

df_train.columns

primary_columns = list(df_train.drop(columns=['id', 'prognosis']).columns)

train = df_train.copy().drop(columns=['id'])
marginals = train.groupby('prognosis').mean()
plt.xticks(range(64), marginals.columns, rotation=90)
plt.yticks(range(11), marginals.index)
plt.colorbar()

disease_dfs = {group_name: group_df for group_name, group_df in df_train.drop(columns=['id']).groupby(by='prognosis')}
diseses_important_symptoms = {}

import seaborn as sns
disease_combined = df_train.drop(columns=['id']).groupby(by='prognosis').sum()
value_counts = df_train['prognosis'].value_counts()
z_scores = {}
df_high = pd.DataFrame()
for col_name in df_train.columns:
    if col_name not in ['id', 'prognosis']:
        top_diseases = disease_combined[col_name].sort_values(ascending=False)
        top_df = top_diseases.reset_index()
        top_df['percentage'] = top_df.apply(lambda row: round(row[col_name] / value_counts[row['prognosis']], 2), axis=1)
        weights = top_df.drop(columns=[col_name])
        weights['z-score'] = round((weights['percentage'] - weights['percentage'].mean()) / weights['percentage'].std(), 2)
        z_scores[col_name] = {row['prognosis']: row['z-score'] for _, row in weights.iterrows()}

df_z = pd.DataFrame(z_scores)
plt.xticks(range(64), df_z.columns, rotation=90)
plt.yticks(range(11), df_z.index)
plt.colorbar()

df_symptom = df_z.T

symptom_cluster = df_symptom.groupby('cluster').groups
symptom_cluster