nn-rank 0.0.1__tar.gz
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.
- nn_rank-0.0.1/LICENSE +204 -0
- nn_rank-0.0.1/PKG-INFO +213 -0
- nn_rank-0.0.1/README.md +188 -0
- nn_rank-0.0.1/ab/nn/select.py +1247 -0
- nn_rank-0.0.1/nn_rank.egg-info/PKG-INFO +213 -0
- nn_rank-0.0.1/nn_rank.egg-info/SOURCES.txt +11 -0
- nn_rank-0.0.1/nn_rank.egg-info/dependency_links.txt +1 -0
- nn_rank-0.0.1/nn_rank.egg-info/requires.txt +3 -0
- nn_rank-0.0.1/nn_rank.egg-info/top_level.txt +1 -0
- nn_rank-0.0.1/pyproject.toml +44 -0
- nn_rank-0.0.1/requirements.txt +3 -0
- nn_rank-0.0.1/setup.cfg +4 -0
- nn_rank-0.0.1/version +1 -0
nn_rank-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026- ABrain-One
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9
|
+
|
|
10
|
+
1. Definitions.
|
|
11
|
+
|
|
12
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
13
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
14
|
+
|
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
16
|
+
the copyright owner that is granting the License.
|
|
17
|
+
|
|
18
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
19
|
+
other entities that control, are controlled by, or are under common
|
|
20
|
+
control with that entity. For the purposes of this definition,
|
|
21
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
22
|
+
direction or management of such entity, whether by contract or
|
|
23
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
24
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
25
|
+
|
|
26
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
27
|
+
exercising permissions granted by this License.
|
|
28
|
+
|
|
29
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
30
|
+
including but not limited to software source code, documentation
|
|
31
|
+
source, and configuration files.
|
|
32
|
+
|
|
33
|
+
"Object" form shall mean any form resulting from mechanical
|
|
34
|
+
transformation or translation of a Source form, including but
|
|
35
|
+
not limited to compiled object code, generated documentation,
|
|
36
|
+
and conversions to other media types.
|
|
37
|
+
|
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
39
|
+
Object form, made available under the License, as indicated by a
|
|
40
|
+
copyright notice that is included in or attached to the work
|
|
41
|
+
(an example is provided in the Appendix below).
|
|
42
|
+
|
|
43
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
|
45
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
46
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
47
|
+
of this License, Derivative Works shall not include works that remain
|
|
48
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
49
|
+
the Work and Derivative Works thereof.
|
|
50
|
+
|
|
51
|
+
"Contribution" shall mean any work of authorship, including
|
|
52
|
+
the original version of the Work and any modifications or additions
|
|
53
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
54
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
55
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
56
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
57
|
+
means any form of electronic, verbal, or written communication sent
|
|
58
|
+
to the Licensor or its representatives, including but not limited to
|
|
59
|
+
communication on electronic mailing lists, source code control systems,
|
|
60
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
61
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
62
|
+
excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
64
|
+
|
|
65
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
66
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
67
|
+
subsequently incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
70
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
71
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
72
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
73
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
74
|
+
Work and such Derivative Works in Source or Object form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
77
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
78
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
79
|
+
(except as stated in this section) patent license to make, have made,
|
|
80
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
81
|
+
where such license applies only to those patent claims licensable
|
|
82
|
+
by such Contributor that are necessarily infringed by their
|
|
83
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
84
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
85
|
+
institute patent litigation against any entity (including a
|
|
86
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
87
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
88
|
+
or contributory patent infringement, then any patent licenses
|
|
89
|
+
granted to You under this License for that Work shall terminate
|
|
90
|
+
as of the date such litigation is filed.
|
|
91
|
+
|
|
92
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
93
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
94
|
+
modifications, and in Source or Object form, provided that You
|
|
95
|
+
meet the following conditions:
|
|
96
|
+
|
|
97
|
+
(a) You must give any other recipients of the Work or
|
|
98
|
+
Derivative Works a copy of this License; and
|
|
99
|
+
|
|
100
|
+
(b) You must cause any modified files to carry prominent notices
|
|
101
|
+
stating that You changed the files; and
|
|
102
|
+
|
|
103
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
104
|
+
that You distribute, all copyright, patent, trademark, and
|
|
105
|
+
attribution notices from the Source form of the Work,
|
|
106
|
+
excluding those notices that do not pertain to any part of
|
|
107
|
+
the Derivative Works; and
|
|
108
|
+
|
|
109
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
110
|
+
distribution, then any Derivative Works that You distribute must
|
|
111
|
+
include a readable copy of the attribution notices contained
|
|
112
|
+
within such NOTICE file, excluding those notices that do not
|
|
113
|
+
pertain to any part of the Derivative Works, in at least one
|
|
114
|
+
of the following places: within a NOTICE text file distributed
|
|
115
|
+
as part of the Derivative Works; within the Source form or
|
|
116
|
+
documentation, if provided along with the Derivative Works; or,
|
|
117
|
+
within a display generated by the Derivative Works, if and
|
|
118
|
+
wherever such third-party notices normally appear. The contents
|
|
119
|
+
of the NOTICE file are for informational purposes only and
|
|
120
|
+
do not modify the License. You may add Your own attribution
|
|
121
|
+
notices within Derivative Works that You distribute, alongside
|
|
122
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
123
|
+
that such additional attribution notices cannot be construed
|
|
124
|
+
as modifying the License.
|
|
125
|
+
|
|
126
|
+
You may add Your own copyright statement to Your modifications and
|
|
127
|
+
may provide additional or different license terms and conditions
|
|
128
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
129
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
130
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
131
|
+
the conditions stated in this License.
|
|
132
|
+
|
|
133
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
134
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
135
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
136
|
+
this License, without any additional terms or conditions.
|
|
137
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
138
|
+
the terms of any separate license agreement you may have executed
|
|
139
|
+
with Licensor regarding such Contributions.
|
|
140
|
+
|
|
141
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
142
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
143
|
+
except as required for reasonable and customary use in describing the
|
|
144
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
145
|
+
|
|
146
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
147
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
148
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
149
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
150
|
+
implied, including, without limitation, any warranties or conditions
|
|
151
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
153
|
+
appropriateness of using or redistributing the Work and assume any
|
|
154
|
+
risks associated with Your exercise of permissions under this License.
|
|
155
|
+
|
|
156
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
157
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
158
|
+
unless required by applicable law (such as deliberate and grossly
|
|
159
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
160
|
+
liable to You for damages, including any direct, indirect, special,
|
|
161
|
+
incidental, or consequential damages of any character arising as a
|
|
162
|
+
result of this License or out of the use or inability to use the
|
|
163
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
164
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
165
|
+
other commercial damages or losses), even if such Contributor
|
|
166
|
+
has been advised of the possibility of such damages.
|
|
167
|
+
|
|
168
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
169
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
170
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
171
|
+
or other liability obligations and/or rights consistent with this
|
|
172
|
+
License. However, in accepting such obligations, You may act only
|
|
173
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
174
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
175
|
+
defend, and hold each Contributor harmless for any liability
|
|
176
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
177
|
+
of your accepting any such warranty or additional liability.
|
|
178
|
+
|
|
179
|
+
END OF TERMS AND CONDITIONS
|
|
180
|
+
|
|
181
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
182
|
+
|
|
183
|
+
To apply the Apache License to your work, attach the following
|
|
184
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
185
|
+
replaced with your own identifying information. (Don't include
|
|
186
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
187
|
+
comment syntax for the file format. We also recommend that a
|
|
188
|
+
file or class name and description of purpose be included on the
|
|
189
|
+
same "printed page" as the copyright notice for easier
|
|
190
|
+
identification within third-party archives.
|
|
191
|
+
|
|
192
|
+
Copyright [yyyy] [name of copyright owner]
|
|
193
|
+
|
|
194
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
195
|
+
you may not use this file except in compliance with the License.
|
|
196
|
+
You may obtain a copy of the License at
|
|
197
|
+
|
|
198
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
199
|
+
|
|
200
|
+
Unless required by applicable law or agreed to in writing, software
|
|
201
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
202
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
203
|
+
See the License for the specific language governing permissions and
|
|
204
|
+
limitations under the License.
|
nn_rank-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nn-rank
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Ranking of AI Systems by the Accuracy-Resource Trade-off
|
|
5
|
+
Author-email: ABrain One and contributors <AI@ABrain.one>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://ABrain.one
|
|
8
|
+
Project-URL: Repository, https://github.com/ABrain-One/nn-rank
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/ABrain-One/nn-rank/issues
|
|
10
|
+
Keywords: neural network ranking,model selection,AI system,accuracy latency trade-off,pareto front,quality resource trade-off,inference cost analysis,model efficiency benchmark,deep learning model comparison,python model ranking
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: scipy
|
|
23
|
+
Requires-Dist: pandas
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# AI Ranking
|
|
27
|
+
|
|
28
|
+
Ranks neural networks by the **accuracy–resource trade-off** and returns one
|
|
29
|
+
score per model. There is no weight to choose: the exchange rate between
|
|
30
|
+
accuracy and cost is derived from the candidates' own frontier.
|
|
31
|
+
|
|
32
|
+
## Create and Activate a Virtual Environment (recommended)
|
|
33
|
+
|
|
34
|
+
For Linux/Mac:
|
|
35
|
+
```bash
|
|
36
|
+
python3 -m venv .venv
|
|
37
|
+
source .venv/bin/activate
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For Windows:
|
|
42
|
+
```bash
|
|
43
|
+
python3 -m venv .venv
|
|
44
|
+
.venv\Scripts\activate
|
|
45
|
+
python -m pip install --upgrade pip
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m pip install --upgrade pip
|
|
50
|
+
pip install -r requirements.txt
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Use as an API
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import pandas as pd
|
|
57
|
+
from ab.nn.select import select
|
|
58
|
+
|
|
59
|
+
df = pd.DataFrame({
|
|
60
|
+
"name": ["B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7"],
|
|
61
|
+
"accuracy": [0.771, 0.791, 0.801, 0.816, 0.829, 0.836, 0.840, 0.843],
|
|
62
|
+
"flops_B": [0.39, 0.70, 1.0, 1.8, 4.2, 9.9, 19, 37],
|
|
63
|
+
"params_M": [5.3, 7.8, 9.2, 12, 19, 30, 43, 66],
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
r = select(df, res_col=["flops_B", "params_M"], rank=True)
|
|
67
|
+
|
|
68
|
+
r["winner"]["name"] # 'B0' <- the selected model
|
|
69
|
+
r["winner"]["score"] # 0.7140 <- its score, higher is better
|
|
70
|
+
r["verdict"]["level"] # 'USABLE' | 'UNVERIFIED' | 'UNUSABLE'
|
|
71
|
+
r["ranking"] # DataFrame: name, score, rank, ...
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Input
|
|
75
|
+
|
|
76
|
+
One row per model, in a `pandas.DataFrame`:
|
|
77
|
+
|
|
78
|
+
| column | required | meaning |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `name` | yes | model identifier |
|
|
81
|
+
| `accuracy` | yes | quality in **(0, 1)**, strictly between 0 and 1 |
|
|
82
|
+
| one or more resource columns | yes | anything you spend: latency, FLOPs, parameters, memory, energy. Each **> 0** |
|
|
83
|
+
|
|
84
|
+
`select(df, res_col=...)` names the resource column(s) — a string for one, a
|
|
85
|
+
list for several. All models must be measured on the **same test set and the
|
|
86
|
+
same device**, and each resource in **one fixed unit**.
|
|
87
|
+
|
|
88
|
+
Quality that is not already in (0, 1) must be converted first. For PSNR in dB,
|
|
89
|
+
`accuracy = 1 - 10 ** (-PSNR / 10)`. For top-1, mAP, mIoU, SSIM or F1, use the
|
|
90
|
+
value as it is.
|
|
91
|
+
|
|
92
|
+
### Output
|
|
93
|
+
|
|
94
|
+
`select()` returns a dict. The three things most users need:
|
|
95
|
+
|
|
96
|
+
| key | what it is |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `winner["name"]` | **the selected model** |
|
|
99
|
+
| `winner["score"]` | **its score** — higher is better |
|
|
100
|
+
| `ranking` | a `DataFrame`, winner first: `name`, `score`, `rank`, `accuracy`, each resource, `sigma`, `eps_eff`, `margin_to_next`, `rank_low`, `rank_high`, `note` |
|
|
101
|
+
|
|
102
|
+
Also returned: `verdict`, `status`, `prices` (one price per resource axis),
|
|
103
|
+
`rate`, `price_free` (dominations true at every price), `front`, `fit`,
|
|
104
|
+
`envelope`, `axis_drop`, `next`, `notes`, `problems`. `select()` prints
|
|
105
|
+
nothing and raises nothing; bad input comes back as `status="bad_input"` with
|
|
106
|
+
the offending rows listed in `problems`.
|
|
107
|
+
|
|
108
|
+
### The score
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
score = 1 / (1 + eps_eff)
|
|
112
|
+
eps_eff = eps * product over axes of (resource ** lambda) eps = 1 - accuracy
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`eps_eff` is **the error the model effectively costs once its resources are
|
|
116
|
+
charged** at the derived price `lambda`; `score` is that mapped into (0, 1) so
|
|
117
|
+
that **higher is better**.
|
|
118
|
+
|
|
119
|
+
Its one useful property: it is computed from a single model's own accuracy and
|
|
120
|
+
resources, and from nothing else. **Adding or removing other models cannot
|
|
121
|
+
change it** — unlike `rank`, or any score normalised over the candidate set.
|
|
122
|
+
So scores are comparable across runs and across published tables.
|
|
123
|
+
|
|
124
|
+
Two things it is *not* invariant to:
|
|
125
|
+
|
|
126
|
+
- **the resource unit** — milliseconds vs seconds shifts every score by the
|
|
127
|
+
same constant, so the ordering is untouched but the numbers are not
|
|
128
|
+
comparable unless the unit is fixed;
|
|
129
|
+
- **`lambda`** — only compare scores derived at the same price.
|
|
130
|
+
|
|
131
|
+
### Read the verdict before the ranking
|
|
132
|
+
|
|
133
|
+
`verdict["level"]` says whether the ranking means anything. A clean run prints
|
|
134
|
+
nothing; a problem prints in red, first.
|
|
135
|
+
|
|
136
|
+
| level | meaning |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `USABLE` | the error floor is confirmed by a nested F-test, so an exchange rate exists and the ranking is a genuine trade-off ranking |
|
|
139
|
+
| `UNVERIFIED` | too few points on the frontier to test the floor, or its knee lies outside the measured range — the ranking is a guess |
|
|
140
|
+
| `UNUSABLE` | the floor is rejected: no exchange rate exists in this data, and the ranking collapses to resource order |
|
|
141
|
+
|
|
142
|
+
`UNVERIFIED` and `UNUSABLE` still return a full ranking — labelled, not
|
|
143
|
+
withheld. What holds regardless of the verdict is `price_free`: a model beaten
|
|
144
|
+
on accuracy **and** on every resource can never win at any price.
|
|
145
|
+
|
|
146
|
+
### How many models are needed
|
|
147
|
+
|
|
148
|
+
Counts refer to candidates that **survive the cull**, not those supplied.
|
|
149
|
+
|
|
150
|
+
| surviving | behaviour |
|
|
151
|
+
|---|---|
|
|
152
|
+
| **8 or more** | the floor test identifies a rate reliably — `USABLE` expected |
|
|
153
|
+
| 6–7 | the papers' threshold, but noise-sensitive: identification 81% at 1% accuracy noise, 9% at 3% |
|
|
154
|
+
| 3–5 | the floor cannot be tested; a ranking is returned, labelled `UNVERIFIED` |
|
|
155
|
+
|
|
156
|
+
Fewer still ranks usefully: the exponent's precision is flat from three to ten
|
|
157
|
+
candidates when a floor is present, and `price_free` dominations hold at any
|
|
158
|
+
price. On MAI 2021, three surviving candidates of ten recovered the official
|
|
159
|
+
top two and identified six of the nine entries as dominated.
|
|
160
|
+
|
|
161
|
+
Competition leaderboards rarely reach eight by construction: their rules fix
|
|
162
|
+
quality at a threshold and compete on cost, so the surviving frontier is short
|
|
163
|
+
and carries little curvature.
|
|
164
|
+
|
|
165
|
+
## Usage examples
|
|
166
|
+
|
|
167
|
+
Ranked by the accuracy–time trade-off, no weight to choose. Any bare argument
|
|
168
|
+
containing a comma is a candidate: `name,accuracy,p1[,p2,...]`.
|
|
169
|
+
|
|
170
|
+
1. MAI 2026 INT8, SSIM vs inference time ms (NPU) — [arXiv:2611.00963](https://arxiv.org/pdf/2611.00963)
|
|
171
|
+
```bash
|
|
172
|
+
python -m ab.nn.select --rank koreatechV2,0.8499,4.35 Godzilla,0.8831,215160 AntSR,0.8731,4.52 LoongSR,0.8586,5729 IN2GM,0.8701,46.5 z6,0.8699,5.49 AIO_MAI,0.8634,41.1 AntYSP,0.8729,4.33
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
2. MAI 2026 INT8, PSNR converted to (0,1) vs 3 resources — NPU ms, CPU ms, model size (KB) — [arXiv:2611.00963](https://arxiv.org/pdf/2611.00963)
|
|
176
|
+
```bash
|
|
177
|
+
python -m ab.nn.select --rank koreatechV2,0.998758348,4.35,464,77.1 Godzilla,0.999085887,215160,215160,16253 AntSR,0.998995384,4.52,404,65.3 LoongSR,0.998943182,5729,5729,708 IN2GM,0.998964858,46.5,526,64.3 z6,0.998983751,5.49,330,67.4 AIO_MAI,0.998950458,41.1,610,96.1 AntYSP,0.998990747,4.33,338,54.9
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
3. EfficientNet B0–B7, ImageNet top-1 vs FLOPs and params (2 resources simultaneously) — [arXiv:1905.11946](https://arxiv.org/pdf/1905.11946), Table 2
|
|
181
|
+
```bash
|
|
182
|
+
python -m ab.nn.select --rank B7,0.843000000,37,66 B0,0.771000000,0.39,5.3 B4,0.829000000,4.2,19 B6,0.840000000,19,43 B2,0.801000000,1,9.2 B1,0.791000000,0.7,7.8 B3,0.816000000,1.8,12 B5,0.836000000,9.9,30
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
4. YOLO11, mAP vs 4 resources — T4 TensorRT10 ms, CPU ONNX ms, params (M), FLOPs (B) — [Ultralytics YOLO11 docs](https://docs.ultralytics.com/models/yolo11/)
|
|
186
|
+
```bash
|
|
187
|
+
python -m ab.nn.select --rank YOLO11l,0.534000000,6.2,238.6,25.3,87.2 YOLO11m,0.515000000,4.7,183.2,20.1,68.1 YOLO11x,0.547000000,11.3,462.8,56.9,195.3 YOLO11n,0.395000000,1.5,56.1,2.6,6.5 YOLO11s,0.470000000,2.5,90.0,9.4,21.6
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
5. MAI 2021 camera scene detection, Top-1 vs A11 Bionic runtime — [CVPRW 2021](https://openaccess.thecvf.com/content/CVPR2021W/MAI/papers/Ignatov_Fast_and_Accurate_Quantized_Camera_Scene_Detection_on_Smartphones_Mobile_CVPRW_2021_paper.pdf)
|
|
191
|
+
```bash
|
|
192
|
+
python -m ab.nn.select --rank Airia-Det,0.9300,17.51 Sidiki,0.7800,1.74 ByteScene,0.9500,4.44 MobileNet-V2,0.9417,16.38 PyImageSearch,0.8967,45.88 ALONG,0.9467,64.45 neptuneai,0.8367,4.17 EVAI,0.9300,3.35 DataArt,0.9150,54.13 Team-Horizon,0.9233,7.7
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
A CSV works too, with headers guessed or named:
|
|
196
|
+
```bash
|
|
197
|
+
python -m ab.nn.select models.csv --rank --acc-col top1 --res-col latency_ms --res-col params_M
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Other options
|
|
201
|
+
|
|
202
|
+
| flag | effect |
|
|
203
|
+
|---|---|
|
|
204
|
+
| `--rank` | order every model winner to loser (otherwise only the winner) |
|
|
205
|
+
| `--out-csv FILE` | write the ranking to CSV (`-` for stdout) |
|
|
206
|
+
| `--alpha 0.05` | coverage level for the rate interval |
|
|
207
|
+
| `--boot N` | max bootstrap refits; skipped automatically once the frontier has 50+ points |
|
|
208
|
+
| `--no-color`, `--quiet` | plain text / suppress the report |
|
|
209
|
+
|
|
210
|
+
Exit codes: `0` clean, `1` `UNVERIFIED` or `UNUSABLE`, `2` bad input.
|
|
211
|
+
|
|
212
|
+
Scale: thousands of candidates are fine — they collapse to a frontier of a few
|
|
213
|
+
hundred, and the fit runs on that. 20,000 models rank in about 1 second.
|
nn_rank-0.0.1/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# AI Ranking
|
|
2
|
+
|
|
3
|
+
Ranks neural networks by the **accuracy–resource trade-off** and returns one
|
|
4
|
+
score per model. There is no weight to choose: the exchange rate between
|
|
5
|
+
accuracy and cost is derived from the candidates' own frontier.
|
|
6
|
+
|
|
7
|
+
## Create and Activate a Virtual Environment (recommended)
|
|
8
|
+
|
|
9
|
+
For Linux/Mac:
|
|
10
|
+
```bash
|
|
11
|
+
python3 -m venv .venv
|
|
12
|
+
source .venv/bin/activate
|
|
13
|
+
python -m pip install --upgrade pip
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
For Windows:
|
|
17
|
+
```bash
|
|
18
|
+
python3 -m venv .venv
|
|
19
|
+
.venv\Scripts\activate
|
|
20
|
+
python -m pip install --upgrade pip
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
pip install -r requirements.txt
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Use as an API
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import pandas as pd
|
|
32
|
+
from ab.nn.select import select
|
|
33
|
+
|
|
34
|
+
df = pd.DataFrame({
|
|
35
|
+
"name": ["B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7"],
|
|
36
|
+
"accuracy": [0.771, 0.791, 0.801, 0.816, 0.829, 0.836, 0.840, 0.843],
|
|
37
|
+
"flops_B": [0.39, 0.70, 1.0, 1.8, 4.2, 9.9, 19, 37],
|
|
38
|
+
"params_M": [5.3, 7.8, 9.2, 12, 19, 30, 43, 66],
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
r = select(df, res_col=["flops_B", "params_M"], rank=True)
|
|
42
|
+
|
|
43
|
+
r["winner"]["name"] # 'B0' <- the selected model
|
|
44
|
+
r["winner"]["score"] # 0.7140 <- its score, higher is better
|
|
45
|
+
r["verdict"]["level"] # 'USABLE' | 'UNVERIFIED' | 'UNUSABLE'
|
|
46
|
+
r["ranking"] # DataFrame: name, score, rank, ...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Input
|
|
50
|
+
|
|
51
|
+
One row per model, in a `pandas.DataFrame`:
|
|
52
|
+
|
|
53
|
+
| column | required | meaning |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `name` | yes | model identifier |
|
|
56
|
+
| `accuracy` | yes | quality in **(0, 1)**, strictly between 0 and 1 |
|
|
57
|
+
| one or more resource columns | yes | anything you spend: latency, FLOPs, parameters, memory, energy. Each **> 0** |
|
|
58
|
+
|
|
59
|
+
`select(df, res_col=...)` names the resource column(s) — a string for one, a
|
|
60
|
+
list for several. All models must be measured on the **same test set and the
|
|
61
|
+
same device**, and each resource in **one fixed unit**.
|
|
62
|
+
|
|
63
|
+
Quality that is not already in (0, 1) must be converted first. For PSNR in dB,
|
|
64
|
+
`accuracy = 1 - 10 ** (-PSNR / 10)`. For top-1, mAP, mIoU, SSIM or F1, use the
|
|
65
|
+
value as it is.
|
|
66
|
+
|
|
67
|
+
### Output
|
|
68
|
+
|
|
69
|
+
`select()` returns a dict. The three things most users need:
|
|
70
|
+
|
|
71
|
+
| key | what it is |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `winner["name"]` | **the selected model** |
|
|
74
|
+
| `winner["score"]` | **its score** — higher is better |
|
|
75
|
+
| `ranking` | a `DataFrame`, winner first: `name`, `score`, `rank`, `accuracy`, each resource, `sigma`, `eps_eff`, `margin_to_next`, `rank_low`, `rank_high`, `note` |
|
|
76
|
+
|
|
77
|
+
Also returned: `verdict`, `status`, `prices` (one price per resource axis),
|
|
78
|
+
`rate`, `price_free` (dominations true at every price), `front`, `fit`,
|
|
79
|
+
`envelope`, `axis_drop`, `next`, `notes`, `problems`. `select()` prints
|
|
80
|
+
nothing and raises nothing; bad input comes back as `status="bad_input"` with
|
|
81
|
+
the offending rows listed in `problems`.
|
|
82
|
+
|
|
83
|
+
### The score
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
score = 1 / (1 + eps_eff)
|
|
87
|
+
eps_eff = eps * product over axes of (resource ** lambda) eps = 1 - accuracy
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`eps_eff` is **the error the model effectively costs once its resources are
|
|
91
|
+
charged** at the derived price `lambda`; `score` is that mapped into (0, 1) so
|
|
92
|
+
that **higher is better**.
|
|
93
|
+
|
|
94
|
+
Its one useful property: it is computed from a single model's own accuracy and
|
|
95
|
+
resources, and from nothing else. **Adding or removing other models cannot
|
|
96
|
+
change it** — unlike `rank`, or any score normalised over the candidate set.
|
|
97
|
+
So scores are comparable across runs and across published tables.
|
|
98
|
+
|
|
99
|
+
Two things it is *not* invariant to:
|
|
100
|
+
|
|
101
|
+
- **the resource unit** — milliseconds vs seconds shifts every score by the
|
|
102
|
+
same constant, so the ordering is untouched but the numbers are not
|
|
103
|
+
comparable unless the unit is fixed;
|
|
104
|
+
- **`lambda`** — only compare scores derived at the same price.
|
|
105
|
+
|
|
106
|
+
### Read the verdict before the ranking
|
|
107
|
+
|
|
108
|
+
`verdict["level"]` says whether the ranking means anything. A clean run prints
|
|
109
|
+
nothing; a problem prints in red, first.
|
|
110
|
+
|
|
111
|
+
| level | meaning |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `USABLE` | the error floor is confirmed by a nested F-test, so an exchange rate exists and the ranking is a genuine trade-off ranking |
|
|
114
|
+
| `UNVERIFIED` | too few points on the frontier to test the floor, or its knee lies outside the measured range — the ranking is a guess |
|
|
115
|
+
| `UNUSABLE` | the floor is rejected: no exchange rate exists in this data, and the ranking collapses to resource order |
|
|
116
|
+
|
|
117
|
+
`UNVERIFIED` and `UNUSABLE` still return a full ranking — labelled, not
|
|
118
|
+
withheld. What holds regardless of the verdict is `price_free`: a model beaten
|
|
119
|
+
on accuracy **and** on every resource can never win at any price.
|
|
120
|
+
|
|
121
|
+
### How many models are needed
|
|
122
|
+
|
|
123
|
+
Counts refer to candidates that **survive the cull**, not those supplied.
|
|
124
|
+
|
|
125
|
+
| surviving | behaviour |
|
|
126
|
+
|---|---|
|
|
127
|
+
| **8 or more** | the floor test identifies a rate reliably — `USABLE` expected |
|
|
128
|
+
| 6–7 | the papers' threshold, but noise-sensitive: identification 81% at 1% accuracy noise, 9% at 3% |
|
|
129
|
+
| 3–5 | the floor cannot be tested; a ranking is returned, labelled `UNVERIFIED` |
|
|
130
|
+
|
|
131
|
+
Fewer still ranks usefully: the exponent's precision is flat from three to ten
|
|
132
|
+
candidates when a floor is present, and `price_free` dominations hold at any
|
|
133
|
+
price. On MAI 2021, three surviving candidates of ten recovered the official
|
|
134
|
+
top two and identified six of the nine entries as dominated.
|
|
135
|
+
|
|
136
|
+
Competition leaderboards rarely reach eight by construction: their rules fix
|
|
137
|
+
quality at a threshold and compete on cost, so the surviving frontier is short
|
|
138
|
+
and carries little curvature.
|
|
139
|
+
|
|
140
|
+
## Usage examples
|
|
141
|
+
|
|
142
|
+
Ranked by the accuracy–time trade-off, no weight to choose. Any bare argument
|
|
143
|
+
containing a comma is a candidate: `name,accuracy,p1[,p2,...]`.
|
|
144
|
+
|
|
145
|
+
1. MAI 2026 INT8, SSIM vs inference time ms (NPU) — [arXiv:2611.00963](https://arxiv.org/pdf/2611.00963)
|
|
146
|
+
```bash
|
|
147
|
+
python -m ab.nn.select --rank koreatechV2,0.8499,4.35 Godzilla,0.8831,215160 AntSR,0.8731,4.52 LoongSR,0.8586,5729 IN2GM,0.8701,46.5 z6,0.8699,5.49 AIO_MAI,0.8634,41.1 AntYSP,0.8729,4.33
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
2. MAI 2026 INT8, PSNR converted to (0,1) vs 3 resources — NPU ms, CPU ms, model size (KB) — [arXiv:2611.00963](https://arxiv.org/pdf/2611.00963)
|
|
151
|
+
```bash
|
|
152
|
+
python -m ab.nn.select --rank koreatechV2,0.998758348,4.35,464,77.1 Godzilla,0.999085887,215160,215160,16253 AntSR,0.998995384,4.52,404,65.3 LoongSR,0.998943182,5729,5729,708 IN2GM,0.998964858,46.5,526,64.3 z6,0.998983751,5.49,330,67.4 AIO_MAI,0.998950458,41.1,610,96.1 AntYSP,0.998990747,4.33,338,54.9
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
3. EfficientNet B0–B7, ImageNet top-1 vs FLOPs and params (2 resources simultaneously) — [arXiv:1905.11946](https://arxiv.org/pdf/1905.11946), Table 2
|
|
156
|
+
```bash
|
|
157
|
+
python -m ab.nn.select --rank B7,0.843000000,37,66 B0,0.771000000,0.39,5.3 B4,0.829000000,4.2,19 B6,0.840000000,19,43 B2,0.801000000,1,9.2 B1,0.791000000,0.7,7.8 B3,0.816000000,1.8,12 B5,0.836000000,9.9,30
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
4. YOLO11, mAP vs 4 resources — T4 TensorRT10 ms, CPU ONNX ms, params (M), FLOPs (B) — [Ultralytics YOLO11 docs](https://docs.ultralytics.com/models/yolo11/)
|
|
161
|
+
```bash
|
|
162
|
+
python -m ab.nn.select --rank YOLO11l,0.534000000,6.2,238.6,25.3,87.2 YOLO11m,0.515000000,4.7,183.2,20.1,68.1 YOLO11x,0.547000000,11.3,462.8,56.9,195.3 YOLO11n,0.395000000,1.5,56.1,2.6,6.5 YOLO11s,0.470000000,2.5,90.0,9.4,21.6
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
5. MAI 2021 camera scene detection, Top-1 vs A11 Bionic runtime — [CVPRW 2021](https://openaccess.thecvf.com/content/CVPR2021W/MAI/papers/Ignatov_Fast_and_Accurate_Quantized_Camera_Scene_Detection_on_Smartphones_Mobile_CVPRW_2021_paper.pdf)
|
|
166
|
+
```bash
|
|
167
|
+
python -m ab.nn.select --rank Airia-Det,0.9300,17.51 Sidiki,0.7800,1.74 ByteScene,0.9500,4.44 MobileNet-V2,0.9417,16.38 PyImageSearch,0.8967,45.88 ALONG,0.9467,64.45 neptuneai,0.8367,4.17 EVAI,0.9300,3.35 DataArt,0.9150,54.13 Team-Horizon,0.9233,7.7
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
A CSV works too, with headers guessed or named:
|
|
171
|
+
```bash
|
|
172
|
+
python -m ab.nn.select models.csv --rank --acc-col top1 --res-col latency_ms --res-col params_M
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Other options
|
|
176
|
+
|
|
177
|
+
| flag | effect |
|
|
178
|
+
|---|---|
|
|
179
|
+
| `--rank` | order every model winner to loser (otherwise only the winner) |
|
|
180
|
+
| `--out-csv FILE` | write the ranking to CSV (`-` for stdout) |
|
|
181
|
+
| `--alpha 0.05` | coverage level for the rate interval |
|
|
182
|
+
| `--boot N` | max bootstrap refits; skipped automatically once the frontier has 50+ points |
|
|
183
|
+
| `--no-color`, `--quiet` | plain text / suppress the report |
|
|
184
|
+
|
|
185
|
+
Exit codes: `0` clean, `1` `UNVERIFIED` or `UNUSABLE`, `2` bad input.
|
|
186
|
+
|
|
187
|
+
Scale: thousands of candidates are fine — they collapse to a frontier of a few
|
|
188
|
+
hundred, and the fit runs on that. 20,000 models rank in about 1 second.
|