image_output_1.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])
        print(f'{red}{col_name}:{res}')
        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()}
        print(weights.sort_values(by='z-score'), '\n')
        plt.figure(figsize=(3, 2))
        sns.kdeplot(weights['percentage'], shade=True)
        plt.title(f'Density Plot of {col_name}')
        plt.xlabel('Percentage')
        plt.ylabel('Density')
        plt.show()