first commit
Browse files- Drop_Columns.txt +1 -0
- app.py +11 -0
- eda.py +104 -0
- h8dsft_p1g3_Ahmad Luay Adnani_inference.csv +11 -0
- heart_failure.jpg +0 -0
- inference.ipynb +756 -0
- phase1_ftds_018_rmt.csv +300 -0
- prediction.py +64 -0
- requirements.txt +8 -0
- rf_gridcv_best.pkl +3 -0
Drop_Columns.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
["sex", "high_blood_pressure", "diabetes", "smoking", "anaemia"]
|
app.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import eda # python file
|
3 |
+
import prediction # python file
|
4 |
+
|
5 |
+
navigation = st.sidebar.selectbox('Page Navigation: ',('EDA','Predict Patients Conditions'))
|
6 |
+
|
7 |
+
if navigation == 'EDA':
|
8 |
+
eda.run()
|
9 |
+
else:
|
10 |
+
prediction.run()
|
11 |
+
|
eda.py
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import seaborn as sns
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import plotly.express as px
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
st.set_page_config(
|
9 |
+
page_title='Heart Failure Prediction based on Ensamble Classifier: Random Forest Classifier and Adaptive Boost Classifier',
|
10 |
+
layout = 'wide',
|
11 |
+
initial_sidebar_state='expanded'
|
12 |
+
)
|
13 |
+
|
14 |
+
def run():
|
15 |
+
# membuat title
|
16 |
+
st.title('Heart Failure Prediction')
|
17 |
+
|
18 |
+
# membuat sub header
|
19 |
+
st.subheader ('Exploratory Data Analysis of the dataset.')
|
20 |
+
|
21 |
+
# Menambahkan Gambar
|
22 |
+
image = Image.open('heart_failure.jpg')
|
23 |
+
st.image(image,caption = 'Heart Failure ilustration')
|
24 |
+
|
25 |
+
# Menambahkan Deskripsi
|
26 |
+
st.write('This page created by Ahmad Luay Adnani')
|
27 |
+
st.write('# Dataset')
|
28 |
+
|
29 |
+
|
30 |
+
# show dataframe
|
31 |
+
df = pd.read_csv('phase1_ftds_018_rmt.csv')
|
32 |
+
st.dataframe(df)
|
33 |
+
|
34 |
+
# DEATH_EVENT
|
35 |
+
st.write('# Exploaratory Data Analysis ')
|
36 |
+
st.write('## Number of Death Event ')
|
37 |
+
# death_event value count
|
38 |
+
death_event = df.DEATH_EVENT.value_counts().to_frame()
|
39 |
+
death_event = death_event.reset_index()
|
40 |
+
death_event['index'] = death_event['index'].replace({0:'No',1:'Yes'})
|
41 |
+
death_event
|
42 |
+
|
43 |
+
# Plot PieChart with Plotly
|
44 |
+
fig = px.pie(death_event,values='DEATH_EVENT', names='index')
|
45 |
+
# fig.update_traces(text = death_event['DEATH_EVENT'].value_counts(), textinfo = 'label+percent+value')
|
46 |
+
fig.update_layout(title_text = "Death Event", title_x = 0.5)
|
47 |
+
st.plotly_chart(fig)
|
48 |
+
st.write('Number of deaths after the following days are different, where **Non-Death are 36% greater than Death**. This will be keep in mind if there is any imbalance data or not. But first, the death_event--as the target--will be compared with other variables so we can get the conclusion for the skewness and handling imbalance data.')
|
49 |
+
|
50 |
+
# Gender Distribution
|
51 |
+
st.write('### Gender Distribution ')
|
52 |
+
# gender value count
|
53 |
+
sex = df.groupby(by=['sex','DEATH_EVENT']).aggregate(Number_of_DEATH_EVENT=('DEATH_EVENT','count'))
|
54 |
+
sex = sex.reset_index()
|
55 |
+
sex['sex'] = sex['sex'].replace({0:'Female',1:'Male'})
|
56 |
+
sex
|
57 |
+
|
58 |
+
# plotting bar plot
|
59 |
+
fig = px.bar(sex, x="sex", y="Number_of_DEATH_EVENT", color="DEATH_EVENT",
|
60 |
+
orientation="v",hover_name="sex"
|
61 |
+
|
62 |
+
)
|
63 |
+
fig.update_layout(title_text = "Gender Distribution", title_x = 0.5)
|
64 |
+
st.plotly_chart(fig)
|
65 |
+
st.write('From the visualization above, Male patients who have smoking habits have a higher chance of dying during follow up periods than any other conditions.')
|
66 |
+
|
67 |
+
|
68 |
+
# Male Patients Condition
|
69 |
+
st.write('## Male Patients Condition ')
|
70 |
+
# male patients deceased during the follow up period
|
71 |
+
df_male = df.loc[(df['sex']==1)&
|
72 |
+
(df['DEATH_EVENT']==1)]
|
73 |
+
df_male.head()
|
74 |
+
|
75 |
+
# Create Bar Charts
|
76 |
+
sns.set(font_scale=2)
|
77 |
+
fig, ax = plt.subplots(1,4, sharex=True, figsize=(40,25))
|
78 |
+
sns.countplot(ax=ax[0],x=df_male['anaemia'], palette='winter')
|
79 |
+
ax[0].set_title('Male patients with anemia')
|
80 |
+
sns.countplot(ax=ax[1],x=df_male['diabetes'], palette='winter')
|
81 |
+
ax[1].set_title('Male patients with diabetes')
|
82 |
+
sns.countplot(ax=ax[2],x=df_male['high_blood_pressure'], palette='winter')
|
83 |
+
ax[2].set_title('Male patients with high blood pressure')
|
84 |
+
sns.countplot(ax=ax[3],x=df_male['smoking'], palette='winter')
|
85 |
+
ax[3].set_title('Male patients with habit of smoking')
|
86 |
+
st.pyplot(fig)
|
87 |
+
st.write('From the table and visualization above, it can be seen that the number of male patients with heart failure is more than female patients. **Where about 32% die during the follow-up period**. Further data exploration is necessary to find out the condition of male patients.')
|
88 |
+
|
89 |
+
#
|
90 |
+
st.write('## Comparison between Death Event with other variables ')
|
91 |
+
# Creating new dataframe for the histogram
|
92 |
+
sns.set(font_scale=1)
|
93 |
+
output = 'DEATH_EVENT'
|
94 |
+
cols = [f for f in df.columns if df.dtypes[f] != "object"]
|
95 |
+
f = pd.melt(df, id_vars=output, value_vars=cols)
|
96 |
+
|
97 |
+
# Creating histogram
|
98 |
+
g = sns.FacetGrid(f, hue=output, col="variable", col_wrap=4, sharex=False, sharey=False )
|
99 |
+
g = g.map(sns.histplot, "value", kde=True).add_legend()
|
100 |
+
st.pyplot(g)
|
101 |
+
st.write('Based on the histogram above, we can see that the distribution of Not Death is still dominating that Death. However, we should check wherer variable time looks different than the others, where Death is high with time between 0-100 days. From here we should check the skewness of time as well.')
|
102 |
+
|
103 |
+
if __name__ == '__main__':
|
104 |
+
run()
|
h8dsft_p1g3_Ahmad Luay Adnani_inference.csv
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,age,anaemia,creatinine_phosphokinase,diabetes,ejection_fraction,high_blood_pressure,platelets,serum_creatinine,serum_sodium,sex,smoking,time,DEATH_EVENT
|
2 |
+
12,65.0,0.0,56.0,0.0,25.0,0.0,237000.0,5.0,130.0,0.0,0.0,207.0,0.0
|
3 |
+
52,67.0,0.0,213.0,0.0,38.0,0.0,215000.0,1.2,133.0,0.0,0.0,245.0,0.0
|
4 |
+
108,75.0,0.0,582.0,0.0,20.0,1.0,265000.0,1.9,130.0,1.0,0.0,4.0,1.0
|
5 |
+
136,72.0,1.0,943.0,0.0,25.0,1.0,338000.0,1.7,139.0,1.0,1.0,111.0,1.0
|
6 |
+
188,65.0,0.0,198.0,1.0,35.0,1.0,281000.0,0.9,137.0,1.0,1.0,146.0,0.0
|
7 |
+
205,55.0,0.0,7861.0,0.0,38.0,0.0,263358.03,1.1,136.0,1.0,0.0,6.0,1.0
|
8 |
+
206,75.0,1.0,81.0,0.0,38.0,1.0,368000.0,4.0,131.0,1.0,1.0,10.0,1.0
|
9 |
+
219,53.0,1.0,707.0,0.0,38.0,0.0,330000.0,1.4,137.0,1.0,1.0,209.0,0.0
|
10 |
+
228,62.0,0.0,61.0,1.0,38.0,1.0,155000.0,1.1,143.0,1.0,1.0,270.0,0.0
|
11 |
+
237,75.0,0.0,582.0,0.0,40.0,0.0,263358.03,1.18,137.0,1.0,0.0,107.0,0.0
|
heart_failure.jpg
ADDED
![]() |
inference.ipynb
ADDED
@@ -0,0 +1,756 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 4,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"# Save and Load Model\n",
|
11 |
+
"import pickle\n",
|
12 |
+
"import json"
|
13 |
+
]
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"cell_type": "code",
|
17 |
+
"execution_count": 2,
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [
|
20 |
+
{
|
21 |
+
"name": "stderr",
|
22 |
+
"output_type": "stream",
|
23 |
+
"text": [
|
24 |
+
"C:\\Users\\luay9\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\base.py:299: UserWarning: Trying to unpickle estimator MinMaxScaler from version 1.2.2 when using version 1.2.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:\n",
|
25 |
+
"https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations\n",
|
26 |
+
" warnings.warn(\n",
|
27 |
+
"C:\\Users\\luay9\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\base.py:299: UserWarning: Trying to unpickle estimator StandardScaler from version 1.2.2 when using version 1.2.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:\n",
|
28 |
+
"https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations\n",
|
29 |
+
" warnings.warn(\n",
|
30 |
+
"C:\\Users\\luay9\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\base.py:299: UserWarning: Trying to unpickle estimator ColumnTransformer from version 1.2.2 when using version 1.2.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:\n",
|
31 |
+
"https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations\n",
|
32 |
+
" warnings.warn(\n",
|
33 |
+
"C:\\Users\\luay9\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\base.py:299: UserWarning: Trying to unpickle estimator NearestNeighbors from version 1.2.2 when using version 1.2.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:\n",
|
34 |
+
"https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations\n",
|
35 |
+
" warnings.warn(\n",
|
36 |
+
"C:\\Users\\luay9\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\base.py:299: UserWarning: Trying to unpickle estimator DecisionTreeClassifier from version 1.2.2 when using version 1.2.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:\n",
|
37 |
+
"https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations\n",
|
38 |
+
" warnings.warn(\n",
|
39 |
+
"C:\\Users\\luay9\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\base.py:299: UserWarning: Trying to unpickle estimator RandomForestClassifier from version 1.2.2 when using version 1.2.1. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:\n",
|
40 |
+
"https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations\n",
|
41 |
+
" warnings.warn(\n"
|
42 |
+
]
|
43 |
+
}
|
44 |
+
],
|
45 |
+
"source": [
|
46 |
+
"# Loading Model Files\n",
|
47 |
+
"\n",
|
48 |
+
"with open('rf_gridcv_best.pkl', 'rb') as file_1:\n",
|
49 |
+
" rf_gridcv_best = pickle.load(file_1)\n",
|
50 |
+
"\n",
|
51 |
+
"with open('Drop_Columns.txt','r') as file_2:\n",
|
52 |
+
" Drop_Columns = json.load(file_2)"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
{
|
56 |
+
"cell_type": "code",
|
57 |
+
"execution_count": 5,
|
58 |
+
"metadata": {},
|
59 |
+
"outputs": [
|
60 |
+
{
|
61 |
+
"data": {
|
62 |
+
"text/html": [
|
63 |
+
"<div>\n",
|
64 |
+
"<style scoped>\n",
|
65 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
66 |
+
" vertical-align: middle;\n",
|
67 |
+
" }\n",
|
68 |
+
"\n",
|
69 |
+
" .dataframe tbody tr th {\n",
|
70 |
+
" vertical-align: top;\n",
|
71 |
+
" }\n",
|
72 |
+
"\n",
|
73 |
+
" .dataframe thead th {\n",
|
74 |
+
" text-align: right;\n",
|
75 |
+
" }\n",
|
76 |
+
"</style>\n",
|
77 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
78 |
+
" <thead>\n",
|
79 |
+
" <tr style=\"text-align: right;\">\n",
|
80 |
+
" <th></th>\n",
|
81 |
+
" <th>age</th>\n",
|
82 |
+
" <th>anaemia</th>\n",
|
83 |
+
" <th>creatinine_phosphokinase</th>\n",
|
84 |
+
" <th>diabetes</th>\n",
|
85 |
+
" <th>ejection_fraction</th>\n",
|
86 |
+
" <th>high_blood_pressure</th>\n",
|
87 |
+
" <th>platelets</th>\n",
|
88 |
+
" <th>serum_creatinine</th>\n",
|
89 |
+
" <th>serum_sodium</th>\n",
|
90 |
+
" <th>sex</th>\n",
|
91 |
+
" <th>smoking</th>\n",
|
92 |
+
" <th>time</th>\n",
|
93 |
+
" <th>DEATH_EVENT</th>\n",
|
94 |
+
" </tr>\n",
|
95 |
+
" </thead>\n",
|
96 |
+
" <tbody>\n",
|
97 |
+
" <tr>\n",
|
98 |
+
" <th>0</th>\n",
|
99 |
+
" <td>65.0</td>\n",
|
100 |
+
" <td>0.0</td>\n",
|
101 |
+
" <td>56.0</td>\n",
|
102 |
+
" <td>0.0</td>\n",
|
103 |
+
" <td>25.0</td>\n",
|
104 |
+
" <td>0.0</td>\n",
|
105 |
+
" <td>237000.00</td>\n",
|
106 |
+
" <td>5.00</td>\n",
|
107 |
+
" <td>130.0</td>\n",
|
108 |
+
" <td>0.0</td>\n",
|
109 |
+
" <td>0.0</td>\n",
|
110 |
+
" <td>207.0</td>\n",
|
111 |
+
" <td>0.0</td>\n",
|
112 |
+
" </tr>\n",
|
113 |
+
" <tr>\n",
|
114 |
+
" <th>1</th>\n",
|
115 |
+
" <td>67.0</td>\n",
|
116 |
+
" <td>0.0</td>\n",
|
117 |
+
" <td>213.0</td>\n",
|
118 |
+
" <td>0.0</td>\n",
|
119 |
+
" <td>38.0</td>\n",
|
120 |
+
" <td>0.0</td>\n",
|
121 |
+
" <td>215000.00</td>\n",
|
122 |
+
" <td>1.20</td>\n",
|
123 |
+
" <td>133.0</td>\n",
|
124 |
+
" <td>0.0</td>\n",
|
125 |
+
" <td>0.0</td>\n",
|
126 |
+
" <td>245.0</td>\n",
|
127 |
+
" <td>0.0</td>\n",
|
128 |
+
" </tr>\n",
|
129 |
+
" <tr>\n",
|
130 |
+
" <th>2</th>\n",
|
131 |
+
" <td>75.0</td>\n",
|
132 |
+
" <td>0.0</td>\n",
|
133 |
+
" <td>582.0</td>\n",
|
134 |
+
" <td>0.0</td>\n",
|
135 |
+
" <td>20.0</td>\n",
|
136 |
+
" <td>1.0</td>\n",
|
137 |
+
" <td>265000.00</td>\n",
|
138 |
+
" <td>1.90</td>\n",
|
139 |
+
" <td>130.0</td>\n",
|
140 |
+
" <td>1.0</td>\n",
|
141 |
+
" <td>0.0</td>\n",
|
142 |
+
" <td>4.0</td>\n",
|
143 |
+
" <td>1.0</td>\n",
|
144 |
+
" </tr>\n",
|
145 |
+
" <tr>\n",
|
146 |
+
" <th>3</th>\n",
|
147 |
+
" <td>72.0</td>\n",
|
148 |
+
" <td>1.0</td>\n",
|
149 |
+
" <td>943.0</td>\n",
|
150 |
+
" <td>0.0</td>\n",
|
151 |
+
" <td>25.0</td>\n",
|
152 |
+
" <td>1.0</td>\n",
|
153 |
+
" <td>338000.00</td>\n",
|
154 |
+
" <td>1.70</td>\n",
|
155 |
+
" <td>139.0</td>\n",
|
156 |
+
" <td>1.0</td>\n",
|
157 |
+
" <td>1.0</td>\n",
|
158 |
+
" <td>111.0</td>\n",
|
159 |
+
" <td>1.0</td>\n",
|
160 |
+
" </tr>\n",
|
161 |
+
" <tr>\n",
|
162 |
+
" <th>4</th>\n",
|
163 |
+
" <td>65.0</td>\n",
|
164 |
+
" <td>0.0</td>\n",
|
165 |
+
" <td>198.0</td>\n",
|
166 |
+
" <td>1.0</td>\n",
|
167 |
+
" <td>35.0</td>\n",
|
168 |
+
" <td>1.0</td>\n",
|
169 |
+
" <td>281000.00</td>\n",
|
170 |
+
" <td>0.90</td>\n",
|
171 |
+
" <td>137.0</td>\n",
|
172 |
+
" <td>1.0</td>\n",
|
173 |
+
" <td>1.0</td>\n",
|
174 |
+
" <td>146.0</td>\n",
|
175 |
+
" <td>0.0</td>\n",
|
176 |
+
" </tr>\n",
|
177 |
+
" <tr>\n",
|
178 |
+
" <th>5</th>\n",
|
179 |
+
" <td>55.0</td>\n",
|
180 |
+
" <td>0.0</td>\n",
|
181 |
+
" <td>7861.0</td>\n",
|
182 |
+
" <td>0.0</td>\n",
|
183 |
+
" <td>38.0</td>\n",
|
184 |
+
" <td>0.0</td>\n",
|
185 |
+
" <td>263358.03</td>\n",
|
186 |
+
" <td>1.10</td>\n",
|
187 |
+
" <td>136.0</td>\n",
|
188 |
+
" <td>1.0</td>\n",
|
189 |
+
" <td>0.0</td>\n",
|
190 |
+
" <td>6.0</td>\n",
|
191 |
+
" <td>1.0</td>\n",
|
192 |
+
" </tr>\n",
|
193 |
+
" <tr>\n",
|
194 |
+
" <th>6</th>\n",
|
195 |
+
" <td>75.0</td>\n",
|
196 |
+
" <td>1.0</td>\n",
|
197 |
+
" <td>81.0</td>\n",
|
198 |
+
" <td>0.0</td>\n",
|
199 |
+
" <td>38.0</td>\n",
|
200 |
+
" <td>1.0</td>\n",
|
201 |
+
" <td>368000.00</td>\n",
|
202 |
+
" <td>4.00</td>\n",
|
203 |
+
" <td>131.0</td>\n",
|
204 |
+
" <td>1.0</td>\n",
|
205 |
+
" <td>1.0</td>\n",
|
206 |
+
" <td>10.0</td>\n",
|
207 |
+
" <td>1.0</td>\n",
|
208 |
+
" </tr>\n",
|
209 |
+
" <tr>\n",
|
210 |
+
" <th>7</th>\n",
|
211 |
+
" <td>53.0</td>\n",
|
212 |
+
" <td>1.0</td>\n",
|
213 |
+
" <td>707.0</td>\n",
|
214 |
+
" <td>0.0</td>\n",
|
215 |
+
" <td>38.0</td>\n",
|
216 |
+
" <td>0.0</td>\n",
|
217 |
+
" <td>330000.00</td>\n",
|
218 |
+
" <td>1.40</td>\n",
|
219 |
+
" <td>137.0</td>\n",
|
220 |
+
" <td>1.0</td>\n",
|
221 |
+
" <td>1.0</td>\n",
|
222 |
+
" <td>209.0</td>\n",
|
223 |
+
" <td>0.0</td>\n",
|
224 |
+
" </tr>\n",
|
225 |
+
" <tr>\n",
|
226 |
+
" <th>8</th>\n",
|
227 |
+
" <td>62.0</td>\n",
|
228 |
+
" <td>0.0</td>\n",
|
229 |
+
" <td>61.0</td>\n",
|
230 |
+
" <td>1.0</td>\n",
|
231 |
+
" <td>38.0</td>\n",
|
232 |
+
" <td>1.0</td>\n",
|
233 |
+
" <td>155000.00</td>\n",
|
234 |
+
" <td>1.10</td>\n",
|
235 |
+
" <td>143.0</td>\n",
|
236 |
+
" <td>1.0</td>\n",
|
237 |
+
" <td>1.0</td>\n",
|
238 |
+
" <td>270.0</td>\n",
|
239 |
+
" <td>0.0</td>\n",
|
240 |
+
" </tr>\n",
|
241 |
+
" <tr>\n",
|
242 |
+
" <th>9</th>\n",
|
243 |
+
" <td>75.0</td>\n",
|
244 |
+
" <td>0.0</td>\n",
|
245 |
+
" <td>582.0</td>\n",
|
246 |
+
" <td>0.0</td>\n",
|
247 |
+
" <td>40.0</td>\n",
|
248 |
+
" <td>0.0</td>\n",
|
249 |
+
" <td>263358.03</td>\n",
|
250 |
+
" <td>1.18</td>\n",
|
251 |
+
" <td>137.0</td>\n",
|
252 |
+
" <td>1.0</td>\n",
|
253 |
+
" <td>0.0</td>\n",
|
254 |
+
" <td>107.0</td>\n",
|
255 |
+
" <td>0.0</td>\n",
|
256 |
+
" </tr>\n",
|
257 |
+
" </tbody>\n",
|
258 |
+
"</table>\n",
|
259 |
+
"</div>"
|
260 |
+
],
|
261 |
+
"text/plain": [
|
262 |
+
" age anaemia creatinine_phosphokinase diabetes ejection_fraction \\\n",
|
263 |
+
"0 65.0 0.0 56.0 0.0 25.0 \n",
|
264 |
+
"1 67.0 0.0 213.0 0.0 38.0 \n",
|
265 |
+
"2 75.0 0.0 582.0 0.0 20.0 \n",
|
266 |
+
"3 72.0 1.0 943.0 0.0 25.0 \n",
|
267 |
+
"4 65.0 0.0 198.0 1.0 35.0 \n",
|
268 |
+
"5 55.0 0.0 7861.0 0.0 38.0 \n",
|
269 |
+
"6 75.0 1.0 81.0 0.0 38.0 \n",
|
270 |
+
"7 53.0 1.0 707.0 0.0 38.0 \n",
|
271 |
+
"8 62.0 0.0 61.0 1.0 38.0 \n",
|
272 |
+
"9 75.0 0.0 582.0 0.0 40.0 \n",
|
273 |
+
"\n",
|
274 |
+
" high_blood_pressure platelets serum_creatinine serum_sodium sex \\\n",
|
275 |
+
"0 0.0 237000.00 5.00 130.0 0.0 \n",
|
276 |
+
"1 0.0 215000.00 1.20 133.0 0.0 \n",
|
277 |
+
"2 1.0 265000.00 1.90 130.0 1.0 \n",
|
278 |
+
"3 1.0 338000.00 1.70 139.0 1.0 \n",
|
279 |
+
"4 1.0 281000.00 0.90 137.0 1.0 \n",
|
280 |
+
"5 0.0 263358.03 1.10 136.0 1.0 \n",
|
281 |
+
"6 1.0 368000.00 4.00 131.0 1.0 \n",
|
282 |
+
"7 0.0 330000.00 1.40 137.0 1.0 \n",
|
283 |
+
"8 1.0 155000.00 1.10 143.0 1.0 \n",
|
284 |
+
"9 0.0 263358.03 1.18 137.0 1.0 \n",
|
285 |
+
"\n",
|
286 |
+
" smoking time DEATH_EVENT \n",
|
287 |
+
"0 0.0 207.0 0.0 \n",
|
288 |
+
"1 0.0 245.0 0.0 \n",
|
289 |
+
"2 0.0 4.0 1.0 \n",
|
290 |
+
"3 1.0 111.0 1.0 \n",
|
291 |
+
"4 1.0 146.0 0.0 \n",
|
292 |
+
"5 0.0 6.0 1.0 \n",
|
293 |
+
"6 1.0 10.0 1.0 \n",
|
294 |
+
"7 1.0 209.0 0.0 \n",
|
295 |
+
"8 1.0 270.0 0.0 \n",
|
296 |
+
"9 0.0 107.0 0.0 "
|
297 |
+
]
|
298 |
+
},
|
299 |
+
"execution_count": 5,
|
300 |
+
"metadata": {},
|
301 |
+
"output_type": "execute_result"
|
302 |
+
}
|
303 |
+
],
|
304 |
+
"source": [
|
305 |
+
"# data inference\n",
|
306 |
+
"df_inf = pd.read_csv('G:\\My Drive\\FTDS\\phase 1\\p1gc3\\h8dsft_p1g3_Ahmad Luay Adnani_inference.csv')\n",
|
307 |
+
"df_inf_copy = df_inf.copy()\n",
|
308 |
+
"df_inf_copy = df_inf.drop(['Unnamed: 0'],axis=1)\n",
|
309 |
+
"df_inf_copy"
|
310 |
+
]
|
311 |
+
},
|
312 |
+
{
|
313 |
+
"cell_type": "code",
|
314 |
+
"execution_count": 6,
|
315 |
+
"metadata": {},
|
316 |
+
"outputs": [
|
317 |
+
{
|
318 |
+
"data": {
|
319 |
+
"text/html": [
|
320 |
+
"<div>\n",
|
321 |
+
"<style scoped>\n",
|
322 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
323 |
+
" vertical-align: middle;\n",
|
324 |
+
" }\n",
|
325 |
+
"\n",
|
326 |
+
" .dataframe tbody tr th {\n",
|
327 |
+
" vertical-align: top;\n",
|
328 |
+
" }\n",
|
329 |
+
"\n",
|
330 |
+
" .dataframe thead th {\n",
|
331 |
+
" text-align: right;\n",
|
332 |
+
" }\n",
|
333 |
+
"</style>\n",
|
334 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
335 |
+
" <thead>\n",
|
336 |
+
" <tr style=\"text-align: right;\">\n",
|
337 |
+
" <th></th>\n",
|
338 |
+
" <th>age</th>\n",
|
339 |
+
" <th>creatinine_phosphokinase</th>\n",
|
340 |
+
" <th>ejection_fraction</th>\n",
|
341 |
+
" <th>platelets</th>\n",
|
342 |
+
" <th>serum_creatinine</th>\n",
|
343 |
+
" <th>serum_sodium</th>\n",
|
344 |
+
" <th>time</th>\n",
|
345 |
+
" <th>DEATH_EVENT</th>\n",
|
346 |
+
" </tr>\n",
|
347 |
+
" </thead>\n",
|
348 |
+
" <tbody>\n",
|
349 |
+
" <tr>\n",
|
350 |
+
" <th>0</th>\n",
|
351 |
+
" <td>65.0</td>\n",
|
352 |
+
" <td>56.0</td>\n",
|
353 |
+
" <td>25.0</td>\n",
|
354 |
+
" <td>237000.00</td>\n",
|
355 |
+
" <td>5.00</td>\n",
|
356 |
+
" <td>130.0</td>\n",
|
357 |
+
" <td>207.0</td>\n",
|
358 |
+
" <td>0.0</td>\n",
|
359 |
+
" </tr>\n",
|
360 |
+
" <tr>\n",
|
361 |
+
" <th>1</th>\n",
|
362 |
+
" <td>67.0</td>\n",
|
363 |
+
" <td>213.0</td>\n",
|
364 |
+
" <td>38.0</td>\n",
|
365 |
+
" <td>215000.00</td>\n",
|
366 |
+
" <td>1.20</td>\n",
|
367 |
+
" <td>133.0</td>\n",
|
368 |
+
" <td>245.0</td>\n",
|
369 |
+
" <td>0.0</td>\n",
|
370 |
+
" </tr>\n",
|
371 |
+
" <tr>\n",
|
372 |
+
" <th>2</th>\n",
|
373 |
+
" <td>75.0</td>\n",
|
374 |
+
" <td>582.0</td>\n",
|
375 |
+
" <td>20.0</td>\n",
|
376 |
+
" <td>265000.00</td>\n",
|
377 |
+
" <td>1.90</td>\n",
|
378 |
+
" <td>130.0</td>\n",
|
379 |
+
" <td>4.0</td>\n",
|
380 |
+
" <td>1.0</td>\n",
|
381 |
+
" </tr>\n",
|
382 |
+
" <tr>\n",
|
383 |
+
" <th>3</th>\n",
|
384 |
+
" <td>72.0</td>\n",
|
385 |
+
" <td>943.0</td>\n",
|
386 |
+
" <td>25.0</td>\n",
|
387 |
+
" <td>338000.00</td>\n",
|
388 |
+
" <td>1.70</td>\n",
|
389 |
+
" <td>139.0</td>\n",
|
390 |
+
" <td>111.0</td>\n",
|
391 |
+
" <td>1.0</td>\n",
|
392 |
+
" </tr>\n",
|
393 |
+
" <tr>\n",
|
394 |
+
" <th>4</th>\n",
|
395 |
+
" <td>65.0</td>\n",
|
396 |
+
" <td>198.0</td>\n",
|
397 |
+
" <td>35.0</td>\n",
|
398 |
+
" <td>281000.00</td>\n",
|
399 |
+
" <td>0.90</td>\n",
|
400 |
+
" <td>137.0</td>\n",
|
401 |
+
" <td>146.0</td>\n",
|
402 |
+
" <td>0.0</td>\n",
|
403 |
+
" </tr>\n",
|
404 |
+
" <tr>\n",
|
405 |
+
" <th>5</th>\n",
|
406 |
+
" <td>55.0</td>\n",
|
407 |
+
" <td>7861.0</td>\n",
|
408 |
+
" <td>38.0</td>\n",
|
409 |
+
" <td>263358.03</td>\n",
|
410 |
+
" <td>1.10</td>\n",
|
411 |
+
" <td>136.0</td>\n",
|
412 |
+
" <td>6.0</td>\n",
|
413 |
+
" <td>1.0</td>\n",
|
414 |
+
" </tr>\n",
|
415 |
+
" <tr>\n",
|
416 |
+
" <th>6</th>\n",
|
417 |
+
" <td>75.0</td>\n",
|
418 |
+
" <td>81.0</td>\n",
|
419 |
+
" <td>38.0</td>\n",
|
420 |
+
" <td>368000.00</td>\n",
|
421 |
+
" <td>4.00</td>\n",
|
422 |
+
" <td>131.0</td>\n",
|
423 |
+
" <td>10.0</td>\n",
|
424 |
+
" <td>1.0</td>\n",
|
425 |
+
" </tr>\n",
|
426 |
+
" <tr>\n",
|
427 |
+
" <th>7</th>\n",
|
428 |
+
" <td>53.0</td>\n",
|
429 |
+
" <td>707.0</td>\n",
|
430 |
+
" <td>38.0</td>\n",
|
431 |
+
" <td>330000.00</td>\n",
|
432 |
+
" <td>1.40</td>\n",
|
433 |
+
" <td>137.0</td>\n",
|
434 |
+
" <td>209.0</td>\n",
|
435 |
+
" <td>0.0</td>\n",
|
436 |
+
" </tr>\n",
|
437 |
+
" <tr>\n",
|
438 |
+
" <th>8</th>\n",
|
439 |
+
" <td>62.0</td>\n",
|
440 |
+
" <td>61.0</td>\n",
|
441 |
+
" <td>38.0</td>\n",
|
442 |
+
" <td>155000.00</td>\n",
|
443 |
+
" <td>1.10</td>\n",
|
444 |
+
" <td>143.0</td>\n",
|
445 |
+
" <td>270.0</td>\n",
|
446 |
+
" <td>0.0</td>\n",
|
447 |
+
" </tr>\n",
|
448 |
+
" <tr>\n",
|
449 |
+
" <th>9</th>\n",
|
450 |
+
" <td>75.0</td>\n",
|
451 |
+
" <td>582.0</td>\n",
|
452 |
+
" <td>40.0</td>\n",
|
453 |
+
" <td>263358.03</td>\n",
|
454 |
+
" <td>1.18</td>\n",
|
455 |
+
" <td>137.0</td>\n",
|
456 |
+
" <td>107.0</td>\n",
|
457 |
+
" <td>0.0</td>\n",
|
458 |
+
" </tr>\n",
|
459 |
+
" </tbody>\n",
|
460 |
+
"</table>\n",
|
461 |
+
"</div>"
|
462 |
+
],
|
463 |
+
"text/plain": [
|
464 |
+
" age creatinine_phosphokinase ejection_fraction platelets \\\n",
|
465 |
+
"0 65.0 56.0 25.0 237000.00 \n",
|
466 |
+
"1 67.0 213.0 38.0 215000.00 \n",
|
467 |
+
"2 75.0 582.0 20.0 265000.00 \n",
|
468 |
+
"3 72.0 943.0 25.0 338000.00 \n",
|
469 |
+
"4 65.0 198.0 35.0 281000.00 \n",
|
470 |
+
"5 55.0 7861.0 38.0 263358.03 \n",
|
471 |
+
"6 75.0 81.0 38.0 368000.00 \n",
|
472 |
+
"7 53.0 707.0 38.0 330000.00 \n",
|
473 |
+
"8 62.0 61.0 38.0 155000.00 \n",
|
474 |
+
"9 75.0 582.0 40.0 263358.03 \n",
|
475 |
+
"\n",
|
476 |
+
" serum_creatinine serum_sodium time DEATH_EVENT \n",
|
477 |
+
"0 5.00 130.0 207.0 0.0 \n",
|
478 |
+
"1 1.20 133.0 245.0 0.0 \n",
|
479 |
+
"2 1.90 130.0 4.0 1.0 \n",
|
480 |
+
"3 1.70 139.0 111.0 1.0 \n",
|
481 |
+
"4 0.90 137.0 146.0 0.0 \n",
|
482 |
+
"5 1.10 136.0 6.0 1.0 \n",
|
483 |
+
"6 4.00 131.0 10.0 1.0 \n",
|
484 |
+
"7 1.40 137.0 209.0 0.0 \n",
|
485 |
+
"8 1.10 143.0 270.0 0.0 \n",
|
486 |
+
"9 1.18 137.0 107.0 0.0 "
|
487 |
+
]
|
488 |
+
},
|
489 |
+
"execution_count": 6,
|
490 |
+
"metadata": {},
|
491 |
+
"output_type": "execute_result"
|
492 |
+
}
|
493 |
+
],
|
494 |
+
"source": [
|
495 |
+
"# Removing unnecessary features\n",
|
496 |
+
"df_inf_final = df_inf_copy.drop(Drop_Columns,axis=1).sort_index()\n",
|
497 |
+
"df_inf_final"
|
498 |
+
]
|
499 |
+
},
|
500 |
+
{
|
501 |
+
"cell_type": "code",
|
502 |
+
"execution_count": 7,
|
503 |
+
"metadata": {},
|
504 |
+
"outputs": [
|
505 |
+
{
|
506 |
+
"data": {
|
507 |
+
"text/plain": [
|
508 |
+
"array([1., 0., 1., 1., 0., 1., 1., 0., 0., 0.])"
|
509 |
+
]
|
510 |
+
},
|
511 |
+
"execution_count": 7,
|
512 |
+
"metadata": {},
|
513 |
+
"output_type": "execute_result"
|
514 |
+
}
|
515 |
+
],
|
516 |
+
"source": [
|
517 |
+
"# Predict using RandomForest\n",
|
518 |
+
"\n",
|
519 |
+
"y_pred_inf = rf_gridcv_best.predict(df_inf_final) #rf_gridcv_best from load files\n",
|
520 |
+
"y_pred_inf"
|
521 |
+
]
|
522 |
+
},
|
523 |
+
{
|
524 |
+
"cell_type": "code",
|
525 |
+
"execution_count": 9,
|
526 |
+
"metadata": {},
|
527 |
+
"outputs": [
|
528 |
+
{
|
529 |
+
"data": {
|
530 |
+
"text/html": [
|
531 |
+
"<div>\n",
|
532 |
+
"<style scoped>\n",
|
533 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
534 |
+
" vertical-align: middle;\n",
|
535 |
+
" }\n",
|
536 |
+
"\n",
|
537 |
+
" .dataframe tbody tr th {\n",
|
538 |
+
" vertical-align: top;\n",
|
539 |
+
" }\n",
|
540 |
+
"\n",
|
541 |
+
" .dataframe thead th {\n",
|
542 |
+
" text-align: right;\n",
|
543 |
+
" }\n",
|
544 |
+
"</style>\n",
|
545 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
546 |
+
" <thead>\n",
|
547 |
+
" <tr style=\"text-align: right;\">\n",
|
548 |
+
" <th></th>\n",
|
549 |
+
" <th>DEATH_EVENT_Prediction</th>\n",
|
550 |
+
" </tr>\n",
|
551 |
+
" </thead>\n",
|
552 |
+
" <tbody>\n",
|
553 |
+
" <tr>\n",
|
554 |
+
" <th>0</th>\n",
|
555 |
+
" <td>1.0</td>\n",
|
556 |
+
" </tr>\n",
|
557 |
+
" <tr>\n",
|
558 |
+
" <th>1</th>\n",
|
559 |
+
" <td>0.0</td>\n",
|
560 |
+
" </tr>\n",
|
561 |
+
" <tr>\n",
|
562 |
+
" <th>2</th>\n",
|
563 |
+
" <td>1.0</td>\n",
|
564 |
+
" </tr>\n",
|
565 |
+
" <tr>\n",
|
566 |
+
" <th>3</th>\n",
|
567 |
+
" <td>1.0</td>\n",
|
568 |
+
" </tr>\n",
|
569 |
+
" <tr>\n",
|
570 |
+
" <th>4</th>\n",
|
571 |
+
" <td>0.0</td>\n",
|
572 |
+
" </tr>\n",
|
573 |
+
" <tr>\n",
|
574 |
+
" <th>5</th>\n",
|
575 |
+
" <td>1.0</td>\n",
|
576 |
+
" </tr>\n",
|
577 |
+
" <tr>\n",
|
578 |
+
" <th>6</th>\n",
|
579 |
+
" <td>1.0</td>\n",
|
580 |
+
" </tr>\n",
|
581 |
+
" <tr>\n",
|
582 |
+
" <th>7</th>\n",
|
583 |
+
" <td>0.0</td>\n",
|
584 |
+
" </tr>\n",
|
585 |
+
" <tr>\n",
|
586 |
+
" <th>8</th>\n",
|
587 |
+
" <td>0.0</td>\n",
|
588 |
+
" </tr>\n",
|
589 |
+
" <tr>\n",
|
590 |
+
" <th>9</th>\n",
|
591 |
+
" <td>0.0</td>\n",
|
592 |
+
" </tr>\n",
|
593 |
+
" </tbody>\n",
|
594 |
+
"</table>\n",
|
595 |
+
"</div>"
|
596 |
+
],
|
597 |
+
"text/plain": [
|
598 |
+
" DEATH_EVENT_Prediction\n",
|
599 |
+
"0 1.0\n",
|
600 |
+
"1 0.0\n",
|
601 |
+
"2 1.0\n",
|
602 |
+
"3 1.0\n",
|
603 |
+
"4 0.0\n",
|
604 |
+
"5 1.0\n",
|
605 |
+
"6 1.0\n",
|
606 |
+
"7 0.0\n",
|
607 |
+
"8 0.0\n",
|
608 |
+
"9 0.0"
|
609 |
+
]
|
610 |
+
},
|
611 |
+
"execution_count": 9,
|
612 |
+
"metadata": {},
|
613 |
+
"output_type": "execute_result"
|
614 |
+
}
|
615 |
+
],
|
616 |
+
"source": [
|
617 |
+
"# Create DEATH_EVENT Prediction DataFrame\n",
|
618 |
+
"\n",
|
619 |
+
"y_pred_inf_df = pd.DataFrame(y_pred_inf, columns=['DEATH_EVENT_Prediction'],index=df_inf_final.index)\n",
|
620 |
+
"round(y_pred_inf_df.head(10),2)"
|
621 |
+
]
|
622 |
+
},
|
623 |
+
{
|
624 |
+
"cell_type": "code",
|
625 |
+
"execution_count": 10,
|
626 |
+
"metadata": {},
|
627 |
+
"outputs": [
|
628 |
+
{
|
629 |
+
"data": {
|
630 |
+
"text/html": [
|
631 |
+
"<div>\n",
|
632 |
+
"<style scoped>\n",
|
633 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
634 |
+
" vertical-align: middle;\n",
|
635 |
+
" }\n",
|
636 |
+
"\n",
|
637 |
+
" .dataframe tbody tr th {\n",
|
638 |
+
" vertical-align: top;\n",
|
639 |
+
" }\n",
|
640 |
+
"\n",
|
641 |
+
" .dataframe thead th {\n",
|
642 |
+
" text-align: right;\n",
|
643 |
+
" }\n",
|
644 |
+
"</style>\n",
|
645 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
646 |
+
" <thead>\n",
|
647 |
+
" <tr style=\"text-align: right;\">\n",
|
648 |
+
" <th></th>\n",
|
649 |
+
" <th>DEATH_EVENT</th>\n",
|
650 |
+
" <th>DEATH_EVENT_Prediction</th>\n",
|
651 |
+
" </tr>\n",
|
652 |
+
" </thead>\n",
|
653 |
+
" <tbody>\n",
|
654 |
+
" <tr>\n",
|
655 |
+
" <th>0</th>\n",
|
656 |
+
" <td>0.0</td>\n",
|
657 |
+
" <td>1.0</td>\n",
|
658 |
+
" </tr>\n",
|
659 |
+
" <tr>\n",
|
660 |
+
" <th>1</th>\n",
|
661 |
+
" <td>0.0</td>\n",
|
662 |
+
" <td>0.0</td>\n",
|
663 |
+
" </tr>\n",
|
664 |
+
" <tr>\n",
|
665 |
+
" <th>2</th>\n",
|
666 |
+
" <td>1.0</td>\n",
|
667 |
+
" <td>1.0</td>\n",
|
668 |
+
" </tr>\n",
|
669 |
+
" <tr>\n",
|
670 |
+
" <th>3</th>\n",
|
671 |
+
" <td>1.0</td>\n",
|
672 |
+
" <td>1.0</td>\n",
|
673 |
+
" </tr>\n",
|
674 |
+
" <tr>\n",
|
675 |
+
" <th>4</th>\n",
|
676 |
+
" <td>0.0</td>\n",
|
677 |
+
" <td>0.0</td>\n",
|
678 |
+
" </tr>\n",
|
679 |
+
" <tr>\n",
|
680 |
+
" <th>5</th>\n",
|
681 |
+
" <td>1.0</td>\n",
|
682 |
+
" <td>1.0</td>\n",
|
683 |
+
" </tr>\n",
|
684 |
+
" <tr>\n",
|
685 |
+
" <th>6</th>\n",
|
686 |
+
" <td>1.0</td>\n",
|
687 |
+
" <td>1.0</td>\n",
|
688 |
+
" </tr>\n",
|
689 |
+
" <tr>\n",
|
690 |
+
" <th>7</th>\n",
|
691 |
+
" <td>0.0</td>\n",
|
692 |
+
" <td>0.0</td>\n",
|
693 |
+
" </tr>\n",
|
694 |
+
" <tr>\n",
|
695 |
+
" <th>8</th>\n",
|
696 |
+
" <td>0.0</td>\n",
|
697 |
+
" <td>0.0</td>\n",
|
698 |
+
" </tr>\n",
|
699 |
+
" <tr>\n",
|
700 |
+
" <th>9</th>\n",
|
701 |
+
" <td>0.0</td>\n",
|
702 |
+
" <td>0.0</td>\n",
|
703 |
+
" </tr>\n",
|
704 |
+
" </tbody>\n",
|
705 |
+
"</table>\n",
|
706 |
+
"</div>"
|
707 |
+
],
|
708 |
+
"text/plain": [
|
709 |
+
" DEATH_EVENT DEATH_EVENT_Prediction\n",
|
710 |
+
"0 0.0 1.0\n",
|
711 |
+
"1 0.0 0.0\n",
|
712 |
+
"2 1.0 1.0\n",
|
713 |
+
"3 1.0 1.0\n",
|
714 |
+
"4 0.0 0.0\n",
|
715 |
+
"5 1.0 1.0\n",
|
716 |
+
"6 1.0 1.0\n",
|
717 |
+
"7 0.0 0.0\n",
|
718 |
+
"8 0.0 0.0\n",
|
719 |
+
"9 0.0 0.0"
|
720 |
+
]
|
721 |
+
},
|
722 |
+
"execution_count": 10,
|
723 |
+
"metadata": {},
|
724 |
+
"output_type": "execute_result"
|
725 |
+
}
|
726 |
+
],
|
727 |
+
"source": [
|
728 |
+
"# Comparing the real default_payment_next_month and predicted classification\n",
|
729 |
+
"model_inf = pd.concat([df_inf_copy['DEATH_EVENT'], y_pred_inf_df['DEATH_EVENT_Prediction']], axis=1).sort_index()\n",
|
730 |
+
"model_inf"
|
731 |
+
]
|
732 |
+
}
|
733 |
+
],
|
734 |
+
"metadata": {
|
735 |
+
"kernelspec": {
|
736 |
+
"display_name": "Python 3",
|
737 |
+
"language": "python",
|
738 |
+
"name": "python3"
|
739 |
+
},
|
740 |
+
"language_info": {
|
741 |
+
"codemirror_mode": {
|
742 |
+
"name": "ipython",
|
743 |
+
"version": 3
|
744 |
+
},
|
745 |
+
"file_extension": ".py",
|
746 |
+
"mimetype": "text/x-python",
|
747 |
+
"name": "python",
|
748 |
+
"nbconvert_exporter": "python",
|
749 |
+
"pygments_lexer": "ipython3",
|
750 |
+
"version": "3.9.13"
|
751 |
+
},
|
752 |
+
"orig_nbformat": 4
|
753 |
+
},
|
754 |
+
"nbformat": 4,
|
755 |
+
"nbformat_minor": 2
|
756 |
+
}
|
phase1_ftds_018_rmt.csv
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
age,anaemia,creatinine_phosphokinase,diabetes,ejection_fraction,high_blood_pressure,platelets,serum_creatinine,serum_sodium,sex,smoking,time,DEATH_EVENT
|
2 |
+
42.0,1,250,1,15,0,213000.0,1.3,136,0,0,65,1
|
3 |
+
46.0,0,168,1,17,1,271000.0,2.1,124,0,0,100,1
|
4 |
+
65.0,1,160,1,20,0,327000.0,2.7,116,0,0,8,1
|
5 |
+
53.0,1,91,0,20,1,418000.0,1.4,139,0,0,43,1
|
6 |
+
50.0,1,582,1,20,1,279000.0,1.0,134,0,0,186,0
|
7 |
+
70.0,1,125,0,25,1,237000.0,1.0,140,0,0,15,1
|
8 |
+
65.0,1,52,0,25,1,276000.0,1.3,137,0,0,16,0
|
9 |
+
70.0,0,161,0,25,0,244000.0,1.2,142,0,0,66,1
|
10 |
+
60.0,1,76,1,25,0,196000.0,2.5,132,0,0,77,1
|
11 |
+
59.0,1,280,1,25,1,302000.0,1.0,141,0,0,78,1
|
12 |
+
60.0,1,156,1,25,1,318000.0,1.2,137,0,0,85,0
|
13 |
+
60.0,0,1896,1,25,0,365000.0,2.1,144,0,0,172,1
|
14 |
+
65.0,0,56,0,25,0,237000.0,5.0,130,0,0,207,0
|
15 |
+
72.0,0,211,0,25,0,274000.0,1.2,134,0,0,207,0
|
16 |
+
49.0,1,80,0,30,1,427000.0,1.0,138,0,0,12,0
|
17 |
+
65.0,1,128,1,30,1,297000.0,1.6,136,0,0,20,1
|
18 |
+
75.0,0,582,1,30,1,263358.03,1.83,134,0,0,23,1
|
19 |
+
50.0,1,159,1,30,0,302000.0,1.2,138,0,0,29,0
|
20 |
+
50.0,0,124,1,30,1,153000.0,1.2,136,0,1,32,1
|
21 |
+
57.0,1,129,0,30,0,395000.0,1.0,140,0,0,42,1
|
22 |
+
72.0,1,328,0,30,1,621000.0,1.7,138,0,1,88,1
|
23 |
+
60.0,1,582,0,30,1,127000.0,0.9,145,0,0,95,0
|
24 |
+
50.0,0,482,1,30,0,329000.0,0.9,132,0,0,109,0
|
25 |
+
65.0,0,167,0,30,0,259000.0,0.8,138,0,0,186,0
|
26 |
+
48.0,1,131,1,30,1,244000.0,1.6,130,0,0,193,1
|
27 |
+
60.0,0,166,0,30,0,62000.0,1.7,127,0,0,207,1
|
28 |
+
50.0,0,2522,0,30,1,404000.0,0.5,139,0,0,214,0
|
29 |
+
50.0,1,1051,1,30,0,232000.0,0.7,136,0,0,246,0
|
30 |
+
50.0,1,249,1,35,1,319000.0,1.0,128,0,0,28,1
|
31 |
+
62.0,0,281,1,35,0,221000.0,1.0,136,0,0,108,0
|
32 |
+
46.0,1,291,0,35,0,348000.0,0.9,140,0,0,109,0
|
33 |
+
65.0,1,335,0,35,1,235000.0,0.8,136,0,0,120,0
|
34 |
+
52.0,1,58,0,35,0,277000.0,1.4,136,0,0,120,0
|
35 |
+
50.0,1,2334,1,35,0,75000.0,0.9,142,0,0,126,1
|
36 |
+
70.0,0,835,0,35,1,305000.0,0.8,133,0,0,145,0
|
37 |
+
49.0,0,972,1,35,1,268000.0,0.8,130,0,0,187,0
|
38 |
+
55.0,0,582,1,35,1,371000.0,0.7,140,0,0,197,0
|
39 |
+
70.0,0,81,1,35,1,533000.0,1.3,139,0,0,212,0
|
40 |
+
55.0,0,572,1,35,0,231000.0,0.8,143,0,0,215,0
|
41 |
+
70.0,0,88,1,35,1,236000.0,1.2,132,0,0,215,0
|
42 |
+
70.0,0,618,0,35,0,327000.0,1.1,142,0,0,245,0
|
43 |
+
65.0,0,892,1,35,0,263358.03,1.1,142,0,0,256,0
|
44 |
+
60.0,0,235,1,38,0,329000.0,3.0,142,0,0,30,1
|
45 |
+
60.0,1,260,1,38,0,255000.0,2.2,132,0,1,45,1
|
46 |
+
58.0,0,144,1,38,1,327000.0,0.7,142,0,0,83,0
|
47 |
+
86.0,0,582,0,38,0,263358.03,1.83,134,0,0,95,1
|
48 |
+
66.0,1,68,1,38,1,162000.0,1.0,136,0,0,95,0
|
49 |
+
60.0,0,96,1,38,0,228000.0,0.75,140,0,0,95,0
|
50 |
+
80.0,0,776,1,38,1,192000.0,1.3,135,0,0,130,1
|
51 |
+
45.0,0,582,1,38,1,263358.03,1.18,137,0,0,185,0
|
52 |
+
65.0,0,326,0,38,0,294000.0,1.7,139,0,0,220,0
|
53 |
+
45.0,0,582,1,38,0,302000.0,0.9,140,0,0,244,0
|
54 |
+
67.0,0,213,0,38,0,215000.0,1.2,133,0,0,245,0
|
55 |
+
45.0,0,582,0,38,1,422000.0,0.8,137,0,0,245,0
|
56 |
+
55.0,0,84,1,38,0,451000.0,1.3,136,0,0,246,0
|
57 |
+
90.0,1,337,0,38,0,390000.0,0.9,144,0,0,256,0
|
58 |
+
55.0,0,1820,0,38,0,270000.0,1.2,139,0,0,271,0
|
59 |
+
95.0,1,112,0,40,1,196000.0,1.0,138,0,0,24,1
|
60 |
+
50.0,0,318,0,40,1,216000.0,2.3,131,0,0,60,1
|
61 |
+
70.0,0,69,0,40,0,293000.0,1.7,136,0,0,75,0
|
62 |
+
63.0,1,61,1,40,0,221000.0,1.1,140,0,0,86,0
|
63 |
+
58.0,1,400,0,40,0,164000.0,1.0,139,0,0,91,0
|
64 |
+
46.0,0,719,0,40,1,263358.03,1.18,137,0,0,107,0
|
65 |
+
61.0,1,84,0,40,1,229000.0,0.9,141,0,0,110,0
|
66 |
+
65.0,0,582,1,40,0,270000.0,1.0,138,0,0,140,0
|
67 |
+
60.667,1,151,1,40,1,201000.0,1.0,136,0,0,172,0
|
68 |
+
40.0,1,101,0,40,0,226000.0,0.8,141,0,0,187,0
|
69 |
+
60.0,1,2281,1,40,0,283000.0,1.0,141,0,0,187,0
|
70 |
+
65.0,1,720,1,40,0,257000.0,1.0,136,0,0,210,0
|
71 |
+
73.0,1,1185,0,40,1,220000.0,0.9,141,0,0,213,0
|
72 |
+
53.0,0,207,1,40,0,223000.0,1.2,130,0,0,214,0
|
73 |
+
62.0,1,655,0,40,0,283000.0,0.7,133,0,0,233,0
|
74 |
+
51.0,0,582,1,40,0,221000.0,0.9,134,0,0,244,0
|
75 |
+
55.0,0,336,0,45,1,324000.0,0.9,140,0,0,74,0
|
76 |
+
72.0,0,233,0,45,1,235000.0,2.5,135,0,0,115,1
|
77 |
+
40.0,0,244,0,45,1,275000.0,0.9,140,0,0,174,0
|
78 |
+
50.0,1,167,1,45,0,362000.0,1.0,136,0,0,187,0
|
79 |
+
82.0,1,855,1,50,1,321000.0,1.0,145,0,0,30,1
|
80 |
+
70.0,1,69,1,50,1,351000.0,1.0,134,0,0,44,1
|
81 |
+
60.0,0,53,0,50,1,286000.0,2.3,143,0,0,87,0
|
82 |
+
43.0,1,358,0,50,0,237000.0,1.3,135,0,0,97,0
|
83 |
+
49.0,1,69,0,50,0,132000.0,1.0,140,0,0,147,0
|
84 |
+
50.0,0,582,0,50,0,153000.0,0.6,134,0,0,172,1
|
85 |
+
70.0,0,1202,0,50,1,358000.0,0.9,141,0,0,196,0
|
86 |
+
48.0,1,582,1,55,0,87000.0,1.9,121,0,0,15,1
|
87 |
+
45.0,0,582,1,55,0,543000.0,1.0,132,0,0,250,0
|
88 |
+
45.0,0,615,1,55,0,222000.0,0.8,141,0,0,257,0
|
89 |
+
60.0,1,588,1,60,0,194000.0,1.1,142,0,0,33,1
|
90 |
+
70.0,0,92,0,60,1,317000.0,0.8,140,0,1,74,0
|
91 |
+
42.0,0,582,0,60,0,263358.03,1.18,137,0,0,82,0
|
92 |
+
70.0,1,59,0,60,0,255000.0,1.1,136,0,0,85,0
|
93 |
+
70.0,1,143,0,60,0,351000.0,1.3,137,0,0,90,1
|
94 |
+
60.0,1,96,1,60,1,271000.0,0.7,136,0,0,94,0
|
95 |
+
85.0,1,102,0,60,0,507000.0,3.2,138,0,0,94,0
|
96 |
+
65.0,1,113,1,60,1,203000.0,0.9,140,0,0,94,0
|
97 |
+
58.0,1,200,1,60,0,300000.0,0.8,137,0,0,104,0
|
98 |
+
65.0,1,59,1,60,0,172000.0,0.9,137,0,0,107,0
|
99 |
+
64.0,1,62,0,60,0,309000.0,1.5,135,0,0,174,0
|
100 |
+
75.0,0,675,1,60,0,265000.0,1.4,125,0,0,205,0
|
101 |
+
68.0,1,157,1,60,0,208000.0,1.0,140,0,0,237,0
|
102 |
+
45.0,0,2060,1,60,0,742000.0,0.8,138,0,0,278,0
|
103 |
+
60.0,0,3964,1,62,0,263358.03,6.8,146,0,0,43,1
|
104 |
+
65.0,0,157,0,65,0,263358.03,1.5,138,0,0,10,1
|
105 |
+
54.0,1,427,0,70,1,151000.0,9.0,137,0,0,196,1
|
106 |
+
45.0,0,582,0,80,0,263358.03,1.18,137,0,0,63,0
|
107 |
+
45.0,0,582,0,14,0,166000.0,0.8,127,1,0,14,1
|
108 |
+
75.0,1,246,0,15,0,127000.0,1.2,137,1,0,10,1
|
109 |
+
70.0,0,212,1,17,1,389000.0,1.0,136,1,1,188,0
|
110 |
+
75.0,0,582,0,20,1,265000.0,1.9,130,1,0,4,1
|
111 |
+
65.0,0,146,0,20,0,162000.0,1.3,129,1,1,7,1
|
112 |
+
50.0,1,111,0,20,0,210000.0,1.9,137,1,0,7,1
|
113 |
+
70.0,0,582,0,20,1,263358.03,1.83,134,1,1,31,1
|
114 |
+
80.0,1,553,0,20,1,140000.0,4.4,133,1,0,41,1
|
115 |
+
49.0,0,789,0,20,1,319000.0,1.1,136,1,1,55,1
|
116 |
+
72.0,0,364,1,20,1,254000.0,1.3,136,1,1,59,1
|
117 |
+
60.0,0,68,0,20,0,119000.0,2.9,127,1,1,64,1
|
118 |
+
69.0,0,582,0,20,0,266000.0,1.2,134,1,1,73,1
|
119 |
+
60.0,1,47,0,20,0,204000.0,0.7,139,1,1,73,1
|
120 |
+
59.0,0,66,1,20,0,70000.0,2.4,134,1,0,135,1
|
121 |
+
50.0,1,115,0,20,0,189000.0,0.8,139,1,0,146,0
|
122 |
+
45.0,0,582,0,20,1,126000.0,1.6,135,1,0,180,1
|
123 |
+
73.0,0,582,0,20,0,263358.03,1.83,134,1,0,198,1
|
124 |
+
55.0,0,1199,0,20,0,263358.03,1.83,134,1,1,241,1
|
125 |
+
62.0,0,231,0,25,1,253000.0,0.9,140,1,1,10,1
|
126 |
+
51.0,0,1380,0,25,1,271000.0,0.9,130,1,0,38,1
|
127 |
+
68.0,1,577,0,25,1,166000.0,1.0,138,1,0,43,1
|
128 |
+
45.0,0,7702,1,25,1,390000.0,1.0,139,1,0,60,1
|
129 |
+
72.0,1,110,0,25,0,274000.0,1.0,140,1,1,65,1
|
130 |
+
65.0,0,113,1,25,0,497000.0,1.83,135,1,0,67,1
|
131 |
+
57.0,1,115,0,25,1,181000.0,1.1,144,1,0,79,0
|
132 |
+
60.0,1,154,0,25,0,210000.0,1.7,135,1,0,82,1
|
133 |
+
63.0,1,514,1,25,1,254000.0,1.3,134,1,0,83,0
|
134 |
+
65.0,1,305,0,25,0,298000.0,1.1,141,1,0,87,0
|
135 |
+
80.0,0,898,0,25,0,149000.0,1.1,144,1,1,87,0
|
136 |
+
50.0,0,369,1,25,0,252000.0,1.6,136,1,0,90,0
|
137 |
+
68.0,1,646,0,25,0,305000.0,2.1,130,1,0,108,0
|
138 |
+
72.0,1,943,0,25,1,338000.0,1.7,139,1,1,111,1
|
139 |
+
60.0,1,231,1,25,0,194000.0,1.7,140,1,0,120,0
|
140 |
+
50.0,0,250,0,25,0,262000.0,1.0,136,1,1,120,0
|
141 |
+
59.0,1,176,1,25,0,221000.0,1.0,136,1,1,150,1
|
142 |
+
65.0,0,395,1,25,0,265000.0,1.2,136,1,1,154,1
|
143 |
+
58.0,1,145,0,25,0,219000.0,1.2,137,1,1,170,1
|
144 |
+
60.0,0,59,0,25,1,212000.0,3.5,136,1,1,187,0
|
145 |
+
47.0,0,582,0,25,0,130000.0,0.8,134,1,0,201,0
|
146 |
+
58.0,0,582,1,25,0,504000.0,1.0,138,1,0,205,0
|
147 |
+
58.0,1,57,0,25,0,189000.0,1.3,132,1,1,205,0
|
148 |
+
55.0,0,2017,0,25,0,314000.0,1.1,138,1,0,214,1
|
149 |
+
64.0,0,143,0,25,0,246000.0,2.4,135,1,0,214,0
|
150 |
+
45.0,1,66,1,25,0,233000.0,0.8,135,1,0,230,0
|
151 |
+
65.0,1,258,1,25,0,198000.0,1.4,129,1,0,235,1
|
152 |
+
45.0,1,981,0,30,0,136000.0,1.1,137,1,0,11,1
|
153 |
+
82.0,0,70,1,30,0,200000.0,1.2,132,1,1,26,1
|
154 |
+
60.0,0,2656,1,30,0,305000.0,2.3,137,1,0,30,0
|
155 |
+
95.0,1,371,0,30,0,461000.0,2.0,132,1,0,50,1
|
156 |
+
42.0,0,5209,0,30,0,226000.0,1.0,140,1,1,87,0
|
157 |
+
61.0,0,248,0,30,1,267000.0,0.7,136,1,1,104,0
|
158 |
+
50.0,0,1548,0,30,1,211000.0,0.8,138,1,0,108,0
|
159 |
+
50.0,0,185,0,30,0,266000.0,0.7,141,1,1,112,0
|
160 |
+
52.0,0,132,0,30,0,218000.0,0.7,136,1,1,112,0
|
161 |
+
75.0,1,582,0,30,0,225000.0,1.83,134,1,0,113,1
|
162 |
+
45.0,0,2442,1,30,0,334000.0,1.1,139,1,0,129,1
|
163 |
+
40.0,0,478,1,30,0,303000.0,0.9,136,1,0,148,0
|
164 |
+
60.667,1,104,1,30,0,389000.0,1.5,136,1,0,171,1
|
165 |
+
73.0,1,231,1,30,0,160000.0,1.18,142,1,1,180,0
|
166 |
+
70.0,0,232,0,30,0,173000.0,1.2,132,1,0,210,0
|
167 |
+
65.0,0,582,1,30,0,249000.0,1.3,136,1,1,212,0
|
168 |
+
52.0,1,191,1,30,1,334000.0,1.0,142,1,1,216,0
|
169 |
+
44.0,0,582,1,30,1,263358.03,1.6,130,1,1,244,0
|
170 |
+
60.0,1,257,1,30,0,150000.0,1.0,137,1,1,245,0
|
171 |
+
42.0,0,64,0,30,0,215000.0,3.8,128,1,1,250,0
|
172 |
+
80.0,1,123,0,35,1,388000.0,9.4,133,1,1,10,1
|
173 |
+
68.0,1,220,0,35,1,289000.0,0.9,140,1,1,20,1
|
174 |
+
69.0,0,582,1,35,0,228000.0,3.5,134,1,0,30,1
|
175 |
+
70.0,1,75,0,35,0,223000.0,2.7,138,1,1,54,0
|
176 |
+
55.0,0,109,0,35,0,254000.0,1.1,139,1,1,60,0
|
177 |
+
45.0,0,582,0,35,0,385000.0,1.0,145,1,0,61,1
|
178 |
+
58.0,0,582,1,35,0,122000.0,0.9,139,1,1,71,0
|
179 |
+
85.0,0,5882,0,35,0,243000.0,1.0,132,1,1,72,1
|
180 |
+
55.0,0,47,0,35,1,173000.0,1.1,137,1,0,79,0
|
181 |
+
45.0,1,1876,1,35,0,226000.0,0.9,138,1,0,88,0
|
182 |
+
45.0,0,292,1,35,0,850000.0,1.3,142,1,1,88,0
|
183 |
+
55.0,0,60,0,35,0,228000.0,1.2,135,1,1,90,0
|
184 |
+
53.0,1,270,1,35,0,227000.0,3.4,145,1,0,105,0
|
185 |
+
81.0,0,4540,0,35,0,231000.0,1.18,137,1,1,107,0
|
186 |
+
60.0,0,2261,0,35,1,228000.0,0.9,136,1,0,115,0
|
187 |
+
50.0,0,1846,1,35,0,263358.03,1.18,137,1,1,119,0
|
188 |
+
45.0,1,130,0,35,0,174000.0,0.8,139,1,1,121,0
|
189 |
+
51.0,1,582,1,35,0,263358.03,1.5,136,1,1,145,0
|
190 |
+
65.0,0,198,1,35,1,281000.0,0.9,137,1,1,146,0
|
191 |
+
80.0,0,582,1,35,0,350000.0,2.1,134,1,0,174,0
|
192 |
+
60.0,0,1211,1,35,0,263358.03,1.8,113,1,1,186,0
|
193 |
+
65.0,1,135,0,35,1,290000.0,0.8,134,1,0,194,0
|
194 |
+
73.0,0,582,0,35,1,203000.0,1.3,134,1,0,195,0
|
195 |
+
68.0,1,1021,1,35,0,271000.0,1.1,134,1,0,197,0
|
196 |
+
42.0,1,86,0,35,0,365000.0,1.1,139,1,1,201,0
|
197 |
+
55.0,1,2794,0,35,1,141000.0,1.0,140,1,0,206,0
|
198 |
+
70.0,0,93,0,35,0,185000.0,1.1,134,1,1,208,0
|
199 |
+
40.0,1,129,0,35,0,255000.0,0.9,137,1,0,209,0
|
200 |
+
40.0,0,90,0,35,0,255000.0,1.1,136,1,1,212,0
|
201 |
+
40.0,0,624,0,35,0,301000.0,1.0,142,1,1,214,0
|
202 |
+
50.0,1,298,0,35,0,362000.0,0.9,140,1,1,240,0
|
203 |
+
40.0,0,582,1,35,0,222000.0,1.0,132,1,0,244,0
|
204 |
+
60.0,0,253,0,35,0,279000.0,1.7,140,1,0,250,0
|
205 |
+
60.0,0,320,0,35,0,133000.0,1.4,139,1,0,258,0
|
206 |
+
63.0,1,103,1,35,0,179000.0,0.9,136,1,1,270,0
|
207 |
+
55.0,0,7861,0,38,0,263358.03,1.1,136,1,0,6,1
|
208 |
+
75.0,1,81,0,38,1,368000.0,4.0,131,1,1,10,1
|
209 |
+
50.0,1,168,0,38,1,276000.0,1.1,137,1,0,11,1
|
210 |
+
87.0,1,149,0,38,0,262000.0,0.9,140,1,0,14,1
|
211 |
+
80.0,0,148,1,38,0,149000.0,1.9,144,1,1,23,1
|
212 |
+
58.0,1,60,0,38,0,153000.0,5.8,134,1,0,26,1
|
213 |
+
94.0,0,582,1,38,1,263358.03,1.83,134,1,0,27,1
|
214 |
+
50.0,0,582,1,38,0,310000.0,1.9,135,1,1,35,1
|
215 |
+
60.0,0,582,1,38,1,451000.0,0.6,138,1,1,40,1
|
216 |
+
75.0,1,203,1,38,1,283000.0,0.6,131,1,1,74,0
|
217 |
+
63.0,0,936,0,38,0,304000.0,1.1,133,1,1,88,0
|
218 |
+
80.0,0,805,0,38,0,263358.03,1.1,134,1,0,109,1
|
219 |
+
75.0,0,99,0,38,1,224000.0,2.5,134,1,0,162,1
|
220 |
+
85.0,0,212,0,38,0,186000.0,0.9,136,1,0,187,0
|
221 |
+
53.0,1,707,0,38,0,330000.0,1.4,137,1,1,209,0
|
222 |
+
54.0,0,582,1,38,0,264000.0,1.8,134,1,0,213,0
|
223 |
+
61.0,1,80,1,38,0,282000.0,1.4,137,1,0,213,0
|
224 |
+
58.0,0,132,1,38,1,253000.0,1.0,139,1,0,230,0
|
225 |
+
61.0,0,582,1,38,0,147000.0,1.2,141,1,0,237,0
|
226 |
+
56.0,1,135,1,38,0,133000.0,1.7,140,1,0,244,0
|
227 |
+
70.0,0,582,1,38,0,25100.0,1.1,140,1,0,246,0
|
228 |
+
65.0,0,1688,0,38,0,263358.03,1.1,138,1,1,250,0
|
229 |
+
52.0,0,190,1,38,0,382000.0,1.0,140,1,1,258,0
|
230 |
+
62.0,0,61,1,38,1,155000.0,1.1,143,1,1,270,0
|
231 |
+
45.0,0,2413,0,38,0,140000.0,1.4,140,1,1,280,0
|
232 |
+
90.0,1,47,0,40,1,204000.0,2.1,132,1,1,8,1
|
233 |
+
60.0,1,607,0,40,0,216000.0,0.6,138,1,1,54,0
|
234 |
+
41.0,0,148,0,40,0,374000.0,0.8,140,1,1,68,0
|
235 |
+
42.0,0,102,1,40,0,237000.0,1.2,140,1,0,74,0
|
236 |
+
44.0,0,84,1,40,1,235000.0,0.7,139,1,0,79,0
|
237 |
+
60.0,1,754,1,40,1,328000.0,1.2,126,1,0,91,0
|
238 |
+
60.0,0,582,0,40,0,217000.0,3.7,134,1,0,96,1
|
239 |
+
75.0,0,582,0,40,0,263358.03,1.18,137,1,0,107,0
|
240 |
+
66.0,1,72,0,40,1,242000.0,1.2,134,1,0,121,0
|
241 |
+
63.0,1,582,0,40,0,448000.0,0.9,137,1,1,123,0
|
242 |
+
52.0,0,3966,0,40,0,325000.0,0.9,140,1,1,146,0
|
243 |
+
69.0,0,1419,0,40,0,105000.0,1.0,135,1,1,147,0
|
244 |
+
55.0,0,835,0,40,0,279000.0,0.7,140,1,1,147,0
|
245 |
+
50.0,1,121,1,40,0,260000.0,0.7,130,1,0,175,0
|
246 |
+
78.0,1,64,0,40,0,277000.0,0.7,137,1,1,187,0
|
247 |
+
55.0,0,66,0,40,0,203000.0,1.0,138,1,0,233,0
|
248 |
+
42.0,0,64,0,40,0,189000.0,0.7,140,1,0,245,0
|
249 |
+
70.0,0,2695,1,40,0,241000.0,1.0,137,1,0,247,0
|
250 |
+
70.0,0,582,0,40,0,51000.0,2.7,136,1,1,250,0
|
251 |
+
50.0,1,54,0,40,0,279000.0,0.8,141,1,0,250,0
|
252 |
+
55.0,1,170,1,40,0,336000.0,1.2,135,1,0,250,0
|
253 |
+
70.0,0,122,1,45,1,284000.0,1.3,136,1,1,26,1
|
254 |
+
85.0,0,23,0,45,0,360000.0,3.0,132,1,0,28,1
|
255 |
+
70.0,0,571,1,45,1,185000.0,1.2,139,1,1,33,1
|
256 |
+
70.0,0,66,1,45,0,249000.0,0.8,136,1,1,80,0
|
257 |
+
60.0,0,897,1,45,0,297000.0,1.0,133,1,0,80,0
|
258 |
+
75.0,0,582,0,45,1,263358.03,1.18,137,1,0,87,0
|
259 |
+
55.0,0,748,0,45,0,263000.0,1.3,137,1,0,88,0
|
260 |
+
60.0,1,1082,1,45,0,250000.0,6.1,131,1,0,107,0
|
261 |
+
50.0,0,115,0,45,1,184000.0,0.9,134,1,1,118,0
|
262 |
+
59.0,1,129,0,45,1,362000.0,1.1,139,1,1,121,0
|
263 |
+
77.0,1,418,0,45,0,223000.0,1.8,145,1,0,180,1
|
264 |
+
63.0,1,1767,0,45,0,73000.0,0.7,137,1,0,186,0
|
265 |
+
53.0,1,582,0,45,0,305000.0,1.1,137,1,1,209,0
|
266 |
+
55.0,1,180,0,45,0,263358.03,1.18,137,1,1,211,0
|
267 |
+
50.0,0,245,0,45,1,274000.0,1.0,133,1,0,215,0
|
268 |
+
50.0,0,196,0,45,0,395000.0,1.6,136,1,1,285,0
|
269 |
+
82.0,1,379,0,50,0,47000.0,1.3,136,1,0,13,1
|
270 |
+
65.0,0,94,1,50,1,188000.0,1.0,140,1,0,29,1
|
271 |
+
90.0,1,60,1,50,0,226000.0,1.0,134,1,0,30,1
|
272 |
+
72.0,0,127,1,50,1,218000.0,1.0,134,1,0,33,0
|
273 |
+
65.0,0,224,1,50,0,149000.0,1.3,137,1,1,72,0
|
274 |
+
67.0,0,582,0,50,0,263358.03,1.18,137,1,1,76,0
|
275 |
+
79.0,1,55,0,50,1,172000.0,1.8,133,1,0,78,0
|
276 |
+
51.0,0,78,0,50,0,406000.0,0.7,140,1,0,79,0
|
277 |
+
85.0,1,910,0,50,0,235000.0,1.3,134,1,0,121,0
|
278 |
+
78.0,0,224,0,50,0,481000.0,1.4,138,1,1,192,0
|
279 |
+
65.0,0,118,0,50,0,194000.0,1.1,145,1,1,200,0
|
280 |
+
77.0,1,109,0,50,1,406000.0,1.1,137,1,0,209,0
|
281 |
+
75.0,0,119,0,50,1,248000.0,1.1,148,1,0,209,0
|
282 |
+
53.0,0,56,0,50,0,308000.0,0.7,135,1,1,231,0
|
283 |
+
60.0,1,315,1,60,0,454000.0,1.1,131,1,1,10,1
|
284 |
+
53.0,0,63,1,60,0,368000.0,0.8,135,1,0,22,0
|
285 |
+
65.0,1,68,1,60,1,304000.0,0.8,140,1,0,79,0
|
286 |
+
58.0,1,133,0,60,1,219000.0,1.0,141,1,0,83,0
|
287 |
+
85.0,0,129,0,60,0,306000.0,1.2,132,1,1,90,1
|
288 |
+
60.0,1,737,0,60,1,210000.0,1.5,135,1,1,95,0
|
289 |
+
53.0,1,1808,0,60,1,249000.0,0.7,138,1,1,106,0
|
290 |
+
63.0,0,193,0,60,1,295000.0,1.3,145,1,1,107,0
|
291 |
+
64.0,0,1610,0,60,0,242000.0,1.0,137,1,0,113,0
|
292 |
+
62.0,0,30,1,60,1,244000.0,0.9,139,1,0,117,0
|
293 |
+
53.0,0,196,0,60,0,220000.0,0.7,133,1,1,134,0
|
294 |
+
70.0,1,171,0,60,1,176000.0,1.1,145,1,1,146,0
|
295 |
+
60.0,1,95,0,60,0,337000.0,1.0,138,1,1,146,0
|
296 |
+
63.0,1,122,1,60,0,267000.0,1.2,145,1,0,147,0
|
297 |
+
45.0,0,308,1,60,1,377000.0,1.0,136,1,0,186,0
|
298 |
+
70.0,0,97,0,60,1,220000.0,0.9,138,1,0,186,0
|
299 |
+
53.0,1,446,0,60,1,263358.03,1.0,139,1,0,215,0
|
300 |
+
50.0,0,582,0,62,1,147000.0,0.8,140,1,1,192,0
|
prediction.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
import pickle
|
5 |
+
import json
|
6 |
+
# Load All Files
|
7 |
+
|
8 |
+
with open('rf_gridcv_best.pkl', 'rb') as file_1:
|
9 |
+
rf_gridcv_best = pickle.load(file_1)
|
10 |
+
|
11 |
+
with open('Drop_Columns.txt', 'r') as file_2:
|
12 |
+
Drop_Columns = json.load(file_2)
|
13 |
+
|
14 |
+
def run():
|
15 |
+
with st.form(key='form_fifa_2022'):
|
16 |
+
age = st.number_input('age',min_value=0,max_value=99,value=55,step=1,help='Age of Patients')
|
17 |
+
anemia = st.number_input('Have Anemia ? ',min_value=0, max_value=1,value=0,help='0 for No, 1 for Yes')
|
18 |
+
creatinine_phosphokinase = st.number_input('Level of the CPK enzyme in the blood',min_value=0,max_value=9999,value=600)
|
19 |
+
diabetes = st.number_input('Have Diabetes?',min_value=0,max_value=1000000000,value=0,help='0 for No, 1 for Yes')
|
20 |
+
ejection_fraction = st.number_input('Percentage of blood leaving the heart at each contraction (%)',min_value=0,max_value=100,value=38)
|
21 |
+
high_blood_pressure = st.number_input('Have Diabetes?',min_value=0,max_value=1,value=0,help='0 for No, 1 for Yes')
|
22 |
+
platelets = st.number_input('Platelets in the blood (kiloplatelets/mL)',min_value=0,max_value=999999,value=0,help='in kiloplatelets/mL')
|
23 |
+
serum_creatinine = st.number_input('Level of serum creatinine in the blood ',min_value=0,max_value=10,value=0,help='in mg/dL')
|
24 |
+
serum_sodium = st.number_input('Level of serum sodium in the blood',min_value=0,max_value=150,value=0,help='in mEq/dL')
|
25 |
+
sex = st.number_input('Gender',min_value=0,max_value=1,value=0,help='(Female = 0, Male = 1)')
|
26 |
+
smoking = st.number_input('Smoker or Not Smoker ?',min_value=0,max_value=1,value=0,help='(No= 0, Yes = 1)')
|
27 |
+
time = st.number_input('Follow Up Period',min_value=0,max_value=285,value=0,help='in Days')
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
submitted = st.form_submit_button(' Still Alive or Not ?')
|
32 |
+
|
33 |
+
df_inf = {
|
34 |
+
'age': age,
|
35 |
+
'anaemia': anemia,
|
36 |
+
'creatinine_phosphokinase': creatinine_phosphokinase,
|
37 |
+
'diabetes': diabetes,
|
38 |
+
'ejection_fraction': ejection_fraction,
|
39 |
+
'high_blood_pressure': high_blood_pressure,
|
40 |
+
'platelets': platelets,
|
41 |
+
'serum_creatinine': serum_creatinine,
|
42 |
+
'serum_sodium': serum_sodium,
|
43 |
+
'sex': sex,
|
44 |
+
'smoking': smoking,
|
45 |
+
'time':time
|
46 |
+
}
|
47 |
+
df_inf = pd.DataFrame([df_inf])
|
48 |
+
# Data Inference
|
49 |
+
df_inf_copy = df_inf.copy()
|
50 |
+
df_inf_copy
|
51 |
+
|
52 |
+
# Removing unnecessary features
|
53 |
+
df_inf_final = df_inf_copy.drop(Drop_Columns,axis=1).sort_index()
|
54 |
+
df_inf_final
|
55 |
+
|
56 |
+
st.dataframe(df_inf_final)
|
57 |
+
|
58 |
+
if submitted:
|
59 |
+
# Predict using RandomForest
|
60 |
+
y_pred_inf = rf_gridcv_best.predict(df_inf_final)
|
61 |
+
st.write('# Still Alive or Not ? (0 = Alive, 1 = Deceased) ',str(int(y_pred_inf)))
|
62 |
+
|
63 |
+
if __name__ == '__main__':
|
64 |
+
run()
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pandas
|
3 |
+
seaborn
|
4 |
+
matplotlib
|
5 |
+
numpy
|
6 |
+
scikit-learn==1.2.1
|
7 |
+
imbalanced-learn==0.10.1
|
8 |
+
plotly
|
rf_gridcv_best.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:da094101619cb3174b40fff2ac748a76514cedbc731035ea8d9330f29e2e6a22
|
3 |
+
size 67133
|