From d4cb149c60247ebd13a6127350d05b8c4440372b Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 10:50:43 +0330 Subject: [PATCH 01/17] fix : pycm_util --> utils --- CHANGELOG.md | 1 + Test/function_test.py | 2 +- Test/warning_test.py | 2 +- pycm/pycm_class_func.py | 2 +- pycm/pycm_compare.py | 2 +- pycm/pycm_curve.py | 2 +- pycm/pycm_handler.py | 2 +- pycm/pycm_obj.py | 2 +- pycm/pycm_output.py | 2 +- pycm/pycm_overall_func.py | 2 +- pycm/{pycm_util.py => utils.py} | 0 11 files changed, 10 insertions(+), 9 deletions(-) rename pycm/{pycm_util.py => utils.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd27bb8d..f6e1a381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Test system modified - `Python 3.12` added to `test.yml` - Warning and error messages updated +- `pycm_util.py` renamed to `utils.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index 627bf2be..00d3acbd 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -191,7 +191,7 @@ >>> from pycm.pycm_class_func import * >>> from pycm.pycm_ci import * >>> from pycm.pycm_interpret import * ->>> from pycm.pycm_util import * +>>> from pycm.utils import * >>> color_check("red") [255, 0, 0] >>> color_check((255,2,2)) diff --git a/Test/warning_test.py b/Test/warning_test.py index 619bd164..3f38f041 100644 --- a/Test/warning_test.py +++ b/Test/warning_test.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ >>> from pycm import * ->>> from pycm.pycm_util import deprecated +>>> from pycm.utils import deprecated >>> from pytest import warns >>> large_cm = ConfusionMatrix(list(range(10)) + [2, 3, 5], list(range(10)) + [1, 7, 2]) >>> with warns(RuntimeWarning, match='Confusion matrix is high-dimensional and may not display properly. Consider using the `sparse` flag in printing functions, or save it as a CSV file for better visualization.'): diff --git a/pycm/pycm_class_func.py b/pycm/pycm_class_func.py index e1f53449..d8de7c11 100644 --- a/pycm/pycm_class_func.py +++ b/pycm/pycm_class_func.py @@ -2,7 +2,7 @@ """Class statistics functions.""" from __future__ import division import math -from .pycm_util import normal_quantile +from .utils import normal_quantile from .pycm_interpret import * from .pycm_param import CLASS_PARAMS diff --git a/pycm/pycm_compare.py b/pycm/pycm_compare.py index ba9655ea..dcd04bd1 100644 --- a/pycm/pycm_compare.py +++ b/pycm/pycm_compare.py @@ -3,7 +3,7 @@ from __future__ import division from .pycm_error import pycmCompareError from .pycm_output import * -from .pycm_util import * +from .utils import * from .pycm_param import * from .pycm_obj import ConfusionMatrix import os diff --git a/pycm/pycm_curve.py b/pycm/pycm_curve.py index 90689a22..e14e3952 100644 --- a/pycm/pycm_curve.py +++ b/pycm/pycm_curve.py @@ -2,7 +2,7 @@ """Curve module.""" from __future__ import division from .pycm_error import pycmCurveError, pycmPlotError -from .pycm_util import threshold_func, thresholds_calc, isfloat +from .utils import threshold_func, thresholds_calc, isfloat from .pycm_param import * from .pycm_obj import ConfusionMatrix from warnings import warn diff --git a/pycm/pycm_handler.py b/pycm/pycm_handler.py index ffbcd167..57886294 100644 --- a/pycm/pycm_handler.py +++ b/pycm/pycm_handler.py @@ -4,7 +4,7 @@ from .pycm_class_func import class_statistics from .pycm_error import pycmVectorError, pycmMatrixError from .pycm_overall_func import overall_statistics -from .pycm_util import * +from .utils import * from .pycm_param import * import json import types diff --git a/pycm/pycm_obj.py b/pycm/pycm_obj.py index b2f0d1eb..825472ad 100644 --- a/pycm/pycm_obj.py +++ b/pycm/pycm_obj.py @@ -9,7 +9,7 @@ from .pycm_overall_func import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc from .pycm_distance import DistanceType, DISTANCE_MAPPER from .pycm_output import * -from .pycm_util import * +from .utils import * from .pycm_param import * from .pycm_ci import __CI_overall_handler__, __CI_class_handler__ import os diff --git a/pycm/pycm_output.py b/pycm/pycm_output.py index 274f6e2e..6aa66089 100644 --- a/pycm/pycm_output.py +++ b/pycm/pycm_output.py @@ -3,7 +3,7 @@ from __future__ import division from functools import partial from .pycm_param import * -from .pycm_util import rounder, sort_char_num +from .utils import rounder, sort_char_num import webbrowser diff --git a/pycm/pycm_overall_func.py b/pycm/pycm_overall_func.py index 5b4724d4..a9f4b42c 100644 --- a/pycm/pycm_overall_func.py +++ b/pycm/pycm_overall_func.py @@ -6,7 +6,7 @@ from functools import reduce from .pycm_interpret import * from .pycm_ci import kappa_SE_calc, CI_calc, SE_calc -from .pycm_util import complement +from .utils import complement def log_loss_calc( diff --git a/pycm/pycm_util.py b/pycm/utils.py similarity index 100% rename from pycm/pycm_util.py rename to pycm/utils.py From 24b229e0db1de8d815b3646a133c1da415f17128 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 10:54:35 +0330 Subject: [PATCH 02/17] fix : pycm_test --> basic_test --- .coveragerc | 2 +- CHANGELOG.md | 1 + pycm/__main__.py | 2 +- pycm/{pycm_test.py => basic_test.py} | 0 4 files changed, 3 insertions(+), 2 deletions(-) rename pycm/{pycm_test.py => basic_test.py} (100%) diff --git a/.coveragerc b/.coveragerc index 5413503a..aa3fe217 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,7 +4,7 @@ omit = */pycm/__main__.py */pycm/__init__.py */pycm/pycm_profile.py - */pycm/pycm_test.py + */pycm/basic_test.py [report] # Regexes for lines to exclude from consideration exclude_lines = diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e1a381..bdba4d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `Python 3.12` added to `test.yml` - Warning and error messages updated - `pycm_util.py` renamed to `utils.py` +- `pycm_test.py` renamed to `basic_test.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/__main__.py b/pycm/__main__.py index 51b32ae9..187b8591 100644 --- a/pycm/__main__.py +++ b/pycm/__main__.py @@ -13,7 +13,7 @@ if len(args) > 1: if args[1].upper() == "TEST": error_flag = doctest.testfile( - "pycm_test.py", + "basic_test.py", optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL, verbose=False)[0] diff --git a/pycm/pycm_test.py b/pycm/basic_test.py similarity index 100% rename from pycm/pycm_test.py rename to pycm/basic_test.py From 8ad3ee2e16e807668163a1ad2209638c3493e9bd Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 10:57:01 +0330 Subject: [PATCH 03/17] fix : pycm_profile --> profile --- .coveragerc | 2 +- .github/workflows/test.yml | 2 +- CHANGELOG.md | 1 + pycm/{pycm_profile.py => profile.py} | 0 4 files changed, 3 insertions(+), 2 deletions(-) rename pycm/{pycm_profile.py => profile.py} (100%) diff --git a/.coveragerc b/.coveragerc index aa3fe217..5ee79611 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,7 +3,7 @@ branch = True omit = */pycm/__main__.py */pycm/__init__.py - */pycm/pycm_profile.py + */pycm/profile.py */pycm/basic_test.py [report] # Regexes for lines to exclude from consideration diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29a6afa6..27a45a0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,4 +68,4 @@ jobs: if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS - name: cProfile run: | - python -m cProfile -s cumtime pycm/pycm_profile.py + python -m cProfile -s cumtime pycm/profile.py diff --git a/CHANGELOG.md b/CHANGELOG.md index bdba4d2d..cbdf003e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Warning and error messages updated - `pycm_util.py` renamed to `utils.py` - `pycm_test.py` renamed to `basic_test.py` +- `pycm_profile.py` renamed to `profile.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/pycm_profile.py b/pycm/profile.py similarity index 100% rename from pycm/pycm_profile.py rename to pycm/profile.py From 188cb5ee1ccf11a49dddd62cfb95ce5a951a97d9 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:05:10 +0330 Subject: [PATCH 04/17] fix : pycm_param --> params --- .github/CONTRIBUTING.md | 20 ++++++++++---------- CHANGELOG.md | 1 + Otherfiles/RELEASE.md | 2 +- Otherfiles/version_check.py | 2 +- Test/overall_test.py | 2 +- pycm/__init__.py | 2 +- pycm/pycm_class_func.py | 2 +- pycm/pycm_compare.py | 2 +- pycm/pycm_curve.py | 2 +- pycm/pycm_handler.py | 2 +- pycm/pycm_multilabel_cm.py | 2 +- pycm/pycm_obj.py | 2 +- pycm/pycm_output.py | 2 +- pycm/utils.py | 2 +- 14 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3efe6d3a..2ca221d3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -27,17 +27,17 @@ Please consider the following : ## Class statistic 1. Add new functions to `pycm_class_func.py` -2. Update `CLASS_PARAMS` dictionary in `pycm_param.py` +2. Update `CLASS_PARAMS` dictionary in `params.py` 3. Update `class_statistics` function in `pycm_class_func.py` - Call statistic function and store result in `result` dictionary -4. Update `PARAMS_DESCRIPTION` dictionary in `pycm_param.py` by a short description - - If you don't want capitalization, update `CAPITALIZE_FILTER` list in `pycm_param.py` (*Optional*) +4. Update `PARAMS_DESCRIPTION` dictionary in `params.py` by a short description + - If you don't want capitalization, update `CAPITALIZE_FILTER` list in `params.py` (*Optional*) 5. Update `References` section in `Document.ipynb` (`IEEE` format) 6. Add description to `Class Statistics` section in `Document.ipynb` - Cite reference - Update table of contents - Use `LaTeX` for formula -7. Update `PARAMS_LINK` dictionary in `pycm_param.py` by document tag (without `#`) +7. Update `PARAMS_LINK` dictionary in `params.py` by document tag (without `#`) 8. Add tests to `overall_test.py` and `function_test.py` in `TEST` folder - If you have any verified test add them to `verified_test.py` 9. Run `autopep8.bat`/`autopep8.sh` (*Optional*, need to install latest version of `autopep8` package) @@ -47,7 +47,7 @@ Please consider the following : ## Overall statistic 1. Add new functions to `pycm_overall_func.py` -2. Update `OVERALL_PARAMS` dictionary in `pycm_param.py` +2. Update `OVERALL_PARAMS` dictionary in `params.py` 3. Update `overall_statistics` function in `pycm_class_func.py` - Call statistic function and store result in a variable - Add this variable to output @@ -56,7 +56,7 @@ Please consider the following : - Cite reference - Update table of contents - Use `LaTeX` for formula -6. Update `PARAMS_LINK` dictionary in `pycm_param.py` by document tag (without `#`) +6. Update `PARAMS_LINK` dictionary in `params.py` by document tag (without `#`) 7. Add tests to `overall_test.py` and `function_test.py` in `TEST` folder - If you have any verified test add them to `verified_test.py` 8. Run `autopep8.bat`/`autopep8.sh` (*Optional*, need to install latest version of `autopep8` package) @@ -65,17 +65,17 @@ Please consider the following : ## Interpretation 1. Add new interpretation table as a function to `pycm_interpret.py` -2. Add a score dictionary to `pycm_param.py` +2. Add a score dictionary to `params.py` - Example : ```PLRI_SCORE = {"Good": 4, "Fair": 3, "Poor": 2, "Negligible": 1, "None": "None"}``` -3. Add a color dictionary to `BENCHMARK_COLOR` in `pycm_param.py` +3. Add a color dictionary to `BENCHMARK_COLOR` in `params.py` - Example : ```"PLRI": {"Negligible": "Red","Poor": "Orange","Fair": "Yellow","Good": "Green","None": "White"}``` 4. If interpretation table is for a class statistic: - Step 2-7 [class statistic](#class-statistic) - - Update `CLASS_BENCHMARK_SCORE_DICT` in `pycm_param.py` + - Update `CLASS_BENCHMARK_SCORE_DICT` in `params.py` 5. If interpretation table is for a overall statistic: - Step 2-6 [overall statistic](#overall-statistic) - - Update `OVERALL_BENCHMARK_SCORE_DICT` in `pycm_param.py` + - Update `OVERALL_BENCHMARK_SCORE_DICT` in `params.py` 6. Add tests to `compare_test.py`, `overall_test.py` and `function_test.py` in `TEST` folder - If you have any verified test add them to `verified_test.py` 7. Run `autopep8.bat`/`autopep8.sh` (*Optional*, need to install latest version of `autopep8` package) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbdf003e..5b13cf55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_util.py` renamed to `utils.py` - `pycm_test.py` renamed to `basic_test.py` - `pycm_profile.py` renamed to `profile.py` +- `pycm_param.py` renamed to `params.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Otherfiles/RELEASE.md b/Otherfiles/RELEASE.md index f94d34de..f919c337 100644 --- a/Otherfiles/RELEASE.md +++ b/Otherfiles/RELEASE.md @@ -9,7 +9,7 @@ 2. `README.md` 3. `Otherfiles/version_check.py` 4. `Otherfiles/meta.yaml` - 5. `pycm/pycm_param.py` + 5. `pycm/params.py` 6. `Document/Document.ipynb` 3. Update `CHANGELOG.md` 1. Add a new header under `Unreleased` section (Example: `## [0.1] - 2022-08-17`) diff --git a/Otherfiles/version_check.py b/Otherfiles/version_check.py index c87ded80..33072794 100644 --- a/Otherfiles/version_check.py +++ b/Otherfiles/version_check.py @@ -36,7 +36,7 @@ os.path.join("Document", "Example1_files", "cm2.html"): HTML_ITEMS, os.path.join("Document", "Example1_files", "cm3.html"): HTML_ITEMS, os.path.join("Otherfiles", "test.html"): HTML_ITEMS, - os.path.join("pycm", "pycm_param.py"): PARAMS_ITEMS, + os.path.join("pycm", "params.py"): PARAMS_ITEMS, os.path.join(".github", "ISSUE_TEMPLATE", "bug_report.yml"): ISSUE_TEMPLATE_ITEMS, } diff --git a/Test/overall_test.py b/Test/overall_test.py index 0908733d..c6ba18e1 100644 --- a/Test/overall_test.py +++ b/Test/overall_test.py @@ -1272,7 +1272,7 @@ True >>> cm.imbalance True ->>> from pycm.pycm_param import IMBALANCED_RECOMMEND, MULTICLASS_RECOMMEND, BINARY_RECOMMEND +>>> from pycm.params import IMBALANCED_RECOMMEND, MULTICLASS_RECOMMEND, BINARY_RECOMMEND >>> set(cm.recommended_list) == set(IMBALANCED_RECOMMEND) True >>> cm = ConfusionMatrix(matrix={1: {1: 60, 2: 9, 3: 1, 4: 0, 5: 0, 6: 0}, 2: {1: 23, 2: 48, 3: 0, 4: 2, 5: 2, 6: 1}, 3: {1: 11, 2: 5, 3: 1, 4: 0, 5: 0, 6: 0}, 4: {1: 0, 2: 2, 3: 0, 4: 7, 5: 1, 6: 3}, 5: {1: 2, 2: 1, 3: 0, 4: 0, 5: 4, 6: 2}, 6: {1: 1, 2: 2, 3: 0, 4: 2, 5: 1, 6: 23}}) # Verified Case diff --git a/pycm/__init__.py b/pycm/__init__.py index 71e855d0..490bbe37 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """PyCM modules.""" -from .pycm_param import PYCM_VERSION, OVERALL_BENCHMARK_LIST, CLASS_BENCHMARK_LIST +from .params import PYCM_VERSION, OVERALL_BENCHMARK_LIST, CLASS_BENCHMARK_LIST from .pycm_error import * from .pycm_output import pycm_help, online_help from .pycm_distance import DistanceType diff --git a/pycm/pycm_class_func.py b/pycm/pycm_class_func.py index d8de7c11..1e54211b 100644 --- a/pycm/pycm_class_func.py +++ b/pycm/pycm_class_func.py @@ -4,7 +4,7 @@ import math from .utils import normal_quantile from .pycm_interpret import * -from .pycm_param import CLASS_PARAMS +from .params import CLASS_PARAMS def sensitivity_index_calc(TPR, FPR): diff --git a/pycm/pycm_compare.py b/pycm/pycm_compare.py index dcd04bd1..81bd3445 100644 --- a/pycm/pycm_compare.py +++ b/pycm/pycm_compare.py @@ -4,7 +4,7 @@ from .pycm_error import pycmCompareError from .pycm_output import * from .utils import * -from .pycm_param import * +from .params import * from .pycm_obj import ConfusionMatrix import os import numpy diff --git a/pycm/pycm_curve.py b/pycm/pycm_curve.py index e14e3952..7e6e3917 100644 --- a/pycm/pycm_curve.py +++ b/pycm/pycm_curve.py @@ -3,7 +3,7 @@ from __future__ import division from .pycm_error import pycmCurveError, pycmPlotError from .utils import threshold_func, thresholds_calc, isfloat -from .pycm_param import * +from .params import * from .pycm_obj import ConfusionMatrix from warnings import warn import numpy diff --git a/pycm/pycm_handler.py b/pycm/pycm_handler.py index 57886294..0420d4c2 100644 --- a/pycm/pycm_handler.py +++ b/pycm/pycm_handler.py @@ -5,7 +5,7 @@ from .pycm_error import pycmVectorError, pycmMatrixError from .pycm_overall_func import overall_statistics from .utils import * -from .pycm_param import * +from .params import * import json import types import numpy diff --git a/pycm/pycm_multilabel_cm.py b/pycm/pycm_multilabel_cm.py index 461414ea..f83aa84a 100644 --- a/pycm/pycm_multilabel_cm.py +++ b/pycm/pycm_multilabel_cm.py @@ -2,7 +2,7 @@ """MultiLabelCM module.""" from __future__ import division from .pycm_error import pycmVectorError, pycmMultiLabelError -from .pycm_param import * +from .params import * from .pycm_obj import ConfusionMatrix import numpy diff --git a/pycm/pycm_obj.py b/pycm/pycm_obj.py index 825472ad..ff76454f 100644 --- a/pycm/pycm_obj.py +++ b/pycm/pycm_obj.py @@ -10,7 +10,7 @@ from .pycm_distance import DistanceType, DISTANCE_MAPPER from .pycm_output import * from .utils import * -from .pycm_param import * +from .params import * from .pycm_ci import __CI_overall_handler__, __CI_class_handler__ import os import json diff --git a/pycm/pycm_output.py b/pycm/pycm_output.py index 6aa66089..ed0e0285 100644 --- a/pycm/pycm_output.py +++ b/pycm/pycm_output.py @@ -2,7 +2,7 @@ """Outputs functions.""" from __future__ import division from functools import partial -from .pycm_param import * +from .params import * from .utils import rounder, sort_char_num import webbrowser diff --git a/pycm/utils.py b/pycm/utils.py index c46ae290..a4eb2a9c 100644 --- a/pycm/utils.py +++ b/pycm/utils.py @@ -5,7 +5,7 @@ import math import numpy import re -from .pycm_param import * +from .params import * from .pycm_error import pycmMatrixError from warnings import warn from functools import wraps From 2854f91ec51eb2fbfa4d24eae484e06ae8c0f0b3 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:33:12 +0330 Subject: [PATCH 05/17] fix : pycm_overall_func --> overall_funcs --- .github/CONTRIBUTING.md | 2 +- CHANGELOG.md | 1 + Test/function_test.py | 2 +- Test/verified_test.py | 2 +- pycm/{pycm_overall_func.py => overall_funcs.py} | 0 pycm/{pycm_param.py => params.py} | 0 pycm/pycm_handler.py | 2 +- pycm/pycm_obj.py | 2 +- 8 files changed, 6 insertions(+), 5 deletions(-) rename pycm/{pycm_overall_func.py => overall_funcs.py} (100%) rename pycm/{pycm_param.py => params.py} (100%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2ca221d3..a1b5c6d2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -46,7 +46,7 @@ Please consider the following : ## Overall statistic -1. Add new functions to `pycm_overall_func.py` +1. Add new functions to `overall_funcs.py` 2. Update `OVERALL_PARAMS` dictionary in `params.py` 3. Update `overall_statistics` function in `pycm_class_func.py` - Call statistic function and store result in a variable diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b13cf55..09e48f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_test.py` renamed to `basic_test.py` - `pycm_profile.py` renamed to `profile.py` - `pycm_param.py` renamed to `params.py` +- `pycm_overall_func.py` renamed to `overall_funcs.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index 00d3acbd..d6b028c3 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -187,7 +187,7 @@ >>> online_help(4) ... >>> from pycm.pycm_output import * ->>> from pycm.pycm_overall_func import * +>>> from pycm.overall_funcs import * >>> from pycm.pycm_class_func import * >>> from pycm.pycm_ci import * >>> from pycm.pycm_interpret import * diff --git a/Test/verified_test.py b/Test/verified_test.py index 990660d0..183dc2ab 100644 --- a/Test/verified_test.py +++ b/Test/verified_test.py @@ -3,7 +3,7 @@ >>> import numpy as np >>> from math import isclose >>> from pycm import * ->>> from pycm.pycm_overall_func import NIR_calc +>>> from pycm.overall_funcs import NIR_calc >>> from pycm.pycm_ci import AUC_SE_calc, CI_calc >>> ABS_TOL = 1e-12 >>> REL_TOL = 0 diff --git a/pycm/pycm_overall_func.py b/pycm/overall_funcs.py similarity index 100% rename from pycm/pycm_overall_func.py rename to pycm/overall_funcs.py diff --git a/pycm/pycm_param.py b/pycm/params.py similarity index 100% rename from pycm/pycm_param.py rename to pycm/params.py diff --git a/pycm/pycm_handler.py b/pycm/pycm_handler.py index 0420d4c2..a4df842e 100644 --- a/pycm/pycm_handler.py +++ b/pycm/pycm_handler.py @@ -3,7 +3,7 @@ from __future__ import division from .pycm_class_func import class_statistics from .pycm_error import pycmVectorError, pycmMatrixError -from .pycm_overall_func import overall_statistics +from .overall_funcs import overall_statistics from .utils import * from .params import * import json diff --git a/pycm/pycm_obj.py b/pycm/pycm_obj.py index ff76454f..e46d5e4a 100644 --- a/pycm/pycm_obj.py +++ b/pycm/pycm_obj.py @@ -6,7 +6,7 @@ from .pycm_handler import __obj_assign_handler__, __obj_file_handler__, __obj_matrix_handler__, __obj_vector_handler__, __obj_array_handler__ from .pycm_handler import __imbalancement_handler__ from .pycm_class_func import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc -from .pycm_overall_func import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc +from .overall_funcs import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc from .pycm_distance import DistanceType, DISTANCE_MAPPER from .pycm_output import * from .utils import * From fcac275c3ab188f264f38fa85175c0435e346465 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:36:25 +0330 Subject: [PATCH 06/17] fix : pycm_output --> output --- CHANGELOG.md | 1 + Test/function_test.py | 2 +- pycm/__init__.py | 2 +- pycm/__main__.py | 2 +- pycm/{pycm_output.py => output.py} | 0 pycm/pycm_compare.py | 2 +- pycm/pycm_obj.py | 2 +- 7 files changed, 6 insertions(+), 5 deletions(-) rename pycm/{pycm_output.py => output.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09e48f5c..818fc4d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_profile.py` renamed to `profile.py` - `pycm_param.py` renamed to `params.py` - `pycm_overall_func.py` renamed to `overall_funcs.py` +- `pycm_output.py` renamed to `output.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index d6b028c3..dfeae69f 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -186,7 +186,7 @@ ... >>> online_help(4) ... ->>> from pycm.pycm_output import * +>>> from pycm.output import * >>> from pycm.overall_funcs import * >>> from pycm.pycm_class_func import * >>> from pycm.pycm_ci import * diff --git a/pycm/__init__.py b/pycm/__init__.py index 490bbe37..d9656276 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -2,7 +2,7 @@ """PyCM modules.""" from .params import PYCM_VERSION, OVERALL_BENCHMARK_LIST, CLASS_BENCHMARK_LIST from .pycm_error import * -from .pycm_output import pycm_help, online_help +from .output import pycm_help, online_help from .pycm_distance import DistanceType from .pycm_obj import ConfusionMatrix from .pycm_compare import Compare diff --git a/pycm/__main__.py b/pycm/__main__.py index 187b8591..dec6aacc 100644 --- a/pycm/__main__.py +++ b/pycm/__main__.py @@ -4,7 +4,7 @@ import doctest import sys from .pycm_obj import * -from .pycm_output import * +from .output import * from art import tprint diff --git a/pycm/pycm_output.py b/pycm/output.py similarity index 100% rename from pycm/pycm_output.py rename to pycm/output.py diff --git a/pycm/pycm_compare.py b/pycm/pycm_compare.py index 81bd3445..604fd573 100644 --- a/pycm/pycm_compare.py +++ b/pycm/pycm_compare.py @@ -2,7 +2,7 @@ """Compare module.""" from __future__ import division from .pycm_error import pycmCompareError -from .pycm_output import * +from .output import * from .utils import * from .params import * from .pycm_obj import ConfusionMatrix diff --git a/pycm/pycm_obj.py b/pycm/pycm_obj.py index e46d5e4a..48997e4e 100644 --- a/pycm/pycm_obj.py +++ b/pycm/pycm_obj.py @@ -8,7 +8,7 @@ from .pycm_class_func import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc from .overall_funcs import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc from .pycm_distance import DistanceType, DISTANCE_MAPPER -from .pycm_output import * +from .output import * from .utils import * from .params import * from .pycm_ci import __CI_overall_handler__, __CI_class_handler__ From 934f97d3e0d68a301afe171bd602f869879cc30c Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:39:48 +0330 Subject: [PATCH 07/17] fix : pycm_obj --> cm --- CHANGELOG.md | 1 + pycm/__init__.py | 2 +- pycm/__main__.py | 2 +- pycm/{pycm_obj.py => cm.py} | 0 pycm/pycm_compare.py | 2 +- pycm/pycm_curve.py | 2 +- pycm/pycm_multilabel_cm.py | 2 +- 7 files changed, 6 insertions(+), 5 deletions(-) rename pycm/{pycm_obj.py => cm.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 818fc4d0..b86ececc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_param.py` renamed to `params.py` - `pycm_overall_func.py` renamed to `overall_funcs.py` - `pycm_output.py` renamed to `output.py` +- `pycm_obj.py` renamed to `cm.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/__init__.py b/pycm/__init__.py index d9656276..665a440a 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -4,7 +4,7 @@ from .pycm_error import * from .output import pycm_help, online_help from .pycm_distance import DistanceType -from .pycm_obj import ConfusionMatrix +from .cm import ConfusionMatrix from .pycm_compare import Compare from .pycm_multilabel_cm import MultiLabelCM from .pycm_curve import Curve, ROCCurve, PRCurve diff --git a/pycm/__main__.py b/pycm/__main__.py index dec6aacc..1ab1f492 100644 --- a/pycm/__main__.py +++ b/pycm/__main__.py @@ -3,7 +3,7 @@ import doctest import sys -from .pycm_obj import * +from .cm import * from .output import * from art import tprint diff --git a/pycm/pycm_obj.py b/pycm/cm.py similarity index 100% rename from pycm/pycm_obj.py rename to pycm/cm.py diff --git a/pycm/pycm_compare.py b/pycm/pycm_compare.py index 604fd573..156798e6 100644 --- a/pycm/pycm_compare.py +++ b/pycm/pycm_compare.py @@ -5,7 +5,7 @@ from .output import * from .utils import * from .params import * -from .pycm_obj import ConfusionMatrix +from .cm import ConfusionMatrix import os import numpy from warnings import warn diff --git a/pycm/pycm_curve.py b/pycm/pycm_curve.py index 7e6e3917..08a35896 100644 --- a/pycm/pycm_curve.py +++ b/pycm/pycm_curve.py @@ -4,7 +4,7 @@ from .pycm_error import pycmCurveError, pycmPlotError from .utils import threshold_func, thresholds_calc, isfloat from .params import * -from .pycm_obj import ConfusionMatrix +from .cm import ConfusionMatrix from warnings import warn import numpy diff --git a/pycm/pycm_multilabel_cm.py b/pycm/pycm_multilabel_cm.py index f83aa84a..5f4b4f4f 100644 --- a/pycm/pycm_multilabel_cm.py +++ b/pycm/pycm_multilabel_cm.py @@ -3,7 +3,7 @@ from __future__ import division from .pycm_error import pycmVectorError, pycmMultiLabelError from .params import * -from .pycm_obj import ConfusionMatrix +from .cm import ConfusionMatrix import numpy From 4b3ed51f47cceb70a93452ddb524f9633199d4f9 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:41:47 +0330 Subject: [PATCH 08/17] fix : pycm_multilabel_cm --> multilabel_cm --- CHANGELOG.md | 1 + pycm/__init__.py | 2 +- pycm/{pycm_multilabel_cm.py => multilabel_cm.py} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename pycm/{pycm_multilabel_cm.py => multilabel_cm.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b86ececc..f6f9446a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_overall_func.py` renamed to `overall_funcs.py` - `pycm_output.py` renamed to `output.py` - `pycm_obj.py` renamed to `cm.py` +- `pycm_multilabel_cm.py` renamed to `multilabel_cm.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/__init__.py b/pycm/__init__.py index 665a440a..544b0c48 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -6,6 +6,6 @@ from .pycm_distance import DistanceType from .cm import ConfusionMatrix from .pycm_compare import Compare -from .pycm_multilabel_cm import MultiLabelCM +from .multilabel_cm import MultiLabelCM from .pycm_curve import Curve, ROCCurve, PRCurve __version__ = PYCM_VERSION diff --git a/pycm/pycm_multilabel_cm.py b/pycm/multilabel_cm.py similarity index 100% rename from pycm/pycm_multilabel_cm.py rename to pycm/multilabel_cm.py From 40e2e40f28532bd03d2ffb4fdb71e5bb787610cb Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:44:47 +0330 Subject: [PATCH 09/17] fix : pycm_interpret --> interpret --- .github/CONTRIBUTING.md | 2 +- CHANGELOG.md | 1 + Test/function_test.py | 2 +- pycm/{pycm_interpret.py => interpret.py} | 0 pycm/overall_funcs.py | 2 +- pycm/pycm_class_func.py | 2 +- 6 files changed, 5 insertions(+), 4 deletions(-) rename pycm/{pycm_interpret.py => interpret.py} (100%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a1b5c6d2..8860ec83 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -64,7 +64,7 @@ Please consider the following : ## Interpretation -1. Add new interpretation table as a function to `pycm_interpret.py` +1. Add new interpretation table as a function to `interpret.py` 2. Add a score dictionary to `params.py` - Example : ```PLRI_SCORE = {"Good": 4, "Fair": 3, "Poor": 2, "Negligible": 1, "None": "None"}``` 3. Add a color dictionary to `BENCHMARK_COLOR` in `params.py` diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f9446a..560f745b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_output.py` renamed to `output.py` - `pycm_obj.py` renamed to `cm.py` - `pycm_multilabel_cm.py` renamed to `multilabel_cm.py` +- `pycm_interpret.py` renamed to `interpret.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index dfeae69f..d04f49a8 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -190,7 +190,7 @@ >>> from pycm.overall_funcs import * >>> from pycm.pycm_class_func import * >>> from pycm.pycm_ci import * ->>> from pycm.pycm_interpret import * +>>> from pycm.interpret import * >>> from pycm.utils import * >>> color_check("red") [255, 0, 0] diff --git a/pycm/pycm_interpret.py b/pycm/interpret.py similarity index 100% rename from pycm/pycm_interpret.py rename to pycm/interpret.py diff --git a/pycm/overall_funcs.py b/pycm/overall_funcs.py index a9f4b42c..13ae175d 100644 --- a/pycm/overall_funcs.py +++ b/pycm/overall_funcs.py @@ -4,7 +4,7 @@ import math import operator as op from functools import reduce -from .pycm_interpret import * +from .interpret import * from .pycm_ci import kappa_SE_calc, CI_calc, SE_calc from .utils import complement diff --git a/pycm/pycm_class_func.py b/pycm/pycm_class_func.py index 1e54211b..d7b5fa08 100644 --- a/pycm/pycm_class_func.py +++ b/pycm/pycm_class_func.py @@ -3,7 +3,7 @@ from __future__ import division import math from .utils import normal_quantile -from .pycm_interpret import * +from .interpret import * from .params import CLASS_PARAMS From 74edd45ac872b08670ad2a6942c0599851bc33ee Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:46:41 +0330 Subject: [PATCH 10/17] fix : pycm_handler --> handlers --- CHANGELOG.md | 1 + pycm/cm.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 560f745b..045d05ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_obj.py` renamed to `cm.py` - `pycm_multilabel_cm.py` renamed to `multilabel_cm.py` - `pycm_interpret.py` renamed to `interpret.py` +- `pycm_handler.py` renamed to `handlers.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/cm.py b/pycm/cm.py index 48997e4e..cd139cf3 100644 --- a/pycm/cm.py +++ b/pycm/cm.py @@ -2,9 +2,9 @@ """ConfusionMatrix module.""" from __future__ import division from .pycm_error import pycmVectorError, pycmMatrixError, pycmCIError, pycmAverageError, pycmPlotError -from .pycm_handler import __class_stat_init__, __overall_stat_init__ -from .pycm_handler import __obj_assign_handler__, __obj_file_handler__, __obj_matrix_handler__, __obj_vector_handler__, __obj_array_handler__ -from .pycm_handler import __imbalancement_handler__ +from .handlers import __class_stat_init__, __overall_stat_init__ +from .handlers import __obj_assign_handler__, __obj_file_handler__, __obj_matrix_handler__, __obj_vector_handler__, __obj_array_handler__ +from .handlers import __imbalancement_handler__ from .pycm_class_func import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc from .overall_funcs import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc from .pycm_distance import DistanceType, DISTANCE_MAPPER From 76985f1ed9162297f9ad00dd35f476063495b69d Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 11:52:36 +0330 Subject: [PATCH 11/17] fix : pycm_error --> errors --- CHANGELOG.md | 1 + Test/error_test.py | 146 +++++++++++++------------- Test/plot_error_test.py | 6 +- Test/plot_test.py | 4 +- pycm/__init__.py | 2 +- pycm/cm.py | 2 +- pycm/{pycm_error.py => errors.py} | 0 pycm/{pycm_handler.py => handlers.py} | 2 +- pycm/multilabel_cm.py | 2 +- pycm/pycm_compare.py | 2 +- pycm/pycm_curve.py | 2 +- pycm/utils.py | 2 +- 12 files changed, 86 insertions(+), 85 deletions(-) rename pycm/{pycm_error.py => errors.py} (100%) rename pycm/{pycm_handler.py => handlers.py} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 045d05ac..e25f01b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_multilabel_cm.py` renamed to `multilabel_cm.py` - `pycm_interpret.py` renamed to `interpret.py` - `pycm_handler.py` renamed to `handlers.py` +- `pycm_error.py` renamed to `errors.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/error_test.py b/Test/error_test.py index 7afd2db9..9cf46483 100644 --- a/Test/error_test.py +++ b/Test/error_test.py @@ -8,310 +8,310 @@ >>> cm_2 = ConfusionMatrix(y_actu, 2) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must be provided as a list or a NumPy array. +pycm.errors.pycmVectorError: Input vectors must be provided as a list or a NumPy array. >>> cm_3 = ConfusionMatrix(y_actu, [1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must have the same length. +pycm.errors.pycmVectorError: Input vectors must have the same length. >>> cm_4 = ConfusionMatrix([], []) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must not be empty. +pycm.errors.pycmVectorError: Input vectors must not be empty. >>> cm_5 = ConfusionMatrix([1, 1, 1, ], [1, 1, 1, 1]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must have the same length. +pycm.errors.pycmVectorError: Input vectors must have the same length. >>> cm_6 = ConfusionMatrix(matrix={0: {0: 2, 1: 50, 2: 6}, 1: {0: 5, 1: 50, 2: 3}, 2: {0: 1, 1: 7, 2: 50}}) >>> cm_6.position() Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: This option is only available in vector mode. +pycm.errors.pycmVectorError: This option is only available in vector mode. >>> cm = ConfusionMatrix([1, 2, 3, 4], [1, 2, 3, 4], classes=[1, 2, 2, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: `classes` must contain unique labels with no duplicates. +pycm.errors.pycmVectorError: `classes` must contain unique labels with no duplicates. >>> cm3=ConfusionMatrix(matrix={}) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: Invalid input confusion matrix format. +pycm.errors.pycmMatrixError: Invalid input confusion matrix format. >>> cm_4=ConfusionMatrix(matrix={1: {1: 2, "1": 2}, "1": {1: 2, "1": 3}}) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: All input matrix classes must be of the same type. +pycm.errors.pycmMatrixError: All input matrix classes must be of the same type. >>> cm_5=ConfusionMatrix(matrix={1: {1: 2}}) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: The number of classes must be at least 2. +pycm.errors.pycmMatrixError: The number of classes must be at least 2. >>> cm = ConfusionMatrix([1, 2, 3, 4], [1, 2, 3, 4], classes=[1]) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: The number of classes must be at least 2. +pycm.errors.pycmMatrixError: The number of classes must be at least 2. >>> cm = ConfusionMatrix([1, 1, 1, 1], [1, 2, 1, 1], classes=[]) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: The number of classes must be at least 2. +pycm.errors.pycmMatrixError: The number of classes must be at least 2. >>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2] >>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2] >>> cm = ConfusionMatrix(y_actu, y_pred) >>> cm.distance(metric = 2) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: `metric` type must be DistanceType. +pycm.errors.pycmMatrixError: `metric` type must be DistanceType. >>> cm.relabel([1, 2, 3]) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: Invalid mapping format. +pycm.errors.pycmMatrixError: Invalid mapping format. >>> cm.relabel({1: "L1", 2: "L2"}) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: Invalid mapping class names. +pycm.errors.pycmMatrixError: Invalid mapping class names. >>> cm.relabel({0: "L1", 1: "L2", 2: "L2"}) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: Invalid mapping class names. +pycm.errors.pycmMatrixError: Invalid mapping class names. >>> cp = Compare([cm, cm]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: Input must be provided as a dictionary. +pycm.errors.pycmCompareError: Input must be provided as a dictionary. >>> cp = Compare({"cm1": cm}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: At least 2 confusion matrices are required for comparison. +pycm.errors.pycmCompareError: At least 2 confusion matrices are required for comparison. >>> cp = Compare({"cm1": cm, "cm2": []}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: Input must be a dictionary containing pycm.ConfusionMatrix objects. +pycm.errors.pycmCompareError: Input must be a dictionary containing pycm.ConfusionMatrix objects. >>> cm2 = ConfusionMatrix(matrix={"Class1": {"Class1": 9, "Class2": 3, "Class3": 0}, "Class2": {"Class1": 3, "Class2": 5, "Class3": 1}, "Class3": {"Class1": 1, "Class2": 1, "Class3": 4}}) >>> cp = Compare({"cm1": cm, "cm2": cm2}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: All ConfusionMatrix objects must have the same domain (same sample size and number of classes). +pycm.errors.pycmCompareError: All ConfusionMatrix objects must have the same domain (same sample size and number of classes). >>> cm = ConfusionMatrix(matrix={1: {1: 9, 2: 3}, 2: {1: 3, 2: 5}}, classes=[1, 2, 3]) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: The specified classes are not a subset of the matrix's classes. +pycm.errors.pycmMatrixError: The specified classes are not a subset of the matrix's classes. >>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 1] >>> cm3 = ConfusionMatrix(y_actu, y_pred) >>> cp = Compare({"cm1": cm, "cm2": cm3}, by_class=True, class_weight={1: 1, 2: 1}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: `class_weight` must be a dictionary and specified for all classes. +pycm.errors.pycmCompareError: `class_weight` must be a dictionary and specified for all classes. >>> cp = Compare({"cm1": cm, "cm2": cm3}, by_class=True, class_weight=[]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: `class_weight` must be a dictionary and specified for all classes. +pycm.errors.pycmCompareError: `class_weight` must be a dictionary and specified for all classes. >>> cp = Compare({"cm1": cm, "cm2": cm3}, by_class=True, class_benchmark_weight=[]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: `class_benchmark_weight` must be a dictionary and specified for all class benchmarks. +pycm.errors.pycmCompareError: `class_benchmark_weight` must be a dictionary and specified for all class benchmarks. >>> cp = Compare({"cm1": cm, "cm2": cm3}, by_class=True, overall_benchmark_weight=[]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: `overall_benchmark_weight` must be a dictionary and specified for all overall benchmarks. +pycm.errors.pycmCompareError: `overall_benchmark_weight` must be a dictionary and specified for all overall benchmarks. >>> cm1 = ConfusionMatrix([1, 1, 1, 0], [1, 0, 1, 1], metrics_off=True) >>> cm2 = ConfusionMatrix([1, 1, 1, 0], [1, 0, 1, 1], metrics_off=False) >>> cp = Compare({"cm1":cm1, "cm2":cm2}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCompareError: Comparison cannot be performed when `metrics_off=True` in any matrix. +pycm.errors.pycmCompareError: Comparison cannot be performed when `metrics_off=True` in any matrix. >>> cm.CI("MCC") Traceback (most recent call last): ... -pycm.pycm_error.pycmCIError: Confidence interval calculation for this parameter is not supported in this version of pycm. +pycm.errors.pycmCIError: Confidence interval calculation for this parameter is not supported in this version of pycm. Supported parameters are: TPR, TNR, PPV, NPV, ACC, PLR, NLR, FPR, FNR, AUC, PRE, Kappa, Overall ACC >>> cm.CI(2) Traceback (most recent call last): ... -pycm.pycm_error.pycmCIError: Input must be provided as a string. +pycm.errors.pycmCIError: Input must be provided as a string. >>> cm.average("AUCC") Traceback (most recent call last): ... -pycm.pycm_error.pycmAverageError: Invalid parameter! +pycm.errors.pycmAverageError: Invalid parameter! >>> cm.weighted_average("AUCC") Traceback (most recent call last): ... -pycm.pycm_error.pycmAverageError: Invalid parameter! +pycm.errors.pycmAverageError: Invalid parameter! >>> cm.weighted_average("AUC", weight=2) Traceback (most recent call last): ... -pycm.pycm_error.pycmAverageError: `weight` must be a dictionary and specified for all classes. +pycm.errors.pycmAverageError: `weight` must be a dictionary and specified for all classes. >>> cm.weighted_average("AUC", weight={1: 23}) Traceback (most recent call last): ... -pycm.pycm_error.pycmAverageError: `weight` must be a dictionary and specified for all classes. +pycm.errors.pycmAverageError: `weight` must be a dictionary and specified for all classes. >>> cm.combine(1) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: Input must be an instance of pycm.ConfusionMatrix. +pycm.errors.pycmMatrixError: Input must be an instance of pycm.ConfusionMatrix. >>> cm = ConfusionMatrix([1, 0, 2, 0], [1, 1, 2, 1]) >>> cm.brier_score() Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: This option is only available in binary probability mode. +pycm.errors.pycmVectorError: This option is only available in binary probability mode. >>> cm.log_loss() Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: This option is only available in binary probability mode. +pycm.errors.pycmVectorError: This option is only available in binary probability mode. >>> cm = ConfusionMatrix(["ham", "spam", "ham", "ham"], [0.1, 0.4, 0.25, 1], threshold=lambda x : "ham") >>> cm.brier_score() Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Actual vector contains strings; `pos_class` must be explicitly specified. +pycm.errors.pycmVectorError: Actual vector contains strings; `pos_class` must be explicitly specified. >>> cm.log_loss() Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Actual vector contains strings; `pos_class` must be explicitly specified. +pycm.errors.pycmVectorError: Actual vector contains strings; `pos_class` must be explicitly specified. >>> matrix = [[1, 2, 3], [4, 6, 1], [1, 2, 3]] >>> cm = ConfusionMatrix(matrix=matrix, classes=["L1", "L1", "L3", "L2"]) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: `classes` must contain unique labels with no duplicates. +pycm.errors.pycmMatrixError: `classes` must contain unique labels with no duplicates. >>> cm = ConfusionMatrix(matrix=matrix, classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: The length of the classes does not match the length of the array. +pycm.errors.pycmMatrixError: The length of the classes does not match the length of the array. >>> crv = Curve([1, 2, 2, 1], {1, 2, 2, 1}, classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: Input vectors must be provided as a list or a NumPy array. +pycm.errors.pycmCurveError: Input vectors must be provided as a list or a NumPy array. >>> crv = Curve({1, 2, 2, 1}, [1, 2, 2, 1], classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: Input vectors must be provided as a list or a NumPy array. +pycm.errors.pycmCurveError: Input vectors must be provided as a list or a NumPy array. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9]], classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: Input vectors must have the same length. +pycm.errors.pycmCurveError: Input vectors must have the same length. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.2, 0.9]], classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: The sum of the probability values must equal 1. +pycm.errors.pycmCurveError: The sum of the probability values must equal 1. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.1, 0.9]], classes={1, 2}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: `classes` must be provided as a list. +pycm.errors.pycmCurveError: `classes` must be provided as a list. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.1, 0.9]], classes=[1, 2, 3]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: `classes` does not match the actual vector. +pycm.errors.pycmCurveError: `classes` does not match the actual vector. >>> crv = Curve([1, 1, 1, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.1, 0.9]], classes=[1]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: The number of classes must be at least 2. +pycm.errors.pycmCurveError: The number of classes must be at least 2. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.2, "salam"]], classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: Probability vector elements must be numeric. +pycm.errors.pycmCurveError: Probability vector elements must be numeric. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.2, 0.8]], classes=[1, 2], thresholds={1, 2}) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: `thresholds` must be provided as a list or a NumPy array. +pycm.errors.pycmCurveError: `thresholds` must be provided as a list or a NumPy array. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.2, 0.8]], classes=[1, 2], thresholds=[0.1]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: The number of thresholds must be at least 2. +pycm.errors.pycmCurveError: The number of thresholds must be at least 2. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.2, 0.8]], classes=[1, 2], thresholds=[0.1, "q"]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: `thresholds` must contain only numeric values. +pycm.errors.pycmCurveError: `thresholds` must contain only numeric values. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.9], [0.2, 0.8]], classes=[1, 1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: `classes` must contain unique labels with no duplicates. +pycm.errors.pycmCurveError: `classes` must contain unique labels with no duplicates. >>> crv = Curve([1, 2, 2, 1], [[0.1, 0.9], [0.1, 0.9], [0.1, 0.8, 0.1], [0.2, 0.8]], classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: All elements of the probability vector must have the same length and match the number of classes. +pycm.errors.pycmCurveError: All elements of the probability vector must have the same length and match the number of classes. >>> crv = Curve([1, 2, 2, 1], [[1], [1], [1], [1]], classes=[1, 2]) Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: All elements of the probability vector must have the same length and match the number of classes. +pycm.errors.pycmCurveError: All elements of the probability vector must have the same length and match the number of classes. >>> crv = Curve(actual_vector = np.array([1, 1, 2, 2]), probs = np.array([[0.1, 0.9], [0.4, 0.6], [0.35, 0.65], [0.8, 0.2]]), classes=[2, 1]) >>> crv.area(method="trpz") Traceback (most recent call last): ... -pycm.pycm_error.pycmCurveError: The integral method must be either 'trapezoidal' or 'midpoint'. +pycm.errors.pycmCurveError: The integral method must be either 'trapezoidal' or 'midpoint'. >>> cm = ConfusionMatrix(y_actu, y_pred, metrics_off=True) >>> cm.stat() Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.sensitivity_index() Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.IBA_alpha(0.2) Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.NB() Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.CI("Kappa") Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.average("ACC") Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.weighted_average("ACC") Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.weighted_kappa() Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.weighted_alpha() Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> cm.aickin_alpha() Traceback (most recent call last): ... -pycm.pycm_error.pycmMatrixError: This method cannot be executed when `metrics_off=True`. +pycm.errors.pycmMatrixError: This method cannot be executed when `metrics_off=True`. >>> mlcm = MultiLabelCM([[0, 1], [1, 1]], [[1, 0], [1, 0]]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Failed to extract classes from input. Input vectors should be a list of sets with unified types. +pycm.errors.pycmVectorError: Failed to extract classes from input. Input vectors should be a list of sets with unified types. >>> mlcm = MultiLabelCM([{'dog'}, {'cat', 'dog'}], ['cat', {'cat'}]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Failed to extract classes from input. Input vectors should be a list of sets with unified types. +pycm.errors.pycmVectorError: Failed to extract classes from input. Input vectors should be a list of sets with unified types. >>> mlcm = MultiLabelCM(['dog', {'cat', 'dog'}], [{'cat'}, {'cat'}]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Failed to extract classes from input. Input vectors should be a list of sets with unified types. +pycm.errors.pycmVectorError: Failed to extract classes from input. Input vectors should be a list of sets with unified types. >>> mlcm = MultiLabelCM([{'dog'}, {'cat', 'dog'}], [{'cat'}, {'cat'}]) >>> mlcm.get_cm_by_class(1) Traceback (most recent call last): ... -pycm.pycm_error.pycmMultiLabelError: The specified class name is not among the confusion matrix's classes. +pycm.errors.pycmMultiLabelError: The specified class name is not among the confusion matrix's classes. >>> mlcm.get_cm_by_sample(2) Traceback (most recent call last): ... -pycm.pycm_error.pycmMultiLabelError: Index is out of range for the given vector. +pycm.errors.pycmMultiLabelError: Index is out of range for the given vector. >>> mlcm = MultiLabelCM([{'dog'}, {'cat', 'dog'}], [{'cat'}, {'cat', 'bird'}], classes=['dog', 'cat']) >>> mlcm.get_cm_by_class('bird') Traceback (most recent call last): ... -pycm.pycm_error.pycmMultiLabelError: The specified class name is not among the confusion matrix's classes. +pycm.errors.pycmMultiLabelError: The specified class name is not among the confusion matrix's classes. >>> mlcm = MultiLabelCM(2, [[1, 0], [1, 0]]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must be provided as a list or a NumPy array. +pycm.errors.pycmVectorError: Input vectors must be provided as a list or a NumPy array. >>> mlcm = MultiLabelCM([{1, 0}, {1, 0}, {1,1}], [{1, 0}, {1, 0}]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must have the same length. +pycm.errors.pycmVectorError: Input vectors must have the same length. >>> mlcm = MultiLabelCM([], []) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: Input vectors must not be empty. +pycm.errors.pycmVectorError: Input vectors must not be empty. >>> mlcm = MultiLabelCM([{1, 0}, {1, 0}], [{1, 0}, {1, 0}], classes=[1,0,1]) Traceback (most recent call last): ... -pycm.pycm_error.pycmVectorError: `classes` must contain unique labels with no duplicates. +pycm.errors.pycmVectorError: `classes` must contain unique labels with no duplicates. """ diff --git a/Test/plot_error_test.py b/Test/plot_error_test.py index a3c66f95..b5f51822 100644 --- a/Test/plot_error_test.py +++ b/Test/plot_error_test.py @@ -18,14 +18,14 @@ >>> ax = cm.plot() Traceback (most recent call last): ... -pycm.pycm_error.pycmPlotError: Failed to import matplotlib module. Please install it using: `pip install matplotlib`. +pycm.errors.pycmPlotError: Failed to import matplotlib module. Please install it using: `pip install matplotlib`. >>> ax = cm.plot(plot_lib='seaborn') Traceback (most recent call last): ... -pycm.pycm_error.pycmPlotError: Failed to import matplotlib module. Please install it using: `pip install matplotlib`. +pycm.errors.pycmPlotError: Failed to import matplotlib module. Please install it using: `pip install matplotlib`. >>> crv = Curve(actual_vector = np.array([1, 1, 2, 2]), probs = np.array([[0.1, 0.9], [0.4, 0.6], [0.35, 0.65], [0.8, 0.2]]), classes=[2, 1]) >>> ax = crv.plot(classes=[1]) Traceback (most recent call last): ... -pycm.pycm_error.pycmPlotError: Failed to import matplotlib module. Please install it using: `pip install matplotlib`. +pycm.errors.pycmPlotError: Failed to import matplotlib module. Please install it using: `pip install matplotlib`. """ diff --git a/Test/plot_test.py b/Test/plot_test.py index 4957482b..284c89a6 100644 --- a/Test/plot_test.py +++ b/Test/plot_test.py @@ -207,11 +207,11 @@ >>> crv.plot(colors=['c']) Traceback (most recent call last): ... -pycm.pycm_error.pycmPlotError: The number of colors does not match the number of classes. +pycm.errors.pycmPlotError: The number of colors does not match the number of classes. >>> crv.plot(markers=['*']) Traceback (most recent call last): ... -pycm.pycm_error.pycmPlotError: The number of markers does not match the number of classes. +pycm.errors.pycmPlotError: The number of markers does not match the number of classes. >>> ax = crv.plot(classes=[1]) >>> ax.get_figure()._suptitle.get_text() 'FPR per TPR' diff --git a/pycm/__init__.py b/pycm/__init__.py index 544b0c48..17e5782d 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """PyCM modules.""" from .params import PYCM_VERSION, OVERALL_BENCHMARK_LIST, CLASS_BENCHMARK_LIST -from .pycm_error import * +from .errors import * from .output import pycm_help, online_help from .pycm_distance import DistanceType from .cm import ConfusionMatrix diff --git a/pycm/cm.py b/pycm/cm.py index cd139cf3..85e5b154 100644 --- a/pycm/cm.py +++ b/pycm/cm.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ConfusionMatrix module.""" from __future__ import division -from .pycm_error import pycmVectorError, pycmMatrixError, pycmCIError, pycmAverageError, pycmPlotError +from .errors import pycmVectorError, pycmMatrixError, pycmCIError, pycmAverageError, pycmPlotError from .handlers import __class_stat_init__, __overall_stat_init__ from .handlers import __obj_assign_handler__, __obj_file_handler__, __obj_matrix_handler__, __obj_vector_handler__, __obj_array_handler__ from .handlers import __imbalancement_handler__ diff --git a/pycm/pycm_error.py b/pycm/errors.py similarity index 100% rename from pycm/pycm_error.py rename to pycm/errors.py diff --git a/pycm/pycm_handler.py b/pycm/handlers.py similarity index 99% rename from pycm/pycm_handler.py rename to pycm/handlers.py index a4df842e..fa86bbc2 100644 --- a/pycm/pycm_handler.py +++ b/pycm/handlers.py @@ -2,7 +2,7 @@ """ConfusionMatrix handlers.""" from __future__ import division from .pycm_class_func import class_statistics -from .pycm_error import pycmVectorError, pycmMatrixError +from .errors import pycmVectorError, pycmMatrixError from .overall_funcs import overall_statistics from .utils import * from .params import * diff --git a/pycm/multilabel_cm.py b/pycm/multilabel_cm.py index 5f4b4f4f..8626d1c8 100644 --- a/pycm/multilabel_cm.py +++ b/pycm/multilabel_cm.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """MultiLabelCM module.""" from __future__ import division -from .pycm_error import pycmVectorError, pycmMultiLabelError +from .errors import pycmVectorError, pycmMultiLabelError from .params import * from .cm import ConfusionMatrix import numpy diff --git a/pycm/pycm_compare.py b/pycm/pycm_compare.py index 156798e6..2393d57f 100644 --- a/pycm/pycm_compare.py +++ b/pycm/pycm_compare.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Compare module.""" from __future__ import division -from .pycm_error import pycmCompareError +from .errors import pycmCompareError from .output import * from .utils import * from .params import * diff --git a/pycm/pycm_curve.py b/pycm/pycm_curve.py index 08a35896..e541b554 100644 --- a/pycm/pycm_curve.py +++ b/pycm/pycm_curve.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Curve module.""" from __future__ import division -from .pycm_error import pycmCurveError, pycmPlotError +from .errors import pycmCurveError, pycmPlotError from .utils import threshold_func, thresholds_calc, isfloat from .params import * from .cm import ConfusionMatrix diff --git a/pycm/utils.py b/pycm/utils.py index a4eb2a9c..a54a6115 100644 --- a/pycm/utils.py +++ b/pycm/utils.py @@ -6,7 +6,7 @@ import numpy import re from .params import * -from .pycm_error import pycmMatrixError +from .errors import pycmMatrixError from warnings import warn from functools import wraps From 6df2621d2ffb7a00dc245140759fc76c8141a52f Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 12:24:01 +0330 Subject: [PATCH 12/17] fix : pycm_distance --> distance --- CHANGELOG.md | 1 + Test/function_test.py | 2 +- pycm/__init__.py | 2 +- pycm/cm.py | 2 +- pycm/{pycm_distance.py => distance.py} | 0 5 files changed, 4 insertions(+), 3 deletions(-) rename pycm/{pycm_distance.py => distance.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e25f01b6..92f8441e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_interpret.py` renamed to `interpret.py` - `pycm_handler.py` renamed to `handlers.py` - `pycm_error.py` renamed to `errors.py` +- `pycm_distance.py` renamed to `distance.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index d04f49a8..29107831 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -2,7 +2,7 @@ """ >>> from math import isclose >>> from pycm import * ->>> from pycm.pycm_distance import DISTANCE_MAPPER +>>> from pycm.distance import DISTANCE_MAPPER >>> import os >>> import json >>> import numpy as np diff --git a/pycm/__init__.py b/pycm/__init__.py index 17e5782d..05532bf6 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -3,7 +3,7 @@ from .params import PYCM_VERSION, OVERALL_BENCHMARK_LIST, CLASS_BENCHMARK_LIST from .errors import * from .output import pycm_help, online_help -from .pycm_distance import DistanceType +from .distance import DistanceType from .cm import ConfusionMatrix from .pycm_compare import Compare from .multilabel_cm import MultiLabelCM diff --git a/pycm/cm.py b/pycm/cm.py index 85e5b154..c688c409 100644 --- a/pycm/cm.py +++ b/pycm/cm.py @@ -7,7 +7,7 @@ from .handlers import __imbalancement_handler__ from .pycm_class_func import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc from .overall_funcs import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc -from .pycm_distance import DistanceType, DISTANCE_MAPPER +from .distance import DistanceType, DISTANCE_MAPPER from .output import * from .utils import * from .params import * diff --git a/pycm/pycm_distance.py b/pycm/distance.py similarity index 100% rename from pycm/pycm_distance.py rename to pycm/distance.py From a6e3c71a40c05d6c843cf20c1a5be49a4fd95e4c Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 12:25:20 +0330 Subject: [PATCH 13/17] fix : pycm_curve --> curve --- CHANGELOG.md | 1 + pycm/__init__.py | 2 +- pycm/{pycm_curve.py => curve.py} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename pycm/{pycm_curve.py => curve.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f8441e..4305fd8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_handler.py` renamed to `handlers.py` - `pycm_error.py` renamed to `errors.py` - `pycm_distance.py` renamed to `distance.py` +- `pycm_curve.py` renamed to `curve.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/__init__.py b/pycm/__init__.py index 05532bf6..77ed2ec4 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -7,5 +7,5 @@ from .cm import ConfusionMatrix from .pycm_compare import Compare from .multilabel_cm import MultiLabelCM -from .pycm_curve import Curve, ROCCurve, PRCurve +from .curve import Curve, ROCCurve, PRCurve __version__ = PYCM_VERSION diff --git a/pycm/pycm_curve.py b/pycm/curve.py similarity index 100% rename from pycm/pycm_curve.py rename to pycm/curve.py From 5babe4f7a4ffa6e9dad9db31e8e70289e8f2977f Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 12:26:40 +0330 Subject: [PATCH 14/17] fix : pycm_compare --> compare --- CHANGELOG.md | 1 + pycm/__init__.py | 2 +- pycm/{pycm_compare.py => compare.py} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename pycm/{pycm_compare.py => compare.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4305fd8b..949001dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_error.py` renamed to `errors.py` - `pycm_distance.py` renamed to `distance.py` - `pycm_curve.py` renamed to `curve.py` +- `pycm_compare.py` renamed to `compare.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/pycm/__init__.py b/pycm/__init__.py index 77ed2ec4..4d1bcadb 100644 --- a/pycm/__init__.py +++ b/pycm/__init__.py @@ -5,7 +5,7 @@ from .output import pycm_help, online_help from .distance import DistanceType from .cm import ConfusionMatrix -from .pycm_compare import Compare +from .compare import Compare from .multilabel_cm import MultiLabelCM from .curve import Curve, ROCCurve, PRCurve __version__ = PYCM_VERSION diff --git a/pycm/pycm_compare.py b/pycm/compare.py similarity index 100% rename from pycm/pycm_compare.py rename to pycm/compare.py From 270d2f82629d7eb0220f4ff334f261086fe0d656 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 12:29:57 +0330 Subject: [PATCH 15/17] fix : pycm_class_func --> class_funcs --- .github/CONTRIBUTING.md | 6 +++--- CHANGELOG.md | 1 + Test/function_test.py | 2 +- pycm/{pycm_class_func.py => class_funcs.py} | 0 pycm/cm.py | 2 +- pycm/handlers.py | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) rename pycm/{pycm_class_func.py => class_funcs.py} (100%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8860ec83..cf60a45e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -26,9 +26,9 @@ Please consider the following : ## Class statistic -1. Add new functions to `pycm_class_func.py` +1. Add new functions to `class_funcs.py` 2. Update `CLASS_PARAMS` dictionary in `params.py` -3. Update `class_statistics` function in `pycm_class_func.py` +3. Update `class_statistics` function in `class_funcs.py` - Call statistic function and store result in `result` dictionary 4. Update `PARAMS_DESCRIPTION` dictionary in `params.py` by a short description - If you don't want capitalization, update `CAPITALIZE_FILTER` list in `params.py` (*Optional*) @@ -48,7 +48,7 @@ Please consider the following : 1. Add new functions to `overall_funcs.py` 2. Update `OVERALL_PARAMS` dictionary in `params.py` -3. Update `overall_statistics` function in `pycm_class_func.py` +3. Update `overall_statistics` function in `class_funcs.py` - Call statistic function and store result in a variable - Add this variable to output 4. Update `References` section in `Document.ipynb` (`IEEE` format) diff --git a/CHANGELOG.md b/CHANGELOG.md index 949001dd..680acf77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_distance.py` renamed to `distance.py` - `pycm_curve.py` renamed to `curve.py` - `pycm_compare.py` renamed to `compare.py` +- `pycm_class_func.py` renamed to `class_funcs.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index 29107831..85e697ca 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -188,7 +188,7 @@ ... >>> from pycm.output import * >>> from pycm.overall_funcs import * ->>> from pycm.pycm_class_func import * +>>> from pycm.class_funcs import * >>> from pycm.pycm_ci import * >>> from pycm.interpret import * >>> from pycm.utils import * diff --git a/pycm/pycm_class_func.py b/pycm/class_funcs.py similarity index 100% rename from pycm/pycm_class_func.py rename to pycm/class_funcs.py diff --git a/pycm/cm.py b/pycm/cm.py index c688c409..ce2ea184 100644 --- a/pycm/cm.py +++ b/pycm/cm.py @@ -5,7 +5,7 @@ from .handlers import __class_stat_init__, __overall_stat_init__ from .handlers import __obj_assign_handler__, __obj_file_handler__, __obj_matrix_handler__, __obj_vector_handler__, __obj_array_handler__ from .handlers import __imbalancement_handler__ -from .pycm_class_func import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc +from .class_funcs import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc from .overall_funcs import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc from .distance import DistanceType, DISTANCE_MAPPER from .output import * diff --git a/pycm/handlers.py b/pycm/handlers.py index fa86bbc2..d525bb40 100644 --- a/pycm/handlers.py +++ b/pycm/handlers.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ConfusionMatrix handlers.""" from __future__ import division -from .pycm_class_func import class_statistics +from .class_funcs import class_statistics from .errors import pycmVectorError, pycmMatrixError from .overall_funcs import overall_statistics from .utils import * From be9d671bc68e863723ce291d9fb34fdf4575bc7f Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 12:32:28 +0330 Subject: [PATCH 16/17] fix : pycm_ci --> ci --- CHANGELOG.md | 1 + Test/function_test.py | 2 +- Test/verified_test.py | 2 +- pycm/{pycm_ci.py => ci.py} | 0 pycm/cm.py | 2 +- pycm/overall_funcs.py | 2 +- 6 files changed, 5 insertions(+), 4 deletions(-) rename pycm/{pycm_ci.py => ci.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 680acf77..1fd0ed08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `pycm_curve.py` renamed to `curve.py` - `pycm_compare.py` renamed to `compare.py` - `pycm_class_func.py` renamed to `class_funcs.py` +- `pycm_ci.py` renamed to `ci.py` ## [4.0] - 2023-06-07 ### Added - `pycmMultiLabelError` class diff --git a/Test/function_test.py b/Test/function_test.py index 85e697ca..f0d6574f 100644 --- a/Test/function_test.py +++ b/Test/function_test.py @@ -189,7 +189,7 @@ >>> from pycm.output import * >>> from pycm.overall_funcs import * >>> from pycm.class_funcs import * ->>> from pycm.pycm_ci import * +>>> from pycm.ci import * >>> from pycm.interpret import * >>> from pycm.utils import * >>> color_check("red") diff --git a/Test/verified_test.py b/Test/verified_test.py index 183dc2ab..c04e4c75 100644 --- a/Test/verified_test.py +++ b/Test/verified_test.py @@ -4,7 +4,7 @@ >>> from math import isclose >>> from pycm import * >>> from pycm.overall_funcs import NIR_calc ->>> from pycm.pycm_ci import AUC_SE_calc, CI_calc +>>> from pycm.ci import AUC_SE_calc, CI_calc >>> ABS_TOL = 1e-12 >>> REL_TOL = 0 >>> assert isclose(NIR_calc({'Class2': 804, 'Class1': 196}, 1000), 0.804, abs_tol=ABS_TOL, rel_tol=REL_TOL) # Verified Case - (Caret package) diff --git a/pycm/pycm_ci.py b/pycm/ci.py similarity index 100% rename from pycm/pycm_ci.py rename to pycm/ci.py diff --git a/pycm/cm.py b/pycm/cm.py index ce2ea184..a82194e4 100644 --- a/pycm/cm.py +++ b/pycm/cm.py @@ -11,7 +11,7 @@ from .output import * from .utils import * from .params import * -from .pycm_ci import __CI_overall_handler__, __CI_class_handler__ +from .ci import __CI_overall_handler__, __CI_class_handler__ import os import json import numpy diff --git a/pycm/overall_funcs.py b/pycm/overall_funcs.py index 13ae175d..618fe029 100644 --- a/pycm/overall_funcs.py +++ b/pycm/overall_funcs.py @@ -5,7 +5,7 @@ import operator as op from functools import reduce from .interpret import * -from .pycm_ci import kappa_SE_calc, CI_calc, SE_calc +from .ci import kappa_SE_calc, CI_calc, SE_calc from .utils import complement From f7386590540f710aaca581afb982ac4feb018bd4 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 8 Oct 2024 12:33:49 +0330 Subject: [PATCH 17/17] doc : CONTRIBUTING.md updated --- .github/CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cf60a45e..8942bee4 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,4 +1,6 @@ -# Contribution +# Contribution + +**Last Update: 2024-10-08** Changes and improvements are more than welcome! ❤️ Feel free to fork and open a pull request.