Skip to content

Latest commit

 

History

History
180 lines (125 loc) · 5.23 KB

README.md

File metadata and controls

180 lines (125 loc) · 5.23 KB

CircleCI

mlplot

Machine learning evaluation plots using matplotlib and sklearn.

Install

pip install mlplot

ML Plot runs with python 3.5 and above! (using format strings and type annotations)

Contributing

Create a PR!

Plots

Work was inspired by sklearn model evaluation.

Classification

ROC with AUC number

from mlplot.evaluation import ClassificationEvaluation
eval = ClassificationEvaluation(y_true, y_pred, class_names, model_name)
eval.roc_curve()

https://github.com/sbarton272/mlplot/blob/master/tests/output/tests.evaluation.test_classification.test_calibration.png?raw=true ROC plot

Calibration

from mlplot.evaluation import ClassificationEvaluation
eval = ClassificationEvaluation(y_true, y_pred, class_names, model_name)
eval.calibration()

calibration plot

Precision-Recall

from mlplot.evaluation import ClassificationEvaluation
eval = ClassificationEvaluation(y_true, y_pred, class_names, model_name)
eval.precision_recall(x_axis='recall')
eval.precision_recall(x_axis='thresold')

precision recall curve plot

precision recall threshold plot

Distribution

from mlplot.evaluation import ClassificationEvaluation
eval = ClassificationEvaluation(y_true, y_pred, class_names, model_name)
eval.distribution()

distribution plot

Confusion Matrix

from mlplot.evaluation import ClassificationEvaluation
eval = ClassificationEvaluation(y_true, y_pred, class_names, model_name)
eval.confusion_matrix(threshold=0.5)

confusion matrix

Classification Report

from mlplot.evaluation import ClassificationEvaluation
eval = ClassificationEvaluation(y_true, y_pred, class_names, model_name)
eval.report_table()

classification report

Regression

Scatter Plot

from mlplot.evaluation import RegressionEvaluation
eval = RegressionEvaluation(y_true, y_pred, class_names, model_name)
eval.scatter()

scatter plot

Residuals Plot

from mlplot.evaluation import RegressionEvaluation
eval = RegressionEvaluation(y_true, y_pred, class_names, model_name)
eval.residuals()

scatter plot

Residuals Histogram

from mlplot.evaluation import RegressionEvaluation
eval = RegressionEvaluation(y_true, y_pred, class_names, model_name)
eval.residuals_histogram()

scatter plot

Regression Report

from mlplot.evaluation import RegressionEvaluation
eval = RegressionEvaluation(y_true, y_pred, class_names, model_name)
eval.report_table()

report table

Forecasts

  • TBD

Rankings

  • TBD

Development

Publish to pypi

python setup.py sdist bdist_wheel
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

Design

Basic interface thoughts

from mlplot.evaluation import ClassificationEvaluation
from mlplot.evaluation import RegressorEvaluation
from mlplot.evaluation import MultiClassificationEvaluation
from mlplot.evaluation import MultiRegressorEvaluation
from mlplot.evaluation import ModelComparison
from mlplot.feature_evaluation import *

eval = ClassificationEvaluation(y_true, y_pred)
ax = eval.roc_curve()
auc = eval.auc_score()
f1_score = eval.f1_score()
ax = eval.confusion_matrix(threshold=0.7)
  • ModelEvaluation base class
  • ClassificationEvaluation class
    • take in y_true, y_pred, class names, model_name
  • RegressorEvaluation class
  • MultiClassificationEvaluation class
  • ModelComparison
    • takes in two evaluations of the same type

TODO

  • Fix distribution plot, make lines
  • Add legend with R2 to regression plots
  • Add tests for regression comparison
  • Split apart files for comparison classes
  • Add comparisons to README