clustrust 0.1.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.
- clustrust/__init__.py +0 -0
- clustrust/__main__.py +3 -0
- clustrust/core/__init__.py +0 -0
- clustrust/core/agreement.py +17 -0
- clustrust/core/algorithms.py +19 -0
- clustrust/core/calibrate.py +70 -0
- clustrust/core/consensus.py +51 -0
- clustrust/core/defaults.py +66 -0
- clustrust/core/evidence.py +116 -0
- clustrust/core/indices.py +26 -0
- clustrust/core/null.py +23 -0
- clustrust/core/profiles.py +19 -0
- clustrust/core/runner.py +28 -0
- clustrust/core/stability.py +62 -0
- clustrust/core/tendency.py +46 -0
- clustrust/gui/__init__.py +0 -0
- clustrust/gui/app.py +853 -0
- clustrust/gui/tooltip.py +25 -0
- clustrust/io/export.py +122 -0
- clustrust/io/loaders.py +57 -0
- clustrust-0.1.0.dist-info/METADATA +196 -0
- clustrust-0.1.0.dist-info/RECORD +26 -0
- clustrust-0.1.0.dist-info/WHEEL +5 -0
- clustrust-0.1.0.dist-info/entry_points.txt +2 -0
- clustrust-0.1.0.dist-info/licenses/LICENSE +21 -0
- clustrust-0.1.0.dist-info/top_level.txt +1 -0
clustrust/gui/tooltip.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""A small hover tooltip for plain-language help."""
|
|
2
|
+
import tkinter as tk
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Tooltip:
|
|
6
|
+
def __init__(self, widget, text):
|
|
7
|
+
self.widget, self.text, self.tip = widget, text, None
|
|
8
|
+
widget.bind("<Enter>", self.show)
|
|
9
|
+
widget.bind("<Leave>", self.hide)
|
|
10
|
+
|
|
11
|
+
def show(self, _event=None):
|
|
12
|
+
if self.tip:
|
|
13
|
+
return
|
|
14
|
+
x = self.widget.winfo_rootx() + 20
|
|
15
|
+
y = self.widget.winfo_rooty() + self.widget.winfo_height() + 4
|
|
16
|
+
self.tip = tk.Toplevel(self.widget)
|
|
17
|
+
self.tip.wm_overrideredirect(True)
|
|
18
|
+
self.tip.wm_geometry(f"+{x}+{y}")
|
|
19
|
+
tk.Label(self.tip, text=self.text, justify="left", background="#ffffe0",
|
|
20
|
+
relief="solid", borderwidth=1, wraplength=380, padx=6, pady=4).pack()
|
|
21
|
+
|
|
22
|
+
def hide(self, _event=None):
|
|
23
|
+
if self.tip:
|
|
24
|
+
self.tip.destroy()
|
|
25
|
+
self.tip = None
|
clustrust/io/export.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Export a session: JSON settings, parameter sources, environment and a replay script."""
|
|
2
|
+
import json
|
|
3
|
+
import platform
|
|
4
|
+
import sys
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from importlib import metadata
|
|
7
|
+
|
|
8
|
+
from clustrust.core.defaults import DEFAULTS, value
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def environment() -> dict:
|
|
12
|
+
pkgs = ["numpy", "pandas", "scikit-learn", "scipy", "matplotlib", "joblib", "diptest", "clustrust"]
|
|
13
|
+
versions = {}
|
|
14
|
+
for p in pkgs:
|
|
15
|
+
try:
|
|
16
|
+
versions[p] = metadata.version(p)
|
|
17
|
+
except metadata.PackageNotFoundError:
|
|
18
|
+
versions[p] = "not installed"
|
|
19
|
+
return {"python": sys.version.split()[0], "platform": platform.platform(), "packages": versions}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def default_thresholds() -> dict:
|
|
23
|
+
return {"z": value("z_cutoff"), "min_indices": value("min_indices"),
|
|
24
|
+
"stability": value("stability_ari"), "agreement": value("agreement_ari")}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_config(csv_path, columns, scale, algorithms, kmin, kmax, seed, n_null,
|
|
28
|
+
cons_algo, cons_k, missing="drop", pca=None, log1p=False,
|
|
29
|
+
n_rounds=None, null=None, thresholds=None, preset=None) -> dict:
|
|
30
|
+
return {"csv_path": csv_path, "columns": list(columns), "scale": scale,
|
|
31
|
+
"missing": missing, "pca": pca, "log1p": log1p,
|
|
32
|
+
"algorithms": list(algorithms), "k_min": kmin, "k_max": kmax, "seed": seed,
|
|
33
|
+
"n_null": n_null,
|
|
34
|
+
"n_rounds": value("n_rounds") if n_rounds is None else n_rounds,
|
|
35
|
+
"null": value("null_model") if null is None else null,
|
|
36
|
+
"thresholds": dict(thresholds) if thresholds else default_thresholds(),
|
|
37
|
+
"preset": preset,
|
|
38
|
+
"consensus_algorithm": cons_algo, "consensus_k": cons_k}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def parameter_provenance(used: dict) -> dict:
|
|
42
|
+
"""For each adjustable parameter: the value used, the default, and where the default comes from."""
|
|
43
|
+
names = {"z": "z_cutoff", "min_indices": "min_indices", "stability": "stability_ari",
|
|
44
|
+
"agreement": "agreement_ari", "n_rounds": "n_rounds", "n_null": "n_null",
|
|
45
|
+
"null": "null_model", "subsample_fraction": "subsample_fraction"}
|
|
46
|
+
out = {}
|
|
47
|
+
for key, dname in names.items():
|
|
48
|
+
d = DEFAULTS[dname]
|
|
49
|
+
out[key] = {"used": used.get(key, d["value"]), "default": d["value"],
|
|
50
|
+
"kind": d["kind"], "source": d["source"]}
|
|
51
|
+
return out
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def save_json(config: dict, path: str, summary=None) -> None:
|
|
55
|
+
used = {**config.get("thresholds", {}), "n_rounds": config.get("n_rounds"),
|
|
56
|
+
"n_null": config.get("n_null"), "null": config.get("null"),
|
|
57
|
+
"subsample_fraction": value("subsample_fraction")}
|
|
58
|
+
report = {"created": datetime.now().isoformat(timespec="seconds"),
|
|
59
|
+
"settings": config, "parameters": parameter_provenance(used),
|
|
60
|
+
"environment": environment()}
|
|
61
|
+
if summary is not None:
|
|
62
|
+
report["verdict"] = {"label": summary["verdict"], "reason": summary["reason"],
|
|
63
|
+
"best_k": summary["best_k"], "candidates": summary["candidates"]}
|
|
64
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
65
|
+
json.dump(report, f, indent=2, default=str)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def script_text(config: dict) -> str:
|
|
69
|
+
"""Python code that repeats the analysis exactly."""
|
|
70
|
+
c = config
|
|
71
|
+
thr = c.get("thresholds") or default_thresholds()
|
|
72
|
+
return f'''"""Replay of a ClusTrust session. Generated automatically.
|
|
73
|
+
|
|
74
|
+
Run it in the folder that contains the CSV file: python replay.py
|
|
75
|
+
"""
|
|
76
|
+
import pandas as pd
|
|
77
|
+
from clustrust.io.loaders import load_csv, prepare, numeric_frame
|
|
78
|
+
from clustrust.core.runner import sweep, stability_sweep
|
|
79
|
+
from clustrust.core.evidence import evidence_profile, summarize
|
|
80
|
+
from clustrust.core.consensus import consensus, point_confidence
|
|
81
|
+
from clustrust.core.stability import cluster_jaccard
|
|
82
|
+
|
|
83
|
+
SEED = {c["seed"]!r}
|
|
84
|
+
ALGORITHMS = {c["algorithms"]!r}
|
|
85
|
+
K_RANGE = range({c["k_min"]!r}, {c["k_max"]!r} + 1)
|
|
86
|
+
N_ROUNDS = {c.get("n_rounds", value("n_rounds"))!r}
|
|
87
|
+
N_NULL = {c["n_null"]!r}
|
|
88
|
+
NULL_MODEL = {c.get("null", value("null_model"))!r}
|
|
89
|
+
THRESHOLDS = {thr!r}
|
|
90
|
+
CONS_ALGO = {c["consensus_algorithm"]!r}
|
|
91
|
+
CONS_K = {c["consensus_k"]!r}
|
|
92
|
+
|
|
93
|
+
df = load_csv({c["csv_path"]!r})
|
|
94
|
+
X, columns = prepare(df, scale={c["scale"]!r}, missing={c.get("missing", "drop")!r}, pca={c.get("pca")!r}, log1p={c.get("log1p", False)!r})
|
|
95
|
+
print("Columns used:", columns, "| rows:", len(X))
|
|
96
|
+
|
|
97
|
+
indices = sweep(X, ALGORITHMS, K_RANGE, SEED)
|
|
98
|
+
indices.to_csv("indices.csv", index=False)
|
|
99
|
+
|
|
100
|
+
stab = stability_sweep(X, ALGORITHMS, K_RANGE, n_rounds=N_ROUNDS, seed=SEED)
|
|
101
|
+
stab.to_csv("stability.csv", index=False)
|
|
102
|
+
|
|
103
|
+
prof, cal = evidence_profile(X, ALGORITHMS, K_RANGE, n_null=N_NULL, n_rounds=N_ROUNDS,
|
|
104
|
+
seed=SEED, cons_algo=CONS_ALGO, null=NULL_MODEL)
|
|
105
|
+
prof.to_csv("evidence_profile.csv", index=False)
|
|
106
|
+
cal.to_csv("calibrated.csv", index=False)
|
|
107
|
+
summary = summarize(prof, **THRESHOLDS)
|
|
108
|
+
print("Verdict:", summary["verdict"], "| best k:", summary["best_k"], "| passing:", summary["candidates"])
|
|
109
|
+
print(summary["reason"])
|
|
110
|
+
|
|
111
|
+
labels, C = consensus(CONS_ALGO, X, CONS_K, n_rounds=N_ROUNDS, seed=SEED)
|
|
112
|
+
out = numeric_frame(df, {c.get("missing", "drop")!r}).copy()
|
|
113
|
+
out["cluster"] = labels
|
|
114
|
+
out["confidence"] = point_confidence(C, labels)
|
|
115
|
+
out.to_csv("labels.csv", index=False)
|
|
116
|
+
cluster_jaccard(CONS_ALGO, X, CONS_K, n_rounds=N_ROUNDS, seed=SEED, reference=labels).to_csv("cluster_trust.csv", index=False)
|
|
117
|
+
'''
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def save_script(config: dict, path: str) -> None:
|
|
121
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
122
|
+
f.write(script_text(config))
|
clustrust/io/loaders.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Load a CSV file and prepare it for clustering."""
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from sklearn.decomposition import PCA
|
|
5
|
+
from sklearn.preprocessing import StandardScaler, RobustScaler, MinMaxScaler
|
|
6
|
+
|
|
7
|
+
SCALERS = {"standard": StandardScaler, "robust": RobustScaler, "minmax": MinMaxScaler}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def load_csv(path: str) -> pd.DataFrame:
|
|
11
|
+
"""Read a CSV file into a table."""
|
|
12
|
+
return pd.read_csv(path)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def numeric_frame(df: pd.DataFrame, missing: str = "drop", columns=None) -> pd.DataFrame:
|
|
16
|
+
"""Numeric columns only, with missing values dropped or filled with the median.
|
|
17
|
+
|
|
18
|
+
The rows of this table line up one-to-one with the rows of the array from prepare().
|
|
19
|
+
"""
|
|
20
|
+
num = df.select_dtypes(include="number")
|
|
21
|
+
if columns is not None:
|
|
22
|
+
num = num[list(columns)]
|
|
23
|
+
if num.shape[1] == 0:
|
|
24
|
+
raise ValueError("The file has no numeric columns to cluster.")
|
|
25
|
+
if missing == "drop":
|
|
26
|
+
return num.dropna()
|
|
27
|
+
if missing == "median":
|
|
28
|
+
return num.fillna(num.median())
|
|
29
|
+
raise ValueError(f"Unknown missing-value option: {missing}")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def prepare(df: pd.DataFrame, scale="standard", missing: str = "drop",
|
|
33
|
+
pca=None, columns=None, log1p=False) -> tuple[np.ndarray, list[str]]:
|
|
34
|
+
"""Return (data array, column names) ready for clustering.
|
|
35
|
+
|
|
36
|
+
scale: "standard", "robust", "minmax", "none" (True/False also accepted).
|
|
37
|
+
pca: None, a number of components (int) or a variance fraction (float < 1).
|
|
38
|
+
"""
|
|
39
|
+
if scale is True:
|
|
40
|
+
scale = "standard"
|
|
41
|
+
if scale is False:
|
|
42
|
+
scale = "none"
|
|
43
|
+
num = numeric_frame(df, missing, columns)
|
|
44
|
+
X = num.to_numpy(dtype=float)
|
|
45
|
+
names = list(num.columns)
|
|
46
|
+
if log1p:
|
|
47
|
+
if (X < 0).any():
|
|
48
|
+
raise ValueError("log1p needs non-negative values; this file has negative numbers.")
|
|
49
|
+
X = np.log1p(X)
|
|
50
|
+
if scale != "none":
|
|
51
|
+
if scale not in SCALERS:
|
|
52
|
+
raise ValueError(f"Unknown scaler: {scale}")
|
|
53
|
+
X = SCALERS[scale]().fit_transform(X)
|
|
54
|
+
if pca is not None:
|
|
55
|
+
X = PCA(n_components=pca, random_state=42).fit_transform(X)
|
|
56
|
+
names = [f"PC{i + 1}" for i in range(X.shape[1])]
|
|
57
|
+
return X, names
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clustrust
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Null-calibrated desktop tool and library for judging how many clusters a dataset contains and whether they can be trusted
|
|
5
|
+
Author: Elena Mehana, Lynn Lichaa
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/elenamehana/clustrust
|
|
8
|
+
Project-URL: Repository, https://github.com/elenamehana/clustrust
|
|
9
|
+
Project-URL: Issues, https://github.com/elenamehana/clustrust/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/elenamehana/clustrust/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: clustering,cluster validity,stability,consensus clustering,null calibration,reproducibility
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: pandas
|
|
27
|
+
Requires-Dist: scikit-learn
|
|
28
|
+
Requires-Dist: matplotlib
|
|
29
|
+
Requires-Dist: scipy
|
|
30
|
+
Requires-Dist: joblib
|
|
31
|
+
Provides-Extra: full
|
|
32
|
+
Requires-Dist: diptest; extra == "full"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# ClusTrust
|
|
39
|
+
|
|
40
|
+
A desktop tool and Python library that answers two questions about clustering:
|
|
41
|
+
**how many clusters are in my data, and can I trust them?**
|
|
42
|
+
|
|
43
|
+
Validity indices such as the silhouette always return a best number of clusters of
|
|
44
|
+
two or more, even for data with no groups. ClusTrust runs several algorithms over a
|
|
45
|
+
range of k, scores them with validity indices, tests stability by resampling, builds
|
|
46
|
+
a consensus clustering, and compares every score with structureless reference data.
|
|
47
|
+
The honest answer can therefore be **"no evidence of clusters"**.
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- **Null-calibrated scores:** silhouette, Calinski-Harabasz and Davies-Bouldin are
|
|
55
|
+
turned into z-scores against structureless data (Gaussian null, uniform-over-principal-components
|
|
56
|
+
null, or both; the default requires beating both).
|
|
57
|
+
- **One evidence profile per k:** calibrated indices, resampling stability, PAC and
|
|
58
|
+
agreement between algorithms, with a verdict: *Clear structure*, *Weak or ambiguous
|
|
59
|
+
structure* or *No evidence of clusters*.
|
|
60
|
+
- **Trust at three levels:** for the whole solution, for each cluster (Jaccard
|
|
61
|
+
stability) and for each point (consensus confidence).
|
|
62
|
+
- **No programming needed:** an offline Tkinter interface; your data stays on your computer.
|
|
63
|
+
- **Reproducible:** one global seed, and every session can be exported as
|
|
64
|
+
`session.json` plus a `replay.py` script that repeats the analysis.
|
|
65
|
+
|
|
66
|
+
Algorithms: k-means, agglomerative clustering, Gaussian mixture.
|
|
67
|
+
Input: CSV files (numeric columns are used).
|
|
68
|
+
|
|
69
|
+
## Install
|
|
70
|
+
|
|
71
|
+
Requires Python 3.10 or later, with Tkinter available in your Python installation.
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
pip install "clustrust[full]"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or from source:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
git clone https://github.com/elenamehana/clustrust.git
|
|
81
|
+
cd clustrust
|
|
82
|
+
pip install -e ".[full]"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The `full` extra installs `diptest`, which enables the dip test in the tendency check.
|
|
86
|
+
Without it everything else still works.
|
|
87
|
+
|
|
88
|
+
## Start the graphical interface
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
python -m clustrust
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
1. Click **Load CSV**. Set scaling, missing-value handling, optional log(1 + x) and
|
|
95
|
+
optional PCA, then click **Apply to data**.
|
|
96
|
+
2. Choose the algorithms, the range of k, the seed and the **Run size**:
|
|
97
|
+
- *quick*: 20 resamples, 20 null sets, Gaussian null. For exploring.
|
|
98
|
+
- *literature*: 100 resamples, 100 null sets, both nulls. Much slower
|
|
99
|
+
(roughly an hour on a 2-core laptop for a few hundred rows).
|
|
100
|
+
3. Optional first step: **Check tendency** (Hopkins statistic and dip test).
|
|
101
|
+
4. **Run evidence analysis** gives the verdict, the best-supported k and the table of
|
|
102
|
+
criteria for every k. Thresholds can be changed and the verdict refreshed with
|
|
103
|
+
**Update verdict**; **Literature defaults** restores the published values.
|
|
104
|
+
5. **Run consensus** builds the final grouping with confidence per point, trust per
|
|
105
|
+
cluster and a profile of what each cluster looks like.
|
|
106
|
+
6. **Export session** saves the settings, parameter sources, package versions,
|
|
107
|
+
results and a replay script.
|
|
108
|
+
|
|
109
|
+
Hover over any control for a plain-language explanation and the default with its source.
|
|
110
|
+
|
|
111
|
+
## Quick start from Python
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from clustrust.io.loaders import load_csv, prepare
|
|
115
|
+
from clustrust.core.evidence import evidence_profile, summarize
|
|
116
|
+
|
|
117
|
+
df = load_csv("examples/overlap_blobs/overlap_blobs.csv")
|
|
118
|
+
X, columns = prepare(df, scale="standard")
|
|
119
|
+
prof, cal = evidence_profile(X, k_range=range(2, 7), n_null=20, n_rounds=20)
|
|
120
|
+
print(prof.round(3))
|
|
121
|
+
print(summarize(prof)) # verdict, reason, best_k, passing k
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`evidence_profile` with no arguments uses the literature defaults (100 null sets,
|
|
125
|
+
100 resamples, both nulls).
|
|
126
|
+
|
|
127
|
+
## How the verdict works
|
|
128
|
+
|
|
129
|
+
For each k, ClusTrust checks that at least 2 of the 3 indices beat the null (z above 2),
|
|
130
|
+
that stability is at least 0.80 and that agreement between algorithms is at least 0.80.
|
|
131
|
+
|
|
132
|
+
- No index beats the null at any k: **No evidence of clusters**.
|
|
133
|
+
- Exactly one k passes, or the lowest-PAC k among the passing k is also favoured by
|
|
134
|
+
most indices: **Clear structure**.
|
|
135
|
+
- Otherwise: **Weak or ambiguous structure**, with the passing k and the index
|
|
136
|
+
favourites listed.
|
|
137
|
+
|
|
138
|
+
Every threshold is an adjustable default, not a validated constant. Their sources are
|
|
139
|
+
listed in `src/clustrust/core/defaults.py` and recorded in every `session.json`.
|
|
140
|
+
|
|
141
|
+
## Worked examples
|
|
142
|
+
|
|
143
|
+
The `examples/` folder holds the data, the exported session and the results for each case study.
|
|
144
|
+
All use the literature preset (seed 42, k = 2 to 8, three algorithms).
|
|
145
|
+
|
|
146
|
+
| Example | Data | Verdict |
|
|
147
|
+
| --- | --- | --- |
|
|
148
|
+
| `wine` | 178 wines, 13 chemical measurements | Clear structure, k = 3 |
|
|
149
|
+
| `wholesale` | 440 customers, 6 spending variables (log-transformed) | Weak or ambiguous structure |
|
|
150
|
+
| `gene_expression` | 801 tumours, 500 genes, PCA to 20 components | Weak or ambiguous (k = 3 to 8 all pass) |
|
|
151
|
+
| `wine_shuffled` | Wine with every column permuted: structureless control | No evidence of clusters |
|
|
152
|
+
| `noise` | 500 points, 2 Gaussian variables, no groups | No evidence of clusters |
|
|
153
|
+
| `noise_uniform` | 500 points, 3 uniform variables, no groups | No evidence of clusters |
|
|
154
|
+
| `overlap_blobs` | 500 points, 4 overlapping true groups | Weak or ambiguous (k = 3, 4, 5 pass; best k = 4) |
|
|
155
|
+
|
|
156
|
+
Each folder has a `replay.py` (run it inside the folder to reproduce the analysis),
|
|
157
|
+
a `NOTES.md` where available, and a `DATA_LICENSE.md` with the source and licence.
|
|
158
|
+
Reference labels are used only after the analysis, to check the results
|
|
159
|
+
(`benchmarks/check_labels.py`).
|
|
160
|
+
|
|
161
|
+
The real datasets come from the UCI Machine Learning Repository under CC BY 4.0.
|
|
162
|
+
Re-create them with `python examples/make_examples.py` (needs `pip install ucimlrepo`)
|
|
163
|
+
`python examples/make_gene_expression.py` (needs the manually downloaded TCGA archive)
|
|
164
|
+
and `python examples/make_synthetic.py` (generates the three synthetic examples).
|
|
165
|
+
|
|
166
|
+
## Benchmarks
|
|
167
|
+
|
|
168
|
+
`benchmarks/run_benchmark.py` runs a sanity check on generated data: noise, blobs and
|
|
169
|
+
two moons. `benchmarks/sensitivity.py` shows how the verdict changes when the
|
|
170
|
+
thresholds change. These are sanity checks with small samples, not validated error rates.
|
|
171
|
+
|
|
172
|
+
## Limitations
|
|
173
|
+
|
|
174
|
+
- Three algorithms only; non-convex shapes (for example two moons) are not recovered.
|
|
175
|
+
- Numeric data only; the interface limits consensus to 2000 rows.
|
|
176
|
+
- The verdict depends on adjustable thresholds, some of which are literature values
|
|
177
|
+
applied by analogy.
|
|
178
|
+
- The evidence profile is best read as a set of plausible k with reasons, not as a
|
|
179
|
+
point estimate of k. When several k pass, the best-supported k is the coarsest
|
|
180
|
+
by PAC tie-break.
|
|
181
|
+
- Stability and consensus can look convincing on structureless data; only the null
|
|
182
|
+
calibration exposes this.
|
|
183
|
+
|
|
184
|
+
## Tests
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
pip install -e ".[full,dev]"
|
|
188
|
+
pytest
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Continuous integration runs the tests on Windows and Linux with Python 3.10 and 3.12.
|
|
192
|
+
|
|
193
|
+
## License and citation
|
|
194
|
+
|
|
195
|
+
MIT License (see `LICENSE`). If you use this software, please cite it
|
|
196
|
+
(see `CITATION.cff`).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
clustrust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
clustrust/__main__.py,sha256=cTU4kAFK-sWCDAhYxUnpezi5933wQp0hrqdfT2oECZM,44
|
|
3
|
+
clustrust/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
clustrust/core/agreement.py,sha256=fbrM8ShLDUNdVVpy8z01mLACnkioeSKaR2OHkMAUL-U,738
|
|
5
|
+
clustrust/core/algorithms.py,sha256=mjgdMh0r1fxxQbyrV451437DHhhVl8MAqhzIPOoh6dQ,827
|
|
6
|
+
clustrust/core/calibrate.py,sha256=DeRqiSioCv3Xl-HSiOOzTHNZb-hOkTNl5RGqPmLKSC8,3243
|
|
7
|
+
clustrust/core/consensus.py,sha256=MyVH72yW7R6I1NsxqslpVWxGJBF5FzXXnagjbUULHq8,2266
|
|
8
|
+
clustrust/core/defaults.py,sha256=NZLZrBDYlFBxBIBPP2Z4mmSu5XrevhPw_dEefw9ArbI,4059
|
|
9
|
+
clustrust/core/evidence.py,sha256=fhp3Z3iKHrDAeXt8cdG8jELM-knZX4pvIGsH3Uw03xM,6012
|
|
10
|
+
clustrust/core/indices.py,sha256=dE_Wi0nJNUeSWkFe2s8Y2OMQ0NtfLi9bBFLV06frZDM,882
|
|
11
|
+
clustrust/core/null.py,sha256=cvVzkFxgewNsHgjI7NH1sVeB_4W_VH2TFnOY6Uok_CE,937
|
|
12
|
+
clustrust/core/profiles.py,sha256=PNQxjK7nshCB-ALU0YtJN49KEa9-nn7dsariv-k2Ius,910
|
|
13
|
+
clustrust/core/runner.py,sha256=q_EL4a7WerfC4C0W5IunsCdqrENzV1vBqKC1qT1lcRs,1193
|
|
14
|
+
clustrust/core/stability.py,sha256=UlsV7ew61_qSh9X5erO51qkefhsfyxamAfDshKuPD8M,2795
|
|
15
|
+
clustrust/core/tendency.py,sha256=NAZ0ZXVAS7S08ge8cNrUGmps-EeO5bSY4wtNRqt7FIc,1975
|
|
16
|
+
clustrust/gui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
clustrust/gui/app.py,sha256=FtJjkZVv935-gH5IO6znAxUJRH8IQO78_GSI7RvLsEw,42932
|
|
18
|
+
clustrust/gui/tooltip.py,sha256=sfV9rdgaW1VpeOx6rvFUcSeH9ikE18yRSoNwrYUnvvk,897
|
|
19
|
+
clustrust/io/export.py,sha256=sriRtsAEt7C5cE1SZfJptJNMmZ7k3e9Kwg1Qf_B7Sg4,5564
|
|
20
|
+
clustrust/io/loaders.py,sha256=hIIitZZcBerv5ty-qavRaNtex1lRAHKNvRR4Ku1yTK0,2210
|
|
21
|
+
clustrust-0.1.0.dist-info/licenses/LICENSE,sha256=_6eZKk3UF8NzvHve9s0d6aQ5K5BQO2f2Kt1dJLLrYyQ,1101
|
|
22
|
+
clustrust-0.1.0.dist-info/METADATA,sha256=JmKqUEH8t5lZLrRoyf-5v7PtLmhaCj0hlQHk-4bRAdA,8695
|
|
23
|
+
clustrust-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
24
|
+
clustrust-0.1.0.dist-info/entry_points.txt,sha256=yGs1oBr5d3B3e0cnKPDki529VXWzCe5oWJCzPFzCd6U,49
|
|
25
|
+
clustrust-0.1.0.dist-info/top_level.txt,sha256=UahV26pKDAOEuM7lK6swTpcuBUhKVps4jsTOUYwj8cw,10
|
|
26
|
+
clustrust-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Elena Mehana, Lynn Lichaa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
clustrust
|