diff --git a/README.md b/README.md index af99720..54cb611 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,14 @@ for ix in range(n_samples): criterion_values = my_cvi.get_cvi(samples[ix, :], labels[ix]) ``` +Users can also query the `.info` property of the CVI objects to obtain relevant +scaling and naming information. + +``` +>>> print(my_cvi.info) +CVIInfo(name='Calinski-Harabasz', name_short='CH', index_min=0.0, index_max=inf, optimality='max') +``` + ### Detailed Usage The `cvi` package contains a set of implemented CVIs with batch and incremental update methods. diff --git a/src/cvi/modules/CH.py b/src/cvi/modules/CH.py index 8a26113..6773009 100644 --- a/src/cvi/modules/CH.py +++ b/src/cvi/modules/CH.py @@ -28,6 +28,13 @@ class CH(_base.CVI): 3. M. Moshtaghi, J. C. Bezdek, S. M. Erfani, C. Leckie, and J. Bailey, "Online Cluster Validity Indices for Streaming Data," ArXiv e-prints, 2018, arXiv:1801.02937v1 [stat.ML]. [Online]. 4. M. Moshtaghi, J. C. Bezdek, S. M. Erfani, C. Leckie, J. Bailey, "Online cluster validity indices for performance monitoring of streaming data clustering," Int. J. Intell. Syst., pp. 1-23, 2018. """ + info = _base.CVIInfo( + name="Calinski-Harabasz", + name_short="CH", + index_min=0.0, + index_max=np.inf, + optimality="max" + ) def __init__(self): """ diff --git a/src/cvi/modules/DB.py b/src/cvi/modules/DB.py index 56275cd..4769936 100644 --- a/src/cvi/modules/DB.py +++ b/src/cvi/modules/DB.py @@ -27,6 +27,14 @@ class DB(_base.CVI): 3. M. Moshtaghi, J. C. Bezdek, S. M. Erfani, C. Leckie, J. Bailey, "Online cluster validity indices for performance monitoring of streaming data clustering," Int. J. Intell. Syst., pp. 1-23, 2018. """ + info = _base.CVIInfo( + name="Davies-Bouldin", + name_short="DB", + index_min=0.0, + index_max=np.inf, + optimality="min" + ) + def __init__(self): """ Davies-Bouldin (DB) initialization routine. diff --git a/src/cvi/modules/GD43.py b/src/cvi/modules/GD43.py index 388780a..cd1ec20 100644 --- a/src/cvi/modules/GD43.py +++ b/src/cvi/modules/GD43.py @@ -31,6 +31,14 @@ class GD43(_base.CVI): 5. J. C. Bezdek and N. R. Pal, "Some new indexes of cluster validity," IEEE Trans. Syst., Man, and Cybern., vol. 28, no. 3, pp. 301-315, Jun. 1998. """ + info = _base.CVIInfo( + name="Generalized Dunn's 43", + name_short="GD43", + index_min=0.0, + index_max=np.inf, + optimality="max" + ) + def __init__(self): """ Generalized Dunn's Index 43 (GD43) initialization routine. diff --git a/src/cvi/modules/GD53.py b/src/cvi/modules/GD53.py index 4134a40..095b5bf 100644 --- a/src/cvi/modules/GD53.py +++ b/src/cvi/modules/GD53.py @@ -31,6 +31,14 @@ class GD53(_base.CVI): 5. J. C. Bezdek and N. R. Pal, "Some new indexes of cluster validity," IEEE Trans. Syst., Man, and Cybern., vol. 28, no. 3, pp. 301-315, Jun. 1998. """ + info = _base.CVIInfo( + name="Generalized Dunn's 53", + name_short="GD53", + index_min=0.0, + index_max=np.inf, + optimality="max" + ) + def __init__(self): """ Generalized Dunn's Index 53 (GD53) initialization routine. diff --git a/src/cvi/modules/PS.py b/src/cvi/modules/PS.py index 83b9101..bcbe3c9 100644 --- a/src/cvi/modules/PS.py +++ b/src/cvi/modules/PS.py @@ -25,6 +25,14 @@ class PS(_base.CVI): 2. E. Lughofer, "Extensions of vector quantization for incremental clustering," Pattern Recognit., vol. 41, no. 3, pp. 995-1011, 2008. """ + info = _base.CVIInfo( + name="Partition Separation", + name_short="PS", + index_min=0.0, + index_max=1.0, + optimality="max" + ) + def __init__(self): """ Partition Separation (PS) initialization routine. diff --git a/src/cvi/modules/WB.py b/src/cvi/modules/WB.py index d1694eb..688d089 100644 --- a/src/cvi/modules/WB.py +++ b/src/cvi/modules/WB.py @@ -31,6 +31,14 @@ class WB(_base.CVI): 5. M. Moshtaghi, J. C. Bezdek, S. M. Erfani, C. Leckie, J. Bailey, "Online cluster validity indices for performance monitoring of streaming data clustering," Int. J. Intell. Syst., pp. 1-23, 2018. """ + info = _base.CVIInfo( + name="Within/Between", + name_short="WB", + index_min=0.0, + index_max=np.inf, + optimality="min" + ) + def __init__(self): """ WB initialization routine. diff --git a/src/cvi/modules/XB.py b/src/cvi/modules/XB.py index 53dea02..3cc9ca4 100644 --- a/src/cvi/modules/XB.py +++ b/src/cvi/modules/XB.py @@ -27,6 +27,14 @@ class XB(_base.CVI): 3. M. Moshtaghi, J. C. Bezdek, S. M. Erfani, C. Leckie, J. Bailey, "Online cluster validity indices for performance monitoring of streaming data clustering," Int. J. Intell. Syst., pp. 1-23, 2018. """ + info = _base.CVIInfo( + name="Xie-Beni", + name_short="XB", + index_min=0.0, + index_max=np.inf, + optimality="min" + ) + def __init__(self): """ XB initialization routine. diff --git a/src/cvi/modules/_base.py b/src/cvi/modules/_base.py index e931411..f6fd365 100644 --- a/src/cvi/modules/_base.py +++ b/src/cvi/modules/_base.py @@ -12,6 +12,9 @@ ) from abc import abstractmethod +from dataclasses import dataclass +from typing import ClassVar + # Custom imports import numpy as np @@ -19,6 +22,13 @@ # CLASSES # --------------------------------------------------------------------------- # +@dataclass +class CVIInfo: + name: str + name_short: str + index_min: float + index_max: float + optimality: str class LabelMap(): """ @@ -53,6 +63,8 @@ class CVI(): Superclass containing elements shared between all CVIs. """ + info: ClassVar[CVIInfo] + def __init__(self): """ CVI base class initialization method. diff --git a/src/cvi/modules/cSIL.py b/src/cvi/modules/cSIL.py index 93c0911..0bab086 100644 --- a/src/cvi/modules/cSIL.py +++ b/src/cvi/modules/cSIL.py @@ -27,6 +27,14 @@ class cSIL(_base.CVI): 3. M. Rawashdeh and A. Ralescu, "Center-wise intra-inter silhouettes," in Scalable Uncertainty Management, E. Hüllermeier, S. Link, T. Fober et al., Eds. Berlin, Heidelberg: Springer, 2012, pp. 406-419. """ + info = _base.CVIInfo( + name="Centroid-based Silhouette", + name_short="cSIL", + index_min=-1.0, + index_max=1.0, + optimality="max" + ) + def __init__(self): """ Centroid-based Silhouette (cSIL) initialization routine. diff --git a/src/cvi/modules/rCIP.py b/src/cvi/modules/rCIP.py index e9bf5a4..34e50a9 100644 --- a/src/cvi/modules/rCIP.py +++ b/src/cvi/modules/rCIP.py @@ -27,6 +27,14 @@ class rCIP(_base.CVI): 3. M. Moshtaghi, J. C. Bezdek, S. M. Erfani, C. Leckie, J. Bailey, "Online cluster validity indices for performance monitoring of streaming data clustering," Int. J. Intell. Syst., pp. 1-23, 2018. """ + info = _base.CVIInfo( + name="Representative Cross Information Potential", + name_short="rCIP", + index_min=0.0, + index_max=np.inf, + optimality="min" + ) + def __init__(self): """ (Renyi's) representative Cross Information Potential (rCIP) initialization routine.