tmadl / sklearn-expertsys

Highly interpretable classifiers for scikit learn, producing easily understood decision rules instead of black box models
488 stars 72 forks source link

class1label is actually the 0 class #6

Closed kenben closed 8 years ago

kenben commented 8 years ago

I think class1label actually labels the 0 class:

from RuleListClassifier import *
import numpy as np
status = np.array([['dead','dead','dead','dead',
                    'alive','alive','alive','alive']]).T
isAlive = np.array( [0, 0, 0, 0, 1, 1, 1, 1])
model = RuleListClassifier(class1label="is_alive")
model.fit(status, isAlive, feature_labels=["status"])
print model

Output:

2 rules mined
Starting mcmc chains
Elapsed CPU time 8.980171
Rhat for convergence: 0.999981686696
Posterior average length: 2.48247263224
Posterior average width: 1.0
Trained RuleListClassifier for detecting is_alive
==================================================
IF dead THEN probability of is_alive: 83.3% (47.8%-99.5%)
ELSE probability of is_alive: 16.7% (0.5%-52.2%)
=================================================

You can also see this when looking at the diabetes example data set, and exploring the relationship between the features and labels.

tmadl commented 8 years ago

Thanks a lot for pointing this out! The issue was the confusing "class1label" parameter, which actually labels the first class, that is, the one with y=0. I have fixed the parameter name and the documentation. The examples are correct and consistent now