arena-score 1.0.0__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.
@@ -0,0 +1,117 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ pip-wheel-metadata/
20
+ share/python-wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+ MANIFEST
25
+
26
+ # Virtual Environment
27
+ venv/
28
+ env/
29
+ ENV/
30
+ env.bak/
31
+ venv.bak/
32
+ .venv/
33
+
34
+ # Jupyter Notebook
35
+ .ipynb_checkpoints/
36
+ *.ipynb_checkpoints/
37
+ Untitled*.ipynb
38
+
39
+ # Numba Cache
40
+ *.nbc
41
+ *.nbi
42
+
43
+ # Data files
44
+ data/raw/*.csv
45
+ data/raw/*.txt
46
+ data/raw/*.zip
47
+ data/raw/*.gz
48
+ data/processed/*.npz
49
+ data/processed/*.npy
50
+ data/processed/*.pkl
51
+ data/partitions/*/
52
+
53
+ # Results and Experiments
54
+ results/*/
55
+ experiments/outputs/
56
+ plots/*.png
57
+ plots/*.jpg
58
+ plots/*.pdf
59
+ plots/*.svg
60
+
61
+ # Models
62
+ models/saved_models/
63
+ *.h5
64
+ *.pkl
65
+ *.pth
66
+ *.ckpt
67
+
68
+ # IDE
69
+ .vscode/
70
+ .idea/
71
+ *.swp
72
+ *.swo
73
+ *~
74
+ .DS_Store
75
+ .project
76
+ .pydevproject
77
+ .settings/
78
+
79
+ # OS
80
+ Thumbs.db
81
+ Desktop.ini
82
+
83
+ # Logs
84
+ *.log
85
+ logs/
86
+
87
+ # Environment variables
88
+ .env
89
+ .env.local
90
+
91
+ # Coverage reports
92
+ htmlcov/
93
+ .tox/
94
+ .coverage
95
+ .coverage.*
96
+ .cache
97
+ nosetests.xml
98
+ coverage.xml
99
+ *.cover
100
+ .hypothesis/
101
+ .pytest_cache/
102
+
103
+ # mypy
104
+ .mypy_cache/
105
+ .dmyc.json
106
+ dmyc.json
107
+
108
+ # Profiling
109
+ *.prof
110
+
111
+ git_auto_commit.py
112
+ report.txt
113
+
114
+ Q1_Publication_Roadmap.md
115
+ notebook_code.py
116
+
117
+ Untitled42 (1).ipynb
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ronit Mehta
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,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: arena-score
3
+ Version: 1.0.0
4
+ Summary: ARENA Score - Adaptive Review and Evaluation using Novel Aggregation Score for Federated Learning
5
+ Project-URL: Homepage, https://github.com/Ronit26Mehta/Arena_exp
6
+ Project-URL: Documentation, https://github.com/Ronit26Mehta/Arena_exp#readme
7
+ Project-URL: Repository, https://github.com/Ronit26Mehta/Arena_exp
8
+ Project-URL: Issues, https://github.com/Ronit26Mehta/Arena_exp/issues
9
+ Author-email: Ronit Mehta <mehtaronit702@gmail.com>
10
+ Maintainer-email: Ronit Mehta <mehtaronit702@gmail.com>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: adaptive-aggregation,aggregation,anomaly-detection,arena-score,client-evaluation,deep-learning,distributed-systems,federated-learning,machine-learning,robust-aggregation
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Requires-Python: >=3.8
28
+ Requires-Dist: numpy>=1.21.0
29
+ Provides-Extra: accelerate
30
+ Requires-Dist: numba>=0.56.0; extra == 'accelerate'
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
33
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # ARENA Score
37
+
38
+ [![PyPI version](https://badge.fury.io/py/arena-score.svg)](https://badge.fury.io/py/arena-score)
39
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
40
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
41
+
42
+ **ARENA Score** (Adaptive Review and Evaluation using Novel Aggregation Score) is a novel client evaluation and weighted aggregation algorithm for Federated Learning.
43
+
44
+ ## 🎯 Key Features
45
+
46
+ - **Adaptive Client Evaluation**: Dynamically assesses client update quality using multiple metrics
47
+ - **Robust Aggregation**: Filters out unreliable/malicious client contributions
48
+ - **Anomaly Detection**: Detects Byzantine clients using KL divergence and cosine similarity
49
+ - **Gradient Recycling**: Maintains momentum by reusing successful updates from missing clients
50
+ - **Model Agnostic**: Works with any model that implements the simple weight interface
51
+
52
+ ## 📊 ARENA Score Formula
53
+
54
+ ```
55
+ S_j = α(t) × max(0, ΔAcc_j) + γ(t) × CS_j + η × SN_j/(1 + SN_j)
56
+ ```
57
+
58
+ Where:
59
+ - **ΔAcc** - Local accuracy improvement
60
+ - **CS** - Cosine similarity between client update and global direction
61
+ - **SN** - Spectral norm: `log(1 + σ_max(W_j))`
62
+ - **α(t), γ(t)** - Adaptive time-varying weights
63
+
64
+ ## 🚀 Installation
65
+
66
+ ```bash
67
+ pip install arena-score
68
+ ```
69
+
70
+ For Numba acceleration (optional):
71
+ ```bash
72
+ pip install arena-score[accelerate]
73
+ ```
74
+
75
+ ## 📝 Quick Start
76
+
77
+ ```python
78
+ from arena_score import ARENAScoreClient, ARENAScoreServer, run_arena_score
79
+
80
+ # Create clients with your model
81
+ clients = [
82
+ ARENAScoreClient(
83
+ client_id=i,
84
+ model=your_model.copy(), # Model with get_weights/set_weights
85
+ X=X_train[i],
86
+ y=y_train[i],
87
+ local_epochs=5,
88
+ batch_size=32
89
+ )
90
+ for i in range(n_clients)
91
+ ]
92
+
93
+ # Run ARENA Score federated learning
94
+ history = run_arena_score(
95
+ global_model=your_model,
96
+ clients=clients,
97
+ n_rounds=10,
98
+ eval_data=(X_test, y_test)
99
+ )
100
+
101
+ print(f"Final accuracy: {history['test_accuracy'][-1]:.4f}")
102
+ ```
103
+
104
+ ## 🔧 Advanced Usage
105
+
106
+ ### Custom Server Configuration
107
+
108
+ ```python
109
+ from arena_score import ARENAScoreServer
110
+
111
+ server = ARENAScoreServer(
112
+ global_model=model,
113
+ alpha_0=0.7, # Initial accuracy weight
114
+ alpha_min=0.3, # Minimum accuracy weight
115
+ gamma_0=0.3, # Initial cosine similarity weight
116
+ gamma_min=0.5, # Minimum cosine similarity weight
117
+ eta=0.5, # Spectral norm coefficient
118
+ lambda_decay=0.1, # Decay rate for adaptive weights
119
+ anomaly_threshold=-0.5, # CS threshold for anomaly detection
120
+ kl_threshold=0.5, # KL divergence threshold
121
+ enable_gradient_recycling=True
122
+ )
123
+ ```
124
+
125
+ ### Computing ARENA Score Directly
126
+
127
+ ```python
128
+ from arena_score import compute_arena_score
129
+
130
+ score = compute_arena_score(
131
+ delta_acc=0.05, # Accuracy improvement
132
+ cosine_sim=0.8, # Cosine similarity
133
+ spectral_norm=2.5, # Spectral norm
134
+ alpha_t=0.5, # Current alpha weight
135
+ gamma_t=0.4 # Current gamma weight
136
+ )
137
+ ```
138
+
139
+ ### Utility Functions
140
+
141
+ ```python
142
+ from arena_score import (
143
+ compute_cosine_similarity,
144
+ compute_spectral_norm,
145
+ compute_kl_divergence,
146
+ flatten_weights,
147
+ unflatten_weights
148
+ )
149
+
150
+ # Compute cosine similarity between weight vectors
151
+ cs = compute_cosine_similarity(weights_a, weights_b)
152
+
153
+ # Compute spectral norm of weights
154
+ sn = compute_spectral_norm(weights_dict)
155
+ ```
156
+
157
+ ## 📈 Model Interface
158
+
159
+ Your model must implement these methods:
160
+
161
+ ```python
162
+ class YourModel:
163
+ def get_weights(self) -> Dict[str, np.ndarray]:
164
+ """Return model weights as a dictionary."""
165
+ pass
166
+
167
+ def set_weights(self, weights: Dict[str, np.ndarray]):
168
+ """Set model weights from a dictionary."""
169
+ pass
170
+
171
+ def forward(self, X: np.ndarray) -> np.ndarray:
172
+ """Forward pass, returns predictions."""
173
+ pass
174
+
175
+ def backward(self, X, y, y_pred) -> Dict[str, np.ndarray]:
176
+ """Backward pass, returns gradients."""
177
+ pass
178
+
179
+ def update_weights(self, gradients: Dict[str, np.ndarray]):
180
+ """Update weights using gradients."""
181
+ pass
182
+
183
+ def predict(self, X: np.ndarray) -> np.ndarray:
184
+ """Make predictions (0/1 for classification)."""
185
+ pass
186
+
187
+ def predict_proba(self, X: np.ndarray) -> np.ndarray:
188
+ """Return probability predictions."""
189
+ pass
190
+
191
+ def copy(self) -> 'YourModel':
192
+ """Return a deep copy of the model."""
193
+ pass
194
+ ```
195
+
196
+ <!-- ## 📄 Citation
197
+
198
+ If you use ARENA Score in your research, please cite:
199
+
200
+ ```bibtex
201
+ @article{arena_score2026,
202
+ title={ARENA Score: Adaptive Review and Evaluation using Novel Aggregation Score for Federated Learning},
203
+ author={Mehta, Ronit},
204
+ year={2026}
205
+ }
206
+ ``` -->
207
+
208
+ ## 📜 License
209
+
210
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,175 @@
1
+ # ARENA Score
2
+
3
+ [![PyPI version](https://badge.fury.io/py/arena-score.svg)](https://badge.fury.io/py/arena-score)
4
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **ARENA Score** (Adaptive Review and Evaluation using Novel Aggregation Score) is a novel client evaluation and weighted aggregation algorithm for Federated Learning.
8
+
9
+ ## 🎯 Key Features
10
+
11
+ - **Adaptive Client Evaluation**: Dynamically assesses client update quality using multiple metrics
12
+ - **Robust Aggregation**: Filters out unreliable/malicious client contributions
13
+ - **Anomaly Detection**: Detects Byzantine clients using KL divergence and cosine similarity
14
+ - **Gradient Recycling**: Maintains momentum by reusing successful updates from missing clients
15
+ - **Model Agnostic**: Works with any model that implements the simple weight interface
16
+
17
+ ## 📊 ARENA Score Formula
18
+
19
+ ```
20
+ S_j = α(t) × max(0, ΔAcc_j) + γ(t) × CS_j + η × SN_j/(1 + SN_j)
21
+ ```
22
+
23
+ Where:
24
+ - **ΔAcc** - Local accuracy improvement
25
+ - **CS** - Cosine similarity between client update and global direction
26
+ - **SN** - Spectral norm: `log(1 + σ_max(W_j))`
27
+ - **α(t), γ(t)** - Adaptive time-varying weights
28
+
29
+ ## 🚀 Installation
30
+
31
+ ```bash
32
+ pip install arena-score
33
+ ```
34
+
35
+ For Numba acceleration (optional):
36
+ ```bash
37
+ pip install arena-score[accelerate]
38
+ ```
39
+
40
+ ## 📝 Quick Start
41
+
42
+ ```python
43
+ from arena_score import ARENAScoreClient, ARENAScoreServer, run_arena_score
44
+
45
+ # Create clients with your model
46
+ clients = [
47
+ ARENAScoreClient(
48
+ client_id=i,
49
+ model=your_model.copy(), # Model with get_weights/set_weights
50
+ X=X_train[i],
51
+ y=y_train[i],
52
+ local_epochs=5,
53
+ batch_size=32
54
+ )
55
+ for i in range(n_clients)
56
+ ]
57
+
58
+ # Run ARENA Score federated learning
59
+ history = run_arena_score(
60
+ global_model=your_model,
61
+ clients=clients,
62
+ n_rounds=10,
63
+ eval_data=(X_test, y_test)
64
+ )
65
+
66
+ print(f"Final accuracy: {history['test_accuracy'][-1]:.4f}")
67
+ ```
68
+
69
+ ## 🔧 Advanced Usage
70
+
71
+ ### Custom Server Configuration
72
+
73
+ ```python
74
+ from arena_score import ARENAScoreServer
75
+
76
+ server = ARENAScoreServer(
77
+ global_model=model,
78
+ alpha_0=0.7, # Initial accuracy weight
79
+ alpha_min=0.3, # Minimum accuracy weight
80
+ gamma_0=0.3, # Initial cosine similarity weight
81
+ gamma_min=0.5, # Minimum cosine similarity weight
82
+ eta=0.5, # Spectral norm coefficient
83
+ lambda_decay=0.1, # Decay rate for adaptive weights
84
+ anomaly_threshold=-0.5, # CS threshold for anomaly detection
85
+ kl_threshold=0.5, # KL divergence threshold
86
+ enable_gradient_recycling=True
87
+ )
88
+ ```
89
+
90
+ ### Computing ARENA Score Directly
91
+
92
+ ```python
93
+ from arena_score import compute_arena_score
94
+
95
+ score = compute_arena_score(
96
+ delta_acc=0.05, # Accuracy improvement
97
+ cosine_sim=0.8, # Cosine similarity
98
+ spectral_norm=2.5, # Spectral norm
99
+ alpha_t=0.5, # Current alpha weight
100
+ gamma_t=0.4 # Current gamma weight
101
+ )
102
+ ```
103
+
104
+ ### Utility Functions
105
+
106
+ ```python
107
+ from arena_score import (
108
+ compute_cosine_similarity,
109
+ compute_spectral_norm,
110
+ compute_kl_divergence,
111
+ flatten_weights,
112
+ unflatten_weights
113
+ )
114
+
115
+ # Compute cosine similarity between weight vectors
116
+ cs = compute_cosine_similarity(weights_a, weights_b)
117
+
118
+ # Compute spectral norm of weights
119
+ sn = compute_spectral_norm(weights_dict)
120
+ ```
121
+
122
+ ## 📈 Model Interface
123
+
124
+ Your model must implement these methods:
125
+
126
+ ```python
127
+ class YourModel:
128
+ def get_weights(self) -> Dict[str, np.ndarray]:
129
+ """Return model weights as a dictionary."""
130
+ pass
131
+
132
+ def set_weights(self, weights: Dict[str, np.ndarray]):
133
+ """Set model weights from a dictionary."""
134
+ pass
135
+
136
+ def forward(self, X: np.ndarray) -> np.ndarray:
137
+ """Forward pass, returns predictions."""
138
+ pass
139
+
140
+ def backward(self, X, y, y_pred) -> Dict[str, np.ndarray]:
141
+ """Backward pass, returns gradients."""
142
+ pass
143
+
144
+ def update_weights(self, gradients: Dict[str, np.ndarray]):
145
+ """Update weights using gradients."""
146
+ pass
147
+
148
+ def predict(self, X: np.ndarray) -> np.ndarray:
149
+ """Make predictions (0/1 for classification)."""
150
+ pass
151
+
152
+ def predict_proba(self, X: np.ndarray) -> np.ndarray:
153
+ """Return probability predictions."""
154
+ pass
155
+
156
+ def copy(self) -> 'YourModel':
157
+ """Return a deep copy of the model."""
158
+ pass
159
+ ```
160
+
161
+ <!-- ## 📄 Citation
162
+
163
+ If you use ARENA Score in your research, please cite:
164
+
165
+ ```bibtex
166
+ @article{arena_score2026,
167
+ title={ARENA Score: Adaptive Review and Evaluation using Novel Aggregation Score for Federated Learning},
168
+ author={Mehta, Ronit},
169
+ year={2026}
170
+ }
171
+ ``` -->
172
+
173
+ ## 📜 License
174
+
175
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,73 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "arena-score"
7
+ version = "1.0.0"
8
+ description = "ARENA Score - Adaptive Review and Evaluation using Novel Aggregation Score for Federated Learning"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ {name = "Ronit Mehta", email = "mehtaronit702@gmail.com"}
14
+ ]
15
+ maintainers = [
16
+ {name = "Ronit Mehta", email = "mehtaronit702@gmail.com"}
17
+ ]
18
+ keywords = [
19
+ "federated-learning",
20
+ "machine-learning",
21
+ "deep-learning",
22
+ "aggregation",
23
+ "distributed-systems",
24
+ "arena-score",
25
+ "adaptive-aggregation",
26
+ "anomaly-detection",
27
+ "client-evaluation",
28
+ "robust-aggregation"
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 4 - Beta",
32
+ "Intended Audience :: Developers",
33
+ "Intended Audience :: Science/Research",
34
+ "License :: OSI Approved :: MIT License",
35
+ "Operating System :: OS Independent",
36
+ "Programming Language :: Python :: 3",
37
+ "Programming Language :: Python :: 3.8",
38
+ "Programming Language :: Python :: 3.9",
39
+ "Programming Language :: Python :: 3.10",
40
+ "Programming Language :: Python :: 3.11",
41
+ "Programming Language :: Python :: 3.12",
42
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
43
+ "Topic :: Software Development :: Libraries :: Python Modules",
44
+ ]
45
+
46
+ dependencies = [
47
+ "numpy>=1.21.0",
48
+ ]
49
+
50
+ [project.optional-dependencies]
51
+ accelerate = [
52
+ "numba>=0.56.0",
53
+ ]
54
+ dev = [
55
+ "pytest>=7.0.0",
56
+ "pytest-cov>=4.0.0",
57
+ ]
58
+
59
+ [project.urls]
60
+ Homepage = "https://github.com/Ronit26Mehta/Arena_exp"
61
+ Documentation = "https://github.com/Ronit26Mehta/Arena_exp#readme"
62
+ Repository = "https://github.com/Ronit26Mehta/Arena_exp"
63
+ Issues = "https://github.com/Ronit26Mehta/Arena_exp/issues"
64
+
65
+ [tool.hatch.build.targets.sdist]
66
+ include = [
67
+ "/src",
68
+ "/README.md",
69
+ "/LICENSE",
70
+ ]
71
+
72
+ [tool.hatch.build.targets.wheel]
73
+ packages = ["src/arena_score"]
@@ -0,0 +1,46 @@
1
+ """
2
+ ARENA Score - Adaptive Review and Evaluation using Novel Aggregation Score
3
+
4
+ A novel client evaluation and weighted aggregation algorithm for Federated Learning.
5
+
6
+ Key Features:
7
+ - Adaptive client evaluation using ΔAcc, CS, and SN metrics
8
+ - Robust aggregation with anomaly detection
9
+ - Gradient recycling for missing clients
10
+ - Model agnostic design
11
+ """
12
+
13
+ from arena_score.score import compute_arena_score, compute_adaptive_weights
14
+ from arena_score.client import ARENAScoreClient
15
+ from arena_score.server import ARENAScoreServer
16
+ from arena_score.aggregator import run_arena_score
17
+ from arena_score.utils import (
18
+ compute_cosine_similarity,
19
+ compute_spectral_norm,
20
+ compute_kl_divergence,
21
+ flatten_weights,
22
+ unflatten_weights
23
+ )
24
+
25
+ __version__ = "1.0.0"
26
+ __author__ = "Ronit Mehta"
27
+ __email__ = "ronit26mehta@gmail.com"
28
+
29
+ __all__ = [
30
+ # Core classes
31
+ "ARENAScoreClient",
32
+ "ARENAScoreServer",
33
+ # Main function
34
+ "run_arena_score",
35
+ # Score computation
36
+ "compute_arena_score",
37
+ "compute_adaptive_weights",
38
+ # Utilities
39
+ "compute_cosine_similarity",
40
+ "compute_spectral_norm",
41
+ "compute_kl_divergence",
42
+ "flatten_weights",
43
+ "unflatten_weights",
44
+ # Version
45
+ "__version__",
46
+ ]