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

Interactive flow

by: Chris Cave
(Feyn version 3.0 or newer)

The output value of a node within a neural network of a given data point is called the activation value. Usually neural networks are dense with many nodes so it can be difficult to decipher what a particular activation value at a given node can mean in the overall picture of the model. The Models from the QLattice are much less dense than a neural network which means that the activation values are much easier to decode.

This gives the benefit that one can interpret how each activation value affects the output and thus how each feature contributes to the model. This is what the method plot_flow and plot_flow_interactive captures.

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_flow(
    data=train,
    sample=train.iloc[0:1]
)

The method plot_flow takes a single sample and plots the activation values at each node. It displays these value above each node. The method interactive_activation_flow uses plot_flow and make this interactive as in the image below.

from feyn.plots.interactive import interactive_activation_flow

interactive_activation_flow(best, train)

As with all models one should be very careful when you investigate how the Model behaves outside the domain it has been trained on. This could given unusual and unexpected results which would need further investigation.

This tool is only for IPython kernels. This requires installing ipywidgets and enabling the extension in jupyter notebook:

$ jupyter nbextension enable --py widgetsnbextension

or in jupyter lab:

$ jupyter labextension install @jupyter-widgets/jupyterlab-manager

Location in Feyn

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

from feyn.plots import plot_activation_flow

plot_activation_flow(best, train, train.iloc[0:1])
← Segmented lossUsing the primitives →
  • Location in Feyn
Copyright © 2023 Abzu.ai
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®