# Residuals plot

by: Chris Cave

(Feyn version 1.5.4 or newer)

`Feyn`

offers a range of tools to help you dissect your graph and its dynamics.

As sample data we are going for the boston housing price prediction dataset from sklearn where we are predicting median house prices of different areas around Boston. Below I import data, prepare it and find my graph of choice with my QLattice:

```
from sklearn.datasets import load_boston
import pandas as pd
from feyn import QLattice
from feyn.tools import split
#Download boston housing dataset
boston = load_boston()
df_boston = pd.DataFrame(boston.data, columns=boston.feature_names)
df_boston['PRICE'] = boston.target
# Train/test split
train, test = split(df_boston)
# Connect to QLattice
ql = QLattice()
ql.reset()
# Get a regressor
qgraph = ql.get_regressor(train, 'PRICE', max_depth = 2) #max_depth = 2, let's not overdo it
qgraph.fit(train)
# Select a graph from your fitted QGraph
best_graph = qgraph[0]
```

## Residuals plot

One of the basic diagnosics I can do with my graph is to plot the residuals (`y_true`

- `y_pred`

). This can help me analyse whether my errors are normally distributed or not. If they have an unusual distribution then it points towards biases in my model. If they appear to be randomly scattered then this is a positive sign that the model is unbiased.

```
best_graph.plot_residuals(data=train)
```