clustelia 0.0.0__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.
clustelia/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Clustelia: tools for clustering analysis and validation."""
2
+
3
+ from ._summary import ClusterSummary, summarize_clusters
4
+
5
+ __version__ = "0.0.0"
6
+ __all__ = ["ClusterSummary", "summarize_clusters", "__version__"]
clustelia/_summary.py ADDED
@@ -0,0 +1,62 @@
1
+ """Lightweight, dependency-free cluster-label diagnostics."""
2
+
3
+ from collections import Counter
4
+ from dataclasses import dataclass
5
+ from typing import Hashable, Iterable
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class ClusterSummary:
10
+ """Summary of assigned cluster labels.
11
+
12
+ ``counts`` and ``shares`` include the noise label, when present.
13
+ ``shares`` are relative to all observations, including noise.
14
+ """
15
+
16
+ n_samples: int
17
+ n_clusters: int
18
+ n_noise: int
19
+ counts: dict[Hashable, int]
20
+ shares: dict[Hashable, float]
21
+
22
+
23
+ def summarize_clusters(
24
+ labels: Iterable[Hashable], *, noise_label: Hashable = -1
25
+ ) -> ClusterSummary:
26
+ """Summarize a sequence of cluster assignments.
27
+
28
+ Parameters
29
+ ----------
30
+ labels:
31
+ Hashable cluster labels. Iterators are consumed once. Empty input is
32
+ accepted. Labels may be strings, integers, or other hashable values.
33
+ noise_label:
34
+ Label interpreted as unassigned/noise (default ``-1``, common in
35
+ DBSCAN/HDBSCAN). Noise does not count toward ``n_clusters``.
36
+
37
+ Returns
38
+ -------
39
+ ClusterSummary
40
+ Counts, fractions and sample/cluster/noise totals. No fitted model
41
+ or input data matrix is required.
42
+
43
+ Examples
44
+ --------
45
+ >>> s = summarize_clusters([0, 0, 1, -1])
46
+ >>> (s.n_samples, s.n_clusters, s.n_noise)
47
+ (4, 2, 1)
48
+ >>> s.shares[0]
49
+ 0.5
50
+ """
51
+ counts = dict(Counter(labels))
52
+ n_samples = sum(counts.values())
53
+ n_noise = counts.get(noise_label, 0)
54
+ n_clusters = len(counts) - int(noise_label in counts)
55
+ shares = {label: count / n_samples for label, count in counts.items()}
56
+ return ClusterSummary(
57
+ n_samples=n_samples,
58
+ n_clusters=n_clusters,
59
+ n_noise=n_noise,
60
+ counts=counts,
61
+ shares=shares,
62
+ )
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: clustelia
3
+ Version: 0.0.0
4
+ Summary: Cluster-label diagnostics and an evolving foundation for clustering analysis.
5
+ Author: Jaime Vera-Jaramillo
6
+ Project-URL: Homepage, https://github.com/jaimevera1107/clustelia
7
+ Project-URL: Repository, https://github.com/jaimevera1107/clustelia
8
+ Project-URL: Issues, https://github.com/jaimevera1107/clustelia/issues
9
+ Keywords: clustering,cluster-analysis,unsupervised-learning,machine-learning
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Clustelia
19
+
20
+ **Clustelia** is a Python project for clustering analysis and, over time, automated clustering and model selection.
21
+
22
+ ## Current scope — 0.0.0
23
+
24
+ This is an **early, functional preview**, not a completed AutoML toolkit. It provides a dependency-free utility to summarize cluster assignments (sizes, proportions, number of clusters, and noise count). Fitting clustering models, model selection and advanced stability analysis are planned, not available in this release.
25
+
26
+ ### Install
27
+
28
+ ```bash
29
+ pip install clustelia==0.0.0
30
+ ```
31
+
32
+ ### Use
33
+
34
+ ```python
35
+ from clustelia import summarize_clusters
36
+
37
+ summary = summarize_clusters([0, 0, 1, -1])
38
+ print(summary.n_clusters) # 2
39
+ print(summary.counts) # {0: 2, 1: 1, -1: 1}
40
+ print(summary.shares) # {0: 0.5, 1: 0.25, -1: 0.25}
41
+ ```
42
+
43
+ ## Development
44
+
45
+ ```bash
46
+ python -m pip install -e .
47
+ python -m unittest discover -s tests -v
48
+ ```
49
+
50
+ ## Releasing
51
+
52
+ PyPI publishes automatically through GitHub Actions and Trusted Publishing when a GitHub Release is **published** with a version tag matching `pyproject.toml` (e.g., `v0.0.0`). The workflow checks the version, runs tests, builds source and wheel distributions and uploads them to PyPI.
53
+
54
+ For the **first publication**, register a PyPI pending trusted publisher first:
55
+
56
+ - PyPI project: `clustelia`
57
+ - GitHub owner: `jaimevera1107`
58
+ - Repository: `clustelia`
59
+ - Workflow: `publish.yml`
60
+ - Environment: `pypi`
61
+
62
+ Then publish a GitHub Release for tag `v0.0.0`.
63
+
64
+ **Important:** A pending trusted publisher does not reserve a PyPI project name. The first successful upload creates the project. Releasing a version twice is not possible on PyPI; update the version before creating each new release.
65
+
66
+ ## License
67
+
68
+ A project license has not yet been selected. Choose and add one before broad distribution if you want to grant explicit open-source reuse rights.
@@ -0,0 +1,6 @@
1
+ clustelia/__init__.py,sha256=S0uA8DKCknGGvNb-BO1-3tPhvIjV-R-YnYen97kFzVM,210
2
+ clustelia/_summary.py,sha256=P3wo-cKLl9HA054pM2jQeG0qv-KtERLfEQlV2-lr-TY,1783
3
+ clustelia-0.0.0.dist-info/METADATA,sha256=mMxjrCU35qGanAtBIRV2cF6tBDwMEJMVyN60zhbTMkk,2628
4
+ clustelia-0.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ clustelia-0.0.0.dist-info/top_level.txt,sha256=nAzKyvREPAO3pcSVeJu-HjTpK0fZUyDh-Zjm2L5t7qk,10
6
+ clustelia-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ clustelia