Feyn

Feyn

  • Tutorials
  • Guides
  • API Reference
  • FAQ

›Evaluate Regressors

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

Residuals 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)

# Instantiate a QLattice
ql = feyn.QLattice()

models = ql.auto_run(
    data=train,
    output_name='PRICE'
)
# Select the best Model
best = models[0]

Residuals plot

One of the basic diagnosics we can do with a Model is to plot the residuals (y_true - y_pred). This can help analyse whether errors are normally distributed or not. If they have an unusual distribution then it points towards biases in the Model. If they appear to be randomly scattered then this is a positive sign that the Model is unbiased.

best.plot_residuals(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_residuals(data=train, filename="feyn-plot")

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

Location in Feyn

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

from feyn.plots import plot_residuals

y_true = train['PRICE']
y_pred = best.predict(train)

plot_residuals(y_true, y_pred)
← Regression plotROC curve →
  • Residuals plot
  • Saving the plot
  • Location in Feyn
Copyright © 2023 Abzu.ai
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®