csinva / imodels

Interpretable ML package 🔍 for concise, transparent, and accurate predictive modeling (sklearn-compatible).
https://csinva.io/imodels
MIT License
1.36k stars 121 forks source link

Two Extractly same rules by RulefitClassifier #80

Closed Yannahhh closed 2 years ago

Yannahhh commented 2 years ago

Hello~

When I use the RulefitClassifier, it will return two exactly same rules but with different coef, whether the inherent structures didn't aggregate the rules? I have tried to use the Rulefit directly, and it seems that it doesn't have the similar problem~

The following image is part of my result

image
keyan3 commented 2 years ago

Hi, thanks for bringing this to our attention. Can you provide more details on the code used to produce this result?

Yannahhh commented 2 years ago

Thanks for your reply, should I provide my data also?

features = X.columns X = X.values rulefit = RuleFitClassifier(random_state=2022, tree_size=3, exp_rand_tree_size=False) rulefit.fit(X, y, feature_names=features) preds = rulefit.predict(X) accuracy = round(metrics.accuracy_score(y, preds), 2) rules = rulefit.get_rules() rules = rules[rules.coef != 0].sort_values("coef", ascending=False)

keyan3 commented 2 years ago

No need to provide the data — this is caused by a bug in the process of checking for duplicate rules (https://github.com/csinva/imodels/blob/master/imodels/util/extract.py#L97-L107). We will have it fixed shortly!

keyan3 commented 2 years ago

Was fixed in #87