Datasets:
Chandan Singh
commited on
Commit
•
36991cb
1
Parent(s):
b5867a5
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Port of the diabetes-readmission dataset from UCI (link [here](https://archive.ics.uci.edu/ml/datasets/diabetes+130-us+hospitals+for+years+1999-2008)). See details there and use carefully.
|
2 |
+
|
3 |
+
Basic preprocessing done by the [imodels team](https://github.com/csinva/imodels) in [this notebook](https://github.com/csinva/imodels-data/blob/master/notebooks_fetch_data/00_get_datasets_custom.ipynb).
|
4 |
+
|
5 |
+
The target is the binary outcome `readmitted`.
|
6 |
+
|
7 |
+
### Sample usage
|
8 |
+
|
9 |
+
Load the data:
|
10 |
+
|
11 |
+
```
|
12 |
+
from datasets import load_dataset
|
13 |
+
|
14 |
+
dataset = load_dataset("imodels/diabetes-readmission")
|
15 |
+
df = pd.DataFrame(dataset['train'])
|
16 |
+
X = df.drop(columns=['is_recid'])
|
17 |
+
y = df['readmitted'].values
|
18 |
+
```
|
19 |
+
|
20 |
+
Fit a model:
|
21 |
+
|
22 |
+
```
|
23 |
+
import imodels
|
24 |
+
import numpy as np
|
25 |
+
|
26 |
+
m = imodels.FIGSClassifier(max_rules=5)
|
27 |
+
m.fit(X, y)
|
28 |
+
print(m)
|
29 |
+
```
|
30 |
+
|
31 |
+
|
32 |
+
Evaluate:
|
33 |
+
|
34 |
+
|
35 |
+
```
|
36 |
+
df_test = pd.DataFrame(dataset['test'])
|
37 |
+
X_test = df.drop(columns=['readmitted'])
|
38 |
+
y_test = df['is_recid'].values
|
39 |
+
print('accuracy', np.mean(m.predict(X_test) == y_test))
|
40 |
+
```
|