python-fedci 0.1.2__tar.gz → 0.1.4__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.
- {python_fedci-0.1.2 → python_fedci-0.1.4}/PKG-INFO +1 -1
- {python_fedci-0.1.2 → python_fedci-0.1.4}/fedci/testing.py +21 -14
- {python_fedci-0.1.2 → python_fedci-0.1.4}/pyproject.toml +1 -1
- {python_fedci-0.1.2 → python_fedci-0.1.4}/python_fedci.egg-info/PKG-INFO +1 -1
- {python_fedci-0.1.2 → python_fedci-0.1.4}/LICENSE +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/README.md +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/fedci/__init__.py +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/fedci/client.py +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/fedci/env.py +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/fedci/server.py +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/fedci/utils.py +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/python_fedci.egg-info/SOURCES.txt +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/python_fedci.egg-info/dependency_links.txt +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/python_fedci.egg-info/requires.txt +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/python_fedci.egg-info/top_level.txt +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/setup.cfg +0 -0
- {python_fedci-0.1.2 → python_fedci-0.1.4}/tests/test.py +0 -0
|
@@ -3,7 +3,13 @@ from typing import Dict, List, Optional, Set, Tuple
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import scipy
|
|
5
5
|
|
|
6
|
-
from .env import
|
|
6
|
+
from .env import (
|
|
7
|
+
get_env_debug,
|
|
8
|
+
get_env_fit_intercept,
|
|
9
|
+
get_env_line_search,
|
|
10
|
+
get_env_lm_damping,
|
|
11
|
+
get_env_ridge,
|
|
12
|
+
)
|
|
7
13
|
from .utils import BetaUpdateData, VariableType
|
|
8
14
|
|
|
9
15
|
|
|
@@ -24,7 +30,7 @@ class RegressionTest:
|
|
|
24
30
|
self.num_classes, self.num_parameters = params
|
|
25
31
|
self.dof = self.num_classes * self.num_parameters
|
|
26
32
|
self.beta = np.zeros((self.dof, 1))
|
|
27
|
-
#self.beta = np.random.randn(self.dof, 1)
|
|
33
|
+
# self.beta = np.random.randn(self.dof, 1)
|
|
28
34
|
self.alpha = 1.0
|
|
29
35
|
|
|
30
36
|
self.convergence_threshold = convergence_threshold
|
|
@@ -131,7 +137,9 @@ class RegressionTest:
|
|
|
131
137
|
self.early_stop = True
|
|
132
138
|
return
|
|
133
139
|
|
|
134
|
-
if
|
|
140
|
+
if (
|
|
141
|
+
self.iterations == 0 and np.allclose(xwz, np.zeros_like(xwz))
|
|
142
|
+
): # readjust beta -> mostly an issue with small datasets and perfectly even distribution of categories
|
|
135
143
|
self.beta = np.random.randn(self.dof, 1)
|
|
136
144
|
self.iterations += 1
|
|
137
145
|
return
|
|
@@ -169,10 +177,7 @@ class RegressionTest:
|
|
|
169
177
|
|
|
170
178
|
self.convergence_retry_count += 1
|
|
171
179
|
|
|
172
|
-
self.beta = self._get_new_beta(
|
|
173
|
-
self.previous_xwx,
|
|
174
|
-
self.previous_xwz
|
|
175
|
-
)
|
|
180
|
+
self.beta = self._get_new_beta(self.previous_xwx, self.previous_xwz)
|
|
176
181
|
return
|
|
177
182
|
|
|
178
183
|
self.convergence_retry_count = 0
|
|
@@ -185,9 +190,9 @@ class RegressionTest:
|
|
|
185
190
|
self.lm_lambda /= 10
|
|
186
191
|
beta = self._get_new_beta(xwx, xwz)
|
|
187
192
|
if (
|
|
188
|
-
#self.iterations == 0
|
|
189
|
-
#and np.linalg.norm(self.beta - beta) < 1e-4
|
|
190
|
-
#or np.linalg.norm(self.beta - beta) < 1e-8
|
|
193
|
+
# self.iterations == 0
|
|
194
|
+
# and np.linalg.norm(self.beta - beta) < 1e-4
|
|
195
|
+
# or np.linalg.norm(self.beta - beta) < 1e-8
|
|
191
196
|
np.linalg.norm(self.beta - beta) < 1e-8
|
|
192
197
|
):
|
|
193
198
|
self.early_stop = True
|
|
@@ -227,12 +232,14 @@ class LikelihoodRatioTest:
|
|
|
227
232
|
self.bad_fit = False
|
|
228
233
|
|
|
229
234
|
self.p_value: Optional[float] = None
|
|
235
|
+
self.chi2stat = None
|
|
236
|
+
self.dof = None
|
|
230
237
|
|
|
231
238
|
def __repr__(self):
|
|
232
239
|
if self.p_value is None:
|
|
233
240
|
val = "not finished"
|
|
234
241
|
else:
|
|
235
|
-
val = f"p: {self.p_value:.4f}"
|
|
242
|
+
val = f"p: {self.p_value:.4f} ({self.chi2stat:.4f}, {self.dof})"
|
|
236
243
|
restricted_test_string = self.restricted_test.__repr__()
|
|
237
244
|
restricted_test_string = "\n\t".join(restricted_test_string.split("\n"))
|
|
238
245
|
unrestricted_test_string = self.unrestricted_test.__repr__()
|
|
@@ -328,9 +335,9 @@ class LikelihoodRatioTest:
|
|
|
328
335
|
t0_dof = self.restricted_test.dof
|
|
329
336
|
t1_dof = self.unrestricted_test.dof
|
|
330
337
|
|
|
331
|
-
self.
|
|
332
|
-
|
|
333
|
-
).item()
|
|
338
|
+
self.chi2stat = 2 * (t1_llf - t0_llf)
|
|
339
|
+
self.dof = t1_dof - t0_dof
|
|
340
|
+
self.p_value = scipy.stats.chi2.sf(self.chi2stat, self.dof).item()
|
|
334
341
|
|
|
335
342
|
if get_env_debug() >= 2:
|
|
336
343
|
print(
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-fedci"
|
|
7
7
|
authors = [{ name = "Maximilian Hahn", email = "max.hahn@gmx.de" }]
|
|
8
|
-
version = "0.1.
|
|
8
|
+
version = "0.1.4"
|
|
9
9
|
license = { file = "LICENSE" }
|
|
10
10
|
description = "A small package for federated independence tests"
|
|
11
11
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|