image_output_1.png
from scipy import stats

from scipy import stats

from scipy import stats

from scipy import stats

import matplotlib.pyplot as plt

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df_clinic = []
tmp = pd.read_csv('/kaggle/input/amp-parkinsons-disease-progression-prediction/train_clinical_data.csv')
train_clinical = pd.read_csv('/kaggle/input/amp-parkinsons-disease-progression-prediction/train_clinical_data.csv')
tmp['CSF'] = 1
df_clinic.append(tmp)
tmp = pd.read_csv('/kaggle/input/amp-parkinsons-disease-progression-prediction/supplemental_clinical_data.csv')
tmp['CSF'] = 0
df_clinic.append(tmp)
df_clinic = pd.concat(df_clinic, axis=0).reset_index(drop=True)
df_clinic = df_clinic.rename(columns={'upd23b_clinical_state_on_medication': 'medication'})

df_clinic.isna().sum()

df_clinic.nunique()

df_clinic.groupby('patient_id').size().describe()

import seaborn as sns
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(16,30))
features= ['updrs_1','updrs_2','updrs_3','updrs_4']

for i in range(len(features)):
    fig.add_subplot(9, 5, i+1)
    sns.distplot(df_clinic[features[i]])
plt.tight_layout()
plt.show()

from scipy import stats
fig, (ax) = plt.subplots(figsize = (4,4))
res = stats.probplot(df_clinic['updrs_1'],dist='norm', plot=ax)

from scipy import stats
fig, (ax) = plt.subplots(figsize = (4,4))
res = stats.probplot(df_clinic['updrs_2'],dist='norm', plot=ax)

from scipy import stats
fig, (ax) = plt.subplots(figsize = (4,4))
res = stats.probplot(df_clinic['updrs_3'],dist='norm', plot=ax)

from scipy import stats
fig, (ax) = plt.subplots(figsize = (4,4))
res = stats.probplot(df_clinic['updrs_4'],dist='norm', plot=ax)

plt.yticks(rotation=0)

df_eda = df_clinic.groupby('patient_id')['visit_month'].max()

ax = sns.histplot(df_eda, kde=True, color="blue", line_kws={'linewidth': 2, 'linestyle': '--'})
ax.lines[0].set_color('orange')
plt.title(f"Max month", fontweight="bold", pad=15)
plt.show()

df_eda = df_clinic.groupby('visit_month', as_index=False).mean().dropna()
df_eda

for i in range(4):
    sns.regplot(x=df_eda['visit_month'].values, y=df_eda[f'updrs_{i + 1}'].values, color='green', ci=None, line_kws={'color': 'orange', 'linestyle': '--'})
    plt.title(f'Mean of updrs_{i + 1} by timeseries', fontweight='bold', pad=15)
    plt.text(0, df_eda[f'updrs_{i + 1}'].values.max() * 0.99, f"CORR: {round(df_eda.corr().loc['visit_month', f'updrs_{i + 1}'], 3)}")
    plt.show()