Summary plot
by: Chris Cave
(Feyn version 3.0 or newer)
The summary of a Model
can be seen using the plot
function on the Model
. This provides a graph visualisation of the Model
with metrics and useful plots. The metrics and plots of the Model
on the data passed are:
- For regressors:
- R2 score,
- Root mean squared error,
- Mean absolute error,
- Regression plot,
- Residuals plot.
- For classifiers:
- Accuracy at 0.5 threshold,
- AUC,
- Precision at 0.5 threshold,
- Recall at 0.5 threshold,
- ROC curve,
- Confusion matrix at 0.5 threshold.
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[0]
best.plot(
data=train,
compare_data=test
)
Parameters
data
This should be the data the model has trained on.
compare_data
Can take a single dataframe to compare with, or a list of dataframes - in case you want to compare multiple datasets or splits with each other.
labels
You can pass in custom labels for the header of the summary metrics. If your list of labels is shorter than the compare_data argument, numbered labels will be generated for the rest.
filename
Use to specify a path to a file to save the plot to (as HTML).
best.plot(train, filename="feyn-summary.html")
Feyn
Location in This function can also be found in feyn.plots
module.
from feyn.plots import plot_model_summary
plot_model_summary(best, train)