{"id":14958373,"url":"https://github.com/eonu/daze","last_synced_at":"2025-10-24T14:32:00.559Z","repository":{"id":54254260,"uuid":"331202754","full_name":"eonu/daze","owner":"eonu","description":"Better multi-class confusion matrix plots for Scikit-Learn, incorporating per-class and overall evaluation measures.","archived":false,"fork":false,"pushed_at":"2021-03-01T11:29:01.000Z","size":47,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T02:22:07.946Z","etag":null,"topics":["accuracy","classification","confusion-matrix","confusion-matrix-heatmap","evaluation","evaluation-metrics","f1-score","measures","multi-class","plot","precision","recall","scikit-learn"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/daze/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eonu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-20T05:30:01.000Z","updated_at":"2024-10-10T10:46:21.000Z","dependencies_parsed_at":"2022-08-13T10:10:23.511Z","dependency_job_id":null,"html_url":"https://github.com/eonu/daze","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eonu%2Fdaze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eonu%2Fdaze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eonu%2Fdaze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eonu%2Fdaze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eonu","download_url":"https://codeload.github.com/eonu/daze/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237990581,"owners_count":19398453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accuracy","classification","confusion-matrix","confusion-matrix-heatmap","evaluation","evaluation-metrics","f1-score","measures","multi-class","plot","precision","recall","scikit-learn"],"created_at":"2024-09-24T13:16:53.680Z","updated_at":"2025-10-24T14:31:50.544Z","avatar_url":"https://github.com/eonu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eDaze\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003csup\u003e\u003cem\u003eBetter multi-class confusion matrix plots for Scikit-Learn, incorporating per-class and overall evaluation measures.\u003c/em\u003e\u003c/sup\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://pypi.org/project/daze\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/v/daze?style=flat-square\" alt=\"PyPI\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Hide until tests are implemented\n    \u003ca href=\"https://pypi.org/project/daze\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/pyversions/daze?style=flat-square\" alt=\"PyPI - Python Version\"/\u003e\n    \u003c/a\u003e\n    --\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/eonu/daze/master/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/l/daze?style=flat-square\" alt=\"PyPI - License\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://daze.readthedocs.io/en/latest\"\u003e\n        \u003cimg src=\"https://readthedocs.org/projects/daze/badge/?version=latest\u0026style=flat-square\" alt=\"Read The Docs - Documentation\"\u003e\n    \u003c/a\u003e\n    \u003c!-- Hide until tests are implemented\n    \u003ca href=\"https://travis-ci.org/eonu/daze\"\u003e\n        \u003cimg src=\"https://img.shields.io/travis/eonu/daze?logo=travis\u0026style=flat-square\" alt=\"Travis - Build\"\u003e\n    \u003c/a\u003e\n    --\u003e\n\u003c/div\u003e\n\n## Introduction\n\n\u003cimg src=\"docs/_static/a,c,p,r,f1.svg\" width=\"300px\" align=\"right\"/\u003e\n\nThe [`sklearn.metrics`](https://scikit-learn.org/stable/modules/classes.html#module-sklearn.metrics) module allows for the plotting of a confusion matrix from a\nclassifier (with [`plot_confusion_matrix`](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.plot_confusion_matrix.html#sklearn.metrics.plot_confusion_matrix)), or directly from a pre-computed confusion matrix (with the internal [`ConfusionMatrixDisplay`](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.ConfusionMatrixDisplay.html#sklearn.metrics.ConfusionMatrixDisplay) class).\n\nA confusion matrix shows the discrepancy between the true labels of a dataset and the labels predicted by a classifier.\n\nWhile the confusion matrix plots generated by Scikit-Learn are very informative, they omit important evaluation measures that can summarize classification performance. True positives, precision, F1 score and accuracy are example of such measures – all of which can be derived from the confusion matrix. The [`classification_report`](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html#sklearn.metrics.classification_report) function in the same module provides these measures.\n\nDaze adjusts `plot_confusion_matrix` to incorporate these evaluation measures directly in the confusion matrix plot, while still maintaining a very similar API\nto the original Scikit-Learn function.\n\n## Features\n\n- Similar API to Scikit-Learn's `plot_confusion_matrix`.\n- All common [confusion matrix measures](https://daze.readthedocs.io/en/latest/sections/measures.html#types-of-measures):\u003cbr/\u003e\n  _Accuracy, TP, FP, TN, FN, TPR, FPR, TNR, FNR, Precision, Recall, F1_.\n- Macro \u0026 micro averaging for overall evaluation measures:\u003cbr/\u003e\n  _TPR, FPR, TNR, FNR, Precision, Recall, F1_.\n- Supports both classifiers and pre-computed confusion matrices.\n\n## Installation\n\n```console\npip install daze\n```\n\n## Documentation\n\nThe package API remains largely the same as that of `sklearn.metrics.plot_confusion_matrix` with a few additions and changes to the function arguments:\n\n\u003cdetails\u003e\n\u003csummary\u003e\n    \u003cb\u003eClick here to view the changes.\u003c/b\u003e\n\u003c/summary\u003e\n\u003cp\u003e\n\n- `estimator` (_changed_): Supports the usual fitted Scikit-Learn classifier (or [`sklearn.pipeline.Pipeline`](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html)), but also now accepts a pre-computed confusion matrix.\n- `X` (_changed_): If `estimator` is a classifier, then `X` are input values as usual. If `estimator` is a confusion matrix, then `X` should be set to `None`.\n- `y_true` (_changed_): If `estimator` is a classifier, then `y_true` are target values as usual. If `estimator` is a confusion matrix, then `y_true` should be set to `None`.\n- `normalize` (_added_): Whether or not to normalize the plotted confusion matrix (`True`/`False`). Note that if a confusion matrix is provided, it should always be un-normalized.\n- `include_measures` (_added_): Whether or not to include evaluation measures in the confusion matrix plot (`True`/`False`).\n- `measures` (_added_): Collection of labels for evaluation measures to display in the plot ([see documentation](https://daze.readthedocs.io/en/latest/sections/measures.html#types-of-measures))\n- `measures_format` (_added_): Format string for the evaluation measure values.\n- `include_summary` (_added_): Whether or not to include summary measures (`True`/`False`). Note that `include_measures=False` overrides this setting.\n- `summary_type` (_added_): The type of averaging (`'micro'`/`'macro'`) used for summary measures.\n\n\u003c/p\u003e\n\u003c/details\u003e\n\nDocumentation for the package is available on [Read The Docs](https://daze.readthedocs.io/en/latest).\n\n## Examples\n\n### Using a classifier object\n\n```python\n# Load the 'iris' dataset\nfrom sklearn import datasets\nfrom sklearn.model_selection import train_test_split\niris = datasets.load_iris()\nX_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, random_state=1)\n\n# Train a SVM classifier on a subset of the data\nfrom sklearn.svm import SVC\nclf = SVC(kernel='linear').fit(X_train[:10], y_train[:10])\n\n# Plot the confusion matrix\nimport matplotlib.pyplot as plt\nfrom daze import plot_confusion_matrix\nplt.figure(figsize=(5.5, 5.5))\nplot_confusion_matrix(clf, X_test, y_test, display_labels=iris.target_names, measures=...)\nplt.show()\n```\n\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\n\t\t\t\u003cth\u003e\n                \u003ccode\u003emeasures=\u003c/code\u003e\n\t\t\t\u003c/th\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ccode\u003ea, c, p, r, f1\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ccode\u003ea, tp, fp, fpr, tnr, p\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ccode\u003ea, tn, fn, tpr, fnr, r\u003c/code\u003e\n\t\t\t\u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\n                \u003cb\u003ePlot\u003c/b\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003cimg src=\"docs/_static/a,c,p,r,f1.svg\" width=\"400px\"/\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003cimg src=\"docs/_static/a,tp,fp,fpr,tnr,p.svg\" width=\"385px\"/\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003cimg src=\"docs/_static/a,tn,fn,tpr,fnr,r.svg\" width=\"380px\"/\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n### Using a pre-computed confusion matrix\n\n```python\n# Use the previous classifier to make predictions and create a confusion matrix\nfrom sklearn.metrics import confusion_matrix\ny_pred = clf.predict(X_test)\ncm = confusion_matrix(y_test, y_pred)\n\n# Make a plot from a pre-computed confusion matrix\nplt.figure(figsize=(5.5, 5.5))\nplot_confusion_matrix(cm, display_labels=iris.target_names)\nplt.show()\n```\n\n## Licensing\n\nDaze uses [Scikit-Learn source code](https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/metrics/_plot/confusion_matrix.py) for the majority of the `ConfusionMatrixDisplay` class and `plot_confusion_matrix` function re-implemetations, under the terms of the BSD-3-Clause license.\n\n\u003cdetails\u003e\n\u003csummary\u003e\n    \u003cb\u003eClick here to view the redistribution license.\u003c/b\u003e\n\u003c/summary\u003e\n\u003cp\u003e\n\n\u003e ```\n\u003e BSD 3-Clause License\n\u003e\n\u003e Copyright (c) 2007-2020 The scikit-learn developers.\n\u003e All rights reserved.\n\u003e\n\u003e Redistribution and use in source and binary forms, with or without\n\u003e modification, are permitted provided that the following conditions are met:\n\u003e\n\u003e * Redistributions of source code must retain the above copyright notice, this\n\u003e   list of conditions and the following disclaimer.\n\u003e\n\u003e * Redistributions in binary form must reproduce the above copyright notice,\n\u003e   this list of conditions and the following disclaimer in the documentation\n\u003e   and/or other materials provided with the distribution.\n\u003e\n\u003e * Neither the name of the copyright holder nor the names of its\n\u003e   contributors may be used to endorse or promote products derived from\n\u003e   this software without specific prior written permission.\n\u003e\n\u003e THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n\u003e AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\u003e IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\u003e DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n\u003e FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\u003e DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n\u003e SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n\u003e CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n\u003e OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\u003e OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\u003e ```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eDaze\u003c/b\u003e \u0026copy; 2021-2022, Edwin Onuonga - Released under the \u003ca href=\"https://opensource.org/licenses/MIT\"\u003eMIT\u003c/a\u003e License.\u003cbr/\u003e\n  \u003cem\u003eAuthored and maintained by Edwin Onuonga.\u003c/em\u003e\n\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feonu%2Fdaze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feonu%2Fdaze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feonu%2Fdaze/lists"}