# Plot response

by: Chris Cave

(Feyn version 2.0 or newer)

A `Model`

is a mathematical function from the inputs to the output. If there are more than two inputs in a `Model`

then it is difficult to visualise how the inputs affect the output.

One way to overcome this is to simplifiy the `Model`

by fixing all the inputs except for one. This simplified `Model`

now has one input and one output. This can be visualised by plotting the single input against the output. `plot_response_1d`

enables you to choose and plot simplified models.

Here is an example:

```
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)
# Connect to QLattice
ql = feyn.connect_qlattice()
models = ql.auto_run(
data=train,
output_name='PRICE'
)
# Select the best Model
best = models[0]
best
```

`# Plot simplified model with only 'CRIM' manually fixed`

best.plot_response_1d(

data = train,

by = 'LSTAT',

input_constraints = {'CRIM': train.CRIM.quantile(0.25)}

)

`# Plot simplified model with only 'CRIM' manually fixed`

best.interactive_response_1d(

data = train,

input_constraints = {'CRIM': train.CRIM.quantile(0.25)}

)

The continuous line is the plot of the simplified function. The scatter points are the values (`data[by]`

, `data[output]`

). The histogram on the top is of `data[by]`

and the histogram to the side is of `data[output]`

.

## data

A `pd.DataFrame`

of your data. This parameter is passed to determine the range of the non-fixed input to plot. All input names of the `Model`

should be the name of columns in the data.

The data is also used to plot the scatter points. This is useful to visualise if the `Model`

has had enough data points to say with confidence the output value of particular inputs.

## by

The input name that is not fixed and is the single input of the simplified `Model`

.

## input_constraints

A dictionary where the keys are the names of all fixed inputs and the values are what to fix the `Model`

at. If None and there are fewer than three inputs then 25%, 50% and 75% quartiles of each fixed input is passed. If there are more than three inputs then only the median is passed for each fixed input. Default is None.

`feyn`

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

module.

```
from feyn.plots import plot_model_response_1d
plot_model_response_1d(best, train, train[best[0].name])
```