by: Chris Cave
(Feyn version 2.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
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 best.plot_flow( data=train, sample=train.iloc[0:1] )
plot_flow takes a single sample and plots the activation values at each node. It displays these value above each node. The method
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 nbextension enable --py widgetsnbextension
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager
This function can also be found in
from feyn.plots import plot_activation_flow plot_activation_flow(best, train, train.iloc[0:1])