Chandan Singh commited on
Commit
63f215c
1 Parent(s): 62bd092

show sample usage

Browse files
Files changed (1) hide show
  1. README.md +36 -1
README.md CHANGED
@@ -20,4 +20,39 @@ Port of the compas-recidivism dataset from propublica (github [here](https://git
20
 
21
  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).
22
 
23
- The target is the binary outcome `is_recid`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  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).
22
 
23
+ The target is the binary outcome `is_recid`.
24
+
25
+ ### Sample usage
26
+
27
+ Load the data:
28
+
29
+ ```
30
+ from datasets import load_dataset
31
+
32
+ dataset = load_dataset("imodels/compas-recidivism")
33
+ df = pd.DataFrame(dataset['train'])
34
+ X = df.drop(columns=['is_recid'])
35
+ y = df['is_recid'].values
36
+ ```
37
+
38
+ Fit a model:
39
+
40
+ ```
41
+ import imodels
42
+ import numpy as np
43
+
44
+ m = imodels.FIGSClassifier(max_rules=5)
45
+ m.fit(X, y)
46
+ print(m)
47
+ ```
48
+
49
+
50
+ Evaluate:
51
+
52
+
53
+ ```
54
+ df_test = pd.DataFrame(dataset['test'])
55
+ X_test = df.drop(columns=['is_recid'])
56
+ y_test = df['is_recid'].values
57
+ print('accuracy', np.mean(m.predict(X_test) == y_test))
58
+ ```