SNIPPET
1 Upvote

Prediction Error Distribution

Python
Supervised Learning

Generates a histogram for the prediction errors of a model.

import Matplotlib.pyplot as plt
import numpy as np

"""
Calculate error from between target and predictions
(Based on merged data frame of test data and predictions)
"""
test['error'] = test['target'] - test['prediction']

#Set plot size
plt.subplots(figsize=(10,5))
#Set X-Axis range
plt.xlim(-20, 20)
plt.title('Model Error Distribution')
plt.ylabel('No. of Predictions')
plt.xlabel('Error')
plt.hist(predictions['error'], bins=np.linspace(-20, 20, num=41, dtype=int));
plt.show()

By detro - Last Updated Dec. 15, 2020, 4:09 p.m.

COMMENTS
RELATED SNIPPETS
Search Snippets by Tag: