Feyn

Feyn

  • Tutorials
  • Guides
  • API Reference
  • FAQ

›Understand Your Models

Getting Started

  • Quick start
  • Using Feyn
  • Installation
  • Transition to Feyn 3.0
  • What is a QLattice?
  • Community edition
  • Commercial use

Essentials

  • Auto Run
  • Visualise a model
  • Summary plot
  • Semantic types
  • Categorical features
  • Estimating priors
  • Model parameters
  • Predicting with a model
  • Saving and loading models
  • Filtering models
  • Seeding a QLattice
  • Privacy

Evaluate Regressors

  • Regression plot
  • Residuals plot

Evaluate Classifiers

  • ROC curve
  • Confusion matrix
  • Plot probability scores

Understand Your Models

  • Plot response
  • Plot response 2D
  • Model signal
  • Segmented loss
  • Interactive flow

Primitive Operations

  • Using the primitives
  • Updating priors
  • Sample models
  • Fitting models
  • Pruning models
  • Diverse models
  • Updating a QLattice
  • Validate data

Advanced

  • Converting a model to SymPy
  • Setting themes
  • Saving a graph as an image
  • Using the query language
  • Model complexity

Segmented loss

by: Valdemar Stentoft-Hansen & Chris Cave
(Feyn version 3.0 or newer)

A Models 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")

Location in Feyn

This function can also be found in feyn.plots module.

from feyn.plots import plot_segmented_loss

plot_segmented_loss(best, train)
← Model signalInteractive flow →
  • data
  • by
  • Saving the plot
  • Location in Feyn
Copyright © 2022 Abzu.ai
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®