groupunit 0.2.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.
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: groupunit
3
+ Version: 0.2.0
4
+ Summary: Correlation, PLS, CCA and similarity analyses when annotations exist only for groups
5
+ Author-email: Tim Kmecl <tim.kmecl.tk@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/timkmecl/groupunit
8
+ Project-URL: Documentation, https://timkmecl.github.io/groupunit/
9
+ Project-URL: Issues, https://github.com/timkmecl/groupunit/issues
10
+ Keywords: group-level variables,pseudoreplication,permutation test,PLS,CCA,representational similarity
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: numpy>=1.22
19
+ Requires-Dist: scipy>=1.8
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest>=7; extra == "test"
22
+ Requires-Dist: scikit-learn>=1.2; extra == "test"
23
+ Provides-Extra: docs
24
+ Requires-Dist: mkdocs-material>=9; extra == "docs"
25
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
26
+ Provides-Extra: simulations
27
+ Requires-Dist: pandas>=1.5; extra == "simulations"
28
+ Requires-Dist: tabulate>=0.9; extra == "simulations"
29
+ Dynamic: license-file
30
+
31
+ # groupunit
32
+
33
+ Software for designs in which detailed measurements of individuals are related
34
+ to variables that exist only for the groups they belong to: text features of
35
+ drug experience reports and each drug's receptor profile, brain regions and
36
+ parcel-level atlas maps, patients and characteristics of their hospital.
37
+
38
+ It accompanies Kmecl, *The group is the unit: limits of correlation, PLS and
39
+ CCA with group-level variables* (methods paper, Appendix D). The package
40
+ computes the quantities the paper derives, and the diagnostics, tests and
41
+ validation it recommends. Every test resamples groups, never individuals.
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install -e . # NumPy and SciPy only
47
+ pip install -e ".[test]" # + pytest and scikit-learn; run `pytest`
48
+ pip install -e ".[docs]" # + MkDocs; run `mkdocs serve`
49
+ ```
50
+
51
+ Requires Python 3.10+.
52
+
53
+ ## Example
54
+
55
+ ```python
56
+ import numpy as np
57
+ import groupunit as gu
58
+
59
+ groups, names = gu.encode_groups(report_drug, order=drug_table.index) # labels -> 0..M-1
60
+ Y = drug_table.to_numpy(float) # (M, q), one row per group
61
+ n = gu.group_sizes(groups, len(Y))
62
+
63
+ print(gu.describe(groups, Y, X)) # N, M, r, kappa = r/(M-1), effective groups, warnings
64
+
65
+ Y3, _ = gu.reduce_annotations(Y, n, 3) # reduce in advance if kappa is near 1
66
+ test = gu.pls_test(X, groups, Y3, n_perm=5000, rng=0) # refitted under group permutation
67
+ shares = gu.group_shares(test.fit.group_scores, Y3, n) # which groups carry each component
68
+ print(test.p_value, shares.m_eff, gu.pairing_ratio(Y3, n))
69
+ ```
70
+
71
+ `examples/walkthrough.py` goes through the paper's checklist on simulated data.
72
+
73
+ ## Documentation
74
+
75
+ The documentation is published at https://timkmecl.github.io/groupunit/.
76
+ Its source is in `docs/`; build it locally with `mkdocs serve`, or read the
77
+ Markdown directly:
78
+
79
+ - [Concepts](docs/concepts.md): the ideas behind the package, in a few pages.
80
+ - [Workflow](docs/guide.md): from data to reporting, following the paper's checklist.
81
+ - [Testing and validation](docs/testing.md): what to permute, what to refit, unequal group sizes.
82
+ - [Similarity designs](docs/similarity.md): typicality versus pattern.
83
+ - [Published results](docs/published.md): diagnostics from digitised group means.
84
+ - [Other models and scores](docs/other-models.md): scikit-learn models, scores from any method.
85
+ - [Simulations](docs/simulations.md): the simulation study of §6.
86
+ - [API reference](docs/api.md): generated from the docstrings; readable only in the built site.
87
+
88
+ ## Layout
89
+
90
+ | Module | Paper | Contents |
91
+ | ------------- | --------------- | ------------------------------------------------------------------------- |
92
+ | `core` | §2 | group codes and means, weighted centring, correlation and R², annotation rank |
93
+ | `design` | §3.3, Box 1 | `describe`, `r2_null`, `reduce_annotations` |
94
+ | `scores` | Results 1, 3a | between-group share η², `decompose_score` |
95
+ | `methods` | §3.2–3.3 | `pls`, `cca` (optionally row-weighted), `lda`, computed through the group means |
96
+ | `diagnostics` | §5, Result 2b | group shares, effective numbers, the lens and its null, `leave_out` |
97
+ | `weights` | §4.1 | variance components, optimal and exchangeable weights, effective groups |
98
+ | `similarity` | §3.4, Results 4a–4c | typicality and pattern, `similarity_decomposition`, `compare_similarity`, `distance_similarity` |
99
+ | `inference` | §4.2–4.5, Result 5 | `correlation_test`, `pls_test`, `cca_test`, `estimator_test`, `permutation_test`, `pairing_ratio`, `pairing_terms`, `size_check` |
100
+ | `validation` | §4.5 | `leave_one_group_out`, `pca_regression`, scikit-learn models |
101
+ | `simulate` | §6.1 | `simulate`, `lognormal_sizes` |
102
+
103
+ `simulations/` holds the simulation study of the paper. `tests/` checks the
104
+ identities against direct computation and pins the numbers of the paper's
105
+ toy figures. GitHub Actions run the tests, publish the documentation to
106
+ GitHub Pages and release to PyPI. AGENTS.md ("CI and releasing") lists the
107
+ steps.
@@ -0,0 +1,16 @@
1
+ groupunit/__init__.py,sha256=F2lC1ixiuGlLj9IByr7fsU4WDLO23_TqgdOJ1gHw-QM,1545
2
+ groupunit/core.py,sha256=E6GfmS6sQcEbUbGeHPUdkyVpavf23mTYPwR5Hchu8No,5433
3
+ groupunit/design.py,sha256=pEMHLYKK0_vRcFh33gjxnyTyRRQvzG8wnScrqrgs-Fg,7901
4
+ groupunit/diagnostics.py,sha256=hFdHKlf2-iQTji9tHm8sVGu-M5oAWWdhPZmStPIoekw,11079
5
+ groupunit/inference.py,sha256=uoMN-jepNwb_Ph15my3H5LiVAcwRCrNRFGQNDjrLy_Q,25647
6
+ groupunit/methods.py,sha256=1-cYMhdGKraU8PmzRsy4TcntHNyNHZ-7I6NZ5cCbHRc,6746
7
+ groupunit/scores.py,sha256=m9FMb1PMO2_L-7PokRkDCpnql6_NHMhB2OQEl0lqPyo,2900
8
+ groupunit/similarity.py,sha256=nsvoIYHoosYPaTLyNiuIZX9O9MiqXSlLFP2UQGt0NTM,8273
9
+ groupunit/simulate.py,sha256=6pflJcNJmmzZheVe2MKaiym-pDltGmvErEJlkCoxalw,1687
10
+ groupunit/validation.py,sha256=1UojkNd3LvMpAwtQ3oaXzGAcpc9RblNxC2NlSvE8z8k,4482
11
+ groupunit/weights.py,sha256=hsng6QPj5vJcWSS4yyK08zj-HA-sVq-0Q1i5O4cX7No,4367
12
+ groupunit-0.2.0.dist-info/licenses/LICENSE,sha256=te2NM1zJv13voLrf5Fh1oRE0N6WByvHOWAOPh5FlvCs,1066
13
+ groupunit-0.2.0.dist-info/METADATA,sha256=uDE9lmcXiWn76tGWWDMySKsvTcuDPeafX-6YB9t6Hgw,5565
14
+ groupunit-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
15
+ groupunit-0.2.0.dist-info/top_level.txt,sha256=KeJt0V3t-rqJpEAkyKPHjQOmn0Lrj9BnN46W4BTsCMw,10
16
+ groupunit-0.2.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tim Kmecl
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
+ groupunit