# Regression plot

by: Chris Cave

(Feyn version 3.0 or newer)

`Feyn`

offers a range of tools to help you dissect your `Model`

.

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 we import data, prepare it and find a good `Model`

from a `QLattice`

:

```
import feyn
from sklearn.datasets import load_boston
import pandas as pd
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)
# Intantiate a QLattice
ql = feyn.QLattice()
models = ql.auto_run(
data=train,
output_name='PRICE'
)
# Select the best Model
best = models[0]
```

## plot_regression

As we have a regressor, we would like to compare the true values of the target variable with the predicted values. The code below plots tuples: on the x-axis are the true values of the target variable and on the y-axis are the predicted values from the regressor. If the prediction is perfect then all the points should lie on the `y=x`

dashed line. We can use this to see whether we overestimate or underestimate certain regions.

The line of best fit is an aid to see just how close the points are to the line of equality.

```
best.plot_regression(data=train)
```

## Saving the plot

You can save the plot using the `filename`

parameter. The plot is saved in the current working directory unless another path specifed.

```
best.plot_regression(data=train, filename="feyn-plot")
```

If the extension is not specified then it is saved as a png file.

`Feyn`

Location in This function can also be found in `feyn.plots`

module.

```
from feyn.plots import plot_regression
y_true = train['PRICE']
y_pred = best.predict(train)
plot_regression(y_true, y_pred)
```