-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconverted.py
93 lines (68 loc) · 3.67 KB
/
converted.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import marimo
__generated_with = "0.9.14"
app = marimo.App()
@app.cell
def __():
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import LabelEncoder, StandardScaler
import xgboost as xgb
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report
return (
LabelEncoder,
StandardScaler,
accuracy_score,
classification_report,
np,
pd,
plt,
sns,
train_test_split,
xgb,
)
@app.cell
def __(pd):
df = pd.read_csv('alzheimers_disease_data.csv')
df.head()
return (df,)
@app.cell
def __(df):
df.info()
return
@app.cell
def __(df):
df_1 = df.drop('DoctorInCharge', axis=1)
return (df_1,)
@app.cell
def __(df_1):
X = df_1.drop('Diagnosis', axis=1)
y = df_1['Diagnosis']
return X, y
@app.cell
def __(X, train_test_split, y):
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42, test_size=0.2)
return X_test, X_train, y_test, y_train
@app.cell
def __(StandardScaler, X_test, X_train):
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
return X_test_scaled, X_train_scaled, scaler
@app.cell
def __(X_train_scaled, xgb, y_train):
model = xgb.XGBClassifier()
model.fit(X_train_scaled, y_train, verbose=True)
return (model,)
@app.cell
def __(X_test_scaled, model):
y_pred = model.predict(X_test_scaled)
return (y_pred,)
@app.cell
def __(accuracy_score, y_pred, y_test):
accuracy_score(y_test, y_pred)
return
if __name__ == "__main__":
app.run()