> For the complete documentation index, see [llms.txt](https://maheshwarappa-a.gitbook.io/explainable-ai-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maheshwarappa-a.gitbook.io/explainable-ai-1/implementation-of-these-techniques-on-different-models/untitled.md).

# Random Forest - LIME

[Code Implementation Here](https://colab.research.google.com/drive/1MeTcEe5bV2eFPoxQZ1jtfX0MXhc7a4kb?usp=sharing)

### **What is a Random Forest?**

* Random Forest is an ensemble learning method used for classification and regression&#x20;
* Random Forests are a modification of bagging technique that builds a large collection of non-correlated trees and then averages them
* This technique is sometimes even called "feature bagging".

### **Making the Model**

**Dataset:** Automotive marketing  ; **Target:** Customer lifetime value

The data is passed through pre-processing and then trained using Scikit learn Library with RandomForestRegressor function.

**R2 score:** 0.70

### **Implementation of Interpretability**

For this model we will be using LIME for interpretation. In particular, we use the LimeTabularExplainer which is part of the open source lime package.

![](/files/-MEfVeTNOpZiS0Ne9grL)

We feed some data as shown above and then request the explainer to generate an explanation for a particular row. In the code, we have generated an explanation for 4th row and kept a cap on the number of features as 6.

![](/files/-MEfWn1lF6dgoZ-6Etlh)

### Visualizations

**Row Prediction**

![Predicted Customer Lifetime Value](/files/-MEfX9q90zRfUMwp4_8N)

**Positive/Negative Effects**

![](/files/-MEfXNOUJg-RbQLjh90k)

The above plot gives us an idea of the features that impact the prediction positively and negatively. By positive impact, we say that the feature brought the prediction closer to the predicted value. Negative effect implies the feature took the prediction away from the predicted value. The length of the bars also show the impact. Longer the bar, higher the impact.&#x20;

**Individual Feature Values**

![](/files/-MEfY2sym2Tfbi5EUBj3)

The above plot shows the feature values for that particular row.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maheshwarappa-a.gitbook.io/explainable-ai-1/implementation-of-these-techniques-on-different-models/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
