-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules list cutoffs are not printed in string representations of GreedyRulesListClassifier #169
Comments
davidefiocco
changed the title
Rules list cutoffs are not printed in string representations of GreedyRulesList classifier
Rules list cutoffs are not printed in string representations of GreedyRulesListClassifier
Mar 15, 2023
A possible improvement would be reworking the def __str__(self):
'''Print out the list in a nice way
'''
header = '> ------------------------------\n> Greedy Rule List\n> ------------------------------\n'
footer = '> ------------------------------\n'
rule_template = '> {condition} => {risk}% risk ({num_pts} pts)\n'
s = header
for i in range(len(self.rules_)):
rule = self.rules_[i]
condition = 'else'
risk = (100 * rule['val']).round(2)
num_pts = rule['num_pts']
if 'col' in rule:
predicate = '>=' if not rule['flip'] else '<'
if i == 0:
condition = f"if {rule['col']} {predicate} {rule['cutoff']}"
else:
condition = f"else if {rule['col']} {predicate} {rule['cutoff']}"
risk = (100 * rule['val_right']).round(2)
num_pts = rule['num_pts_right']
s += rule_template.format(
condition=condition,
risk=risk,
num_pts=num_pts
)
s += footer
return s Which would render rules such as
as
|
Thanks, this is a nice fix! I'll work on making it so that it displays like this if the feature is continuous-valued and keeps the original behavior for non-continuous features. Probably also worth rounding the cutoff value to ~3 decimal places. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When training
GreedyRulesListClassifier
on float features, and the fitted classiferclf
is printed, cutoff values are not shown, thus making the interpretation of the model a bit confusing. Here's an example:Trying to render the model with
print(clf)
yields something along the lines ofwhich I find confusing because
x1
andx2
are floats, not booleans.clf.rules_
are insteadand contain a cutoff that is useful for model interpretation. I don't know exactly what would be the desired intended behavior, as at the moment the code starting at
imodels/imodels/rule_list/greedy_rule_list.py
Lines 143 to 184 in 1243240
The text was updated successfully, but these errors were encountered: