Inferensys

Glossary

RuleFit

RuleFit is an algorithm that creates a sparse linear model combining simple, interpretable rules generated from decision trees with original features to provide both predictive accuracy and model transparency.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
SPARSE LINEAR INTERPRETABILITY

What is RuleFit?

RuleFit is an algorithm that creates a sparse linear model combining simple, interpretable rules generated from decision trees with original features to provide both predictive accuracy and model transparency.

RuleFit is a predictive modeling algorithm that generates a sparse linear model by combining two distinct feature types: the original input features and a set of binary rules extracted from the nodes of an ensemble of decision trees. The algorithm first trains a tree ensemble, such as a gradient boosted tree or random forest, and then decomposes each tree into a collection of conjunctive rules representing paths from the root to a leaf. These rules, along with the original features, become inputs to a LASSO-regularized linear model, which automatically selects the most predictive rules while shrinking irrelevant coefficients to zero.

The resulting model balances the high accuracy of tree ensembles with the intrinsic interpretability of a linear model. Each selected rule is a human-readable conditional statement, such as 'transaction_amount > 10,000 AND account_age < 30 days,' making it ideal for generating adverse action reason codes in regulated financial fraud detection. By controlling the sparsity penalty, compliance officers can tune the trade-off between model complexity and explainability, ensuring that anomaly scores are auditable and justifiable to regulators while maintaining robust detection of sophisticated fraud patterns.

Algorithmic Architecture

Key Features of RuleFit

RuleFit creates a sparse linear model that combines tree-derived decision rules with original features, balancing predictive accuracy with full model transparency for high-stakes fraud detection.

01

Sparse Linear Combination

RuleFit constructs a generalized linear model where the predictors are both the original input features and a set of binary rule indicators extracted from decision tree ensembles. The model applies L1 (Lasso) regularization during training, which drives many coefficients to exactly zero. This produces a sparse final model—typically retaining only 15-50 of the most predictive rules and features—making the entire decision function auditable without sacrificing the non-linear pattern detection of tree-based methods.

02

Tree-Derived Rule Generation

Rules are harvested from an ensemble of gradient boosted trees or random forests. Each node in a tree translates to a conjunctive rule:

  • Rule format: IF (feature_A <= threshold) AND (feature_B > value) THEN rule_fires = 1
  • Rule depth: Typically limited to 2-4 splits to maintain interpretability
  • Rule diversity: Hundreds of candidate rules are generated, then the Lasso selects only the most globally predictive subset This approach captures non-linear interactions and threshold effects that linear models alone miss.
03

Feature Importance Ranking

Because the final model is a linear combination, the absolute coefficient value of each rule or feature directly quantifies its contribution to the prediction. This provides:

  • Global importance: Which rules and features matter most across all predictions
  • Local importance: For any single transaction, the fired rules with non-zero coefficients explain exactly why a specific score was assigned
  • Directionality: Positive coefficients push toward fraud, negative toward legitimate This eliminates the need for post-hoc explanation tools like SHAP or LIME for the final model.
04

Winzorization of Feature Inputs

To handle outlier transactions common in financial data, RuleFit applies winsorization to original features before rule generation. Extreme values beyond specified percentiles (e.g., 1st and 99th) are capped rather than removed. This prevents:

  • Rule fragmentation: Outliers creating overly specific, low-coverage rules
  • Coefficient instability: Single extreme transactions distorting the Lasso penalty
  • Overfitting: The model memorizing rare anomalies instead of learning generalizable fraud patterns
05

Interaction Detection Without Specification

Unlike traditional regression where interaction terms must be explicitly engineered, RuleFit automatically discovers feature interactions through the tree ensemble. A single rule like IF (transaction_amount > $10,000) AND (account_age_days < 30) captures a two-way interaction. The Lasso then selects only the interactions that improve predictive performance. This is critical for fraud detection where contextual anomalies—combinations of otherwise normal values—are the primary signal.

06

Base Learner Integration

The final model includes both rule terms and linear terms for original features, allowing it to:

  • Capture non-linearities through rules derived from tree splits
  • Retain linear relationships where a simple monotonic effect exists (e.g., higher transaction amount linearly increases risk)
  • Handle mixed signal types: Rules excel at threshold-based categorical patterns; linear terms handle continuous gradients This dual representation ensures the model is neither unnecessarily complex where a linear relationship suffices nor blind to interactions where they matter.
UNDERSTANDING RULEFIT

Frequently Asked Questions

Clear, technical answers to the most common questions about the RuleFit algorithm, its mechanics, and its role in building transparent, high-performance fraud detection models.

RuleFit is a predictive modeling algorithm that creates a sparse linear model combining two component types: a set of simple, interpretable decision rules extracted from tree ensembles, and the original raw input features. It works in two stages. First, a tree ensemble (typically a gradient boosted tree model) is trained to capture complex, non-linear relationships and interactions. From this ensemble, a large number of candidate rules are generated by traversing paths from the root to terminal nodes. Second, a sparse linear model (often Lasso or L1-regularized logistic regression) is fit on a feature matrix that includes both the original features and the binary rule features. The L1 regularization automatically selects the most predictive rules and features, driving most coefficients to zero. The final model is a weighted sum of the surviving rules and linear terms, making it both accurate and interpretable.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.