Skip to content

Instantly share code, notes, and snippets.

@ogyalcin
Last active June 24, 2021 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogyalcin/ad0b796b4a43b0a56db34705a2eaea39 to your computer and use it in GitHub Desktop.
Save ogyalcin/ad0b796b4a43b0a56db34705a2eaea39 to your computer and use it in GitHub Desktop.
pd.set_option('display.max_colwidth', 400) # Adjust row width to read the entire rule
pd.options.display.float_format = '{:.2f}'.format # Round decimals to 2 decimal places
rules = rulefit.get_rules() # Get the rules
rules = rules[rules['type']!='linear'] # Eliminate the existing explanatory variables
rules = rules[rules['coef'] != 0] # eliminate the insignificant rules
rules = rules.sort_values('support', ascending=False) # Sort the rules based on "support" value
rules = rules[rules['rule'].str.len()>30] # optional: To see more complex rules, filter the long rules
rules.iloc[0:5] # Show the first 5 rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment