Segmented loss
by: Valdemar Stentoft-Hansen & Chris Cave
(Feyn version 3.0 or newer)
A Model
s performance varies across a dataset. The plot_segmented_loss
displays the distribution of an input or output as a histogram and is overlayed with the average loss for the associated bin.
You can use this to determine areas where the Model
performs best and worst across the inputs and output.
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)
# Instantiate a QLattice
ql = feyn.QLattice()
models = ql.auto_run(
data=train,
output_name='PRICE'
)
# Select the best Model
best = models[0]
best.plot_segmented_loss(
data = train,
by = None
)
data
The data passed in this parameter is used to determine the bins of the input or output the plot is segemented by and the average loss across the bin.
by
The input name or output to segment the loss over.
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_segmented_loss(train, filename="feyn-plot")
Feyn
Location in This function can also be found in feyn.plots
module.
from feyn.plots import plot_segmented_loss
plot_segmented_loss(best, train)