bluer-objects 6.322.1__py3-none-any.whl → 6.325.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of bluer-objects might be problematic. Click here for more details.

bluer_objects/__init__.py CHANGED
@@ -4,7 +4,7 @@ ICON = "🌀"
4
4
 
5
5
  DESCRIPTION = f"{ICON} Object management in Bash."
6
6
 
7
- VERSION = "6.322.1"
7
+ VERSION = "6.325.1"
8
8
 
9
9
  REPO_NAME = "bluer-objects"
10
10
 
@@ -0,0 +1,76 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ from typing import List
4
+
5
+ from bluer_objects.graphics.signature import justify_text
6
+ from bluer_objects import file
7
+
8
+
9
+ def log_confusion_matrix(
10
+ confusion_matrix: np.ndarray,
11
+ filename: str,
12
+ header: List[str] = [],
13
+ footer: List[str] = [],
14
+ x_classes: List[str] = [],
15
+ y_classes: List[str] = [],
16
+ x_name: str = "prediction",
17
+ y_name: str = "label",
18
+ line_width: int = 80,
19
+ log: bool = True,
20
+ figsize: tuple = (10, 10),
21
+ ) -> bool:
22
+ fig, ax = plt.subplots(figsize=figsize)
23
+ cax = ax.imshow(
24
+ confusion_matrix,
25
+ interpolation="nearest",
26
+ cmap=plt.cm.Blues,
27
+ )
28
+ fig.colorbar(cax)
29
+ ax.set_title(
30
+ justify_text(
31
+ " | ".join(header),
32
+ line_width=line_width,
33
+ return_str=True,
34
+ )
35
+ )
36
+ ax.set_xlabel(
37
+ justify_text(
38
+ " | ".join([x_name] + footer),
39
+ line_width=line_width,
40
+ return_str=True,
41
+ )
42
+ )
43
+ ax.set_ylabel(y_name)
44
+
45
+ if not x_classes:
46
+ x_classes = [f"class #{index}" for index in range(confusion_matrix.shape[1])]
47
+ if not y_classes:
48
+ y_classes = [f"class #{index}" for index in range(confusion_matrix.shape[0])]
49
+
50
+ ax.set_xticks(np.arange(confusion_matrix.shape[1]))
51
+ ax.set_yticks(np.arange(confusion_matrix.shape[0]))
52
+ ax.set_xticklabels(
53
+ x_classes,
54
+ rotation=45,
55
+ ha="right",
56
+ )
57
+ ax.set_yticklabels(y_classes)
58
+
59
+ threshold = confusion_matrix.max() / 2.0
60
+ for i in range(confusion_matrix.shape[0]):
61
+ for j in range(confusion_matrix.shape[1]):
62
+ ax.text(
63
+ j,
64
+ i,
65
+ f"{100*confusion_matrix[i, j]:.1f}%",
66
+ ha="center",
67
+ va="center",
68
+ color="white" if confusion_matrix[i, j] > threshold else "black",
69
+ )
70
+
71
+ plt.tight_layout()
72
+
73
+ return file.save_fig(
74
+ filename,
75
+ log=log,
76
+ )
@@ -0,0 +1,18 @@
1
+ import numpy as np
2
+
3
+ from bluer_objects import objects
4
+ from bluer_objects.logger.confusion_matrix import log_confusion_matrix
5
+
6
+
7
+ def test_logger_confusion_matrix():
8
+ object_name = objects.unique_object("test_logger_confusion_matrix")
9
+
10
+ confusion_matrix = np.random.random((10, 8))
11
+
12
+ assert log_confusion_matrix(
13
+ confusion_matrix,
14
+ objects.path_of(
15
+ object_name=object_name,
16
+ filename="confusion_matrix.png",
17
+ ),
18
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bluer_objects
3
- Version: 6.322.1
3
+ Version: 6.325.1
4
4
  Summary: 🌀 Object management in Bash.
5
5
  Home-page: https://github.com/kamangir/bluer-objects
6
6
  Author: Arash Abadpour (Kamangir)
@@ -65,6 +65,6 @@ pip install bluer-objects
65
65
 
66
66
  [![pylint](https://github.com/kamangir/bluer-objects/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/bluer-objects/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/bluer-objects/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/bluer-objects.svg)](https://pypi.org/project/bluer-objects/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/bluer-objects)](https://pypistats.org/packages/bluer-objects)
67
67
 
68
- built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.322.1`](https://github.com/kamangir/bluer-objects).
68
+ built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.325.1`](https://github.com/kamangir/bluer-objects).
69
69
 
70
70
  built by 🌀 [`blueness-3.118.1`](https://github.com/kamangir/blueness).
@@ -1,4 +1,4 @@
1
- bluer_objects/__init__.py,sha256=8s1PgZJPlJ4pc1gocF3kBql5DyMVUcQ5FaRcCFqdz4M,315
1
+ bluer_objects/__init__.py,sha256=Pi2iOBzjpZk_r580bAmAfa7JmsPQhMi-wqb2eJLn4AI,315
2
2
  bluer_objects/__main__.py,sha256=Yqfov833_hJuRne19WrGhT5DWAPtdffpoMxeSXS7EGw,359
3
3
  bluer_objects/config.env,sha256=ReX0OSH_dK2tdD4-zAlp-427BB57yw8uDTS6tLYN4K0,270
4
4
  bluer_objects/env.py,sha256=ecwldUVsamxAjOI0a6PmbZPcyhdUZgzJ-nhAPh0CJRo,2085
@@ -117,6 +117,7 @@ bluer_objects/host/__init__.py,sha256=Ko43SWnZNsGKuIPU_l0w17pYrxCgVHQx3_zEoUNaHZ
117
117
  bluer_objects/host/__main__.py,sha256=J0MO2sUzrI_t_X4VVYyM6n41ND0yhhSXOmZSkDAC4rg,1751
118
118
  bluer_objects/host/functions.py,sha256=ADups78hYZDAnC6FlIICQ48WkFd4sPnRMWA0D6X-FV4,1663
119
119
  bluer_objects/logger/__init__.py,sha256=2aGNbx-qBXU3IlX9BDqtrFfN25lO_uarEg22cE3-3dU,102
120
+ bluer_objects/logger/confusion_matrix.py,sha256=CCcuogDm7_w-0f87-AeK7ue2CMBRJHmoaO_Vqy-C_Ds,1991
120
121
  bluer_objects/logger/image.py,sha256=wHpE6jCqKGmcjXU61vCMKbBeir7DAxH6nKx5kb_1Vv0,2617
121
122
  bluer_objects/logger/matrix.py,sha256=cPKQIhd347MH_9LaB-Ym7Mix1pqampG9MIgkeh08KA4,5757
122
123
  bluer_objects/logger/stitch.py,sha256=qFWQAxNyfOn7k5celRYIUPqaI-ZqDWKQ5ud1VyaIwM4,2515
@@ -166,6 +167,7 @@ bluer_objects/tests/test_graphics_signature.py,sha256=CVV257E3A5KBwqEDpRXShN-ful
166
167
  bluer_objects/tests/test_graphics_text.py,sha256=_jLZVuAcQQYlKpATeQCBpPMa8UhKQ__bFYR1bedO5EE,314
167
168
  bluer_objects/tests/test_log_image_grid.py,sha256=qjSRMwY5jnJd9S3XZ3FDeoIsSJ9aFJ3yDhth1sV0A5g,737
168
169
  bluer_objects/tests/test_logger.py,sha256=DdkZqj8YOErKf6T-SWEPtU21LGfQf_O3GKrCn3H0Ujs,88
170
+ bluer_objects/tests/test_logger_confusion_matrix.py,sha256=KbkUg153n6xt3558LXE50URGXrhoRsSorF2lJcqMmaE,469
169
171
  bluer_objects/tests/test_logger_matrix.py,sha256=qedidEDGusMWQM04kgk3mt74yFm4iU3jIyjE4gRi_FQ,1703
170
172
  bluer_objects/tests/test_logger_stitch_images.py,sha256=GW_EPbByNbAhwCJ3LwVXjwe4sTx6jcE0SXVvM8kL_LY,929
171
173
  bluer_objects/tests/test_markdown.py,sha256=KtCWKIDs4U1M3qAGFMYhzVpdGiDV2VU8z7dCaU3s3Ec,217
@@ -186,8 +188,8 @@ bluer_objects/tests/test_web_is_accessible.py,sha256=2Y20NAEDMblg0MKnhnqcfw3XVKE
186
188
  bluer_objects/web/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
187
189
  bluer_objects/web/__main__.py,sha256=xf2Ob54FI8JEokfGhFmiyOBdD9nBactwqmZvsKsdioU,624
188
190
  bluer_objects/web/functions.py,sha256=KNufAFOc6N3BYf83lN2rUpKUdsnzb2anWyp9koFRVUo,172
189
- bluer_objects-6.322.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
190
- bluer_objects-6.322.1.dist-info/METADATA,sha256=YZCM8792s_KHOnuBzk1wcEMeMbybhULXJR156RLFKBk,3780
191
- bluer_objects-6.322.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
192
- bluer_objects-6.322.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
193
- bluer_objects-6.322.1.dist-info/RECORD,,
191
+ bluer_objects-6.325.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
192
+ bluer_objects-6.325.1.dist-info/METADATA,sha256=satmgSwT0AVO9rSYBViAgJbo7RfFTSOCDlJZrK0bX4s,3780
193
+ bluer_objects-6.325.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
194
+ bluer_objects-6.325.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
195
+ bluer_objects-6.325.1.dist-info/RECORD,,