by: Chris Cave
(Feyn version 3.0 or newer)
The signal of a
Model can be seen using the
plot_signal function on the
This provides a graph visualisation of the
Model that colours the nodes of the graph with its signal capture amount at each point.
Here is an example:
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 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.
This should be the data the model has trained on.
Takes a correlation function amongst
['pearson', 'spearman', 'mutual_information'] to compute the correlations at each interaction in the model.
Use to specify a path to a file to save the plot to (as SVG).
This function can also be found in
from feyn.plots import plot_model_signal plot_model_signal(best, train)