Model signal
by: Kevin Broløs and Chris Cave
(Feyn version 3.0 or newer)
The signal of a Model
can be seen using the plot_signal
function on the Model
.
This provides a graph visualisation of the Model
that colours the nodes of the graph with its signal capture amount at each point.
Example
import feyn
from sklearn.datasets import load_diabetes
import pandas as pd
from feyn.tools import split
# Load diabetes dataset into a pandas dataframe
dataset = load_diabetes()
df_diabetes = pd.DataFrame(dataset.data, columns=dataset.feature_names)
df_diabetes['response'] = dataset.target
# Train/test split
train, test = split(df_diabetes, ratio=[0.6, 0.4])
# Instantiate a QLattice
ql = feyn.QLattice()
models = ql.auto_run(
data=train,
output_name='response'
)
# Select the best Model
best = models[0]
best.plot_signal(train)
Colours on a graph
The nodes in the graph returned from the plot_signal
function are coloured and have values above them.
The values show the paths in the graph that are important or unnecessary in the Model
. If the value of the node has increased significantly (about 0.05) compared to its inputs then those inputs are important. Otherwise the node is likely to be unnecessary.
If there is redundancy then run a simulation with lower max_complexity
and with a criterion
. You will get a Model
with less unnecessary paths without sacrificing much on performance.
Repeating this process with many iterations enables you to decide the Model
with the correct balance of interpreability and performance for your dataset.
The values are the Pearson's correlation coefficient of the activation values of the node and the output variable. The colours correspond to the correlation coefficient, where -1
is represented by red, 0
by white and 1
by green.
Parameters
data
This should be the data the model has trained on.
corr_func
Takes a correlation function amongst ['pearson', 'spearman', 'mutual_information']
to compute the correlations at each interaction in the model.
filename
Use to specify a path to a file to save the plot to (as SVG).
best.plot_signal(train, filename="feyn-signal-plot.svg")
Feyn
Location in This function can also be found in feyn.plots
module.
from feyn.plots import plot_model_signal
plot_model_signal(best, train)