-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: initial refactoring of incremental spmd algos #2248
base: main
Are you sure you want to change the base?
Changes from all commits
6112457
9c72d9c
e455c56
572bae5
da5c27c
6fdcbaa
4acc102
f9e6b36
28c4eb5
bc147eb
8559c5f
1fdecd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,8 +71,9 @@ def __init__(self, result_options="all"): | |
|
||
def _reset(self): | ||
self._need_to_finalize = False | ||
self._partial_result = self._get_backend( | ||
"basic_statistics", None, "partial_compute_result" | ||
# Not supported with spmd policy so IncrementalBasicStatistics must be specified | ||
self._partial_result = IncrementalBasicStatistics._get_backend( | ||
ethanglaser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
IncrementalBasicStatistics, "basic_statistics", None, "partial_compute_result" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
|
||
def __getstate__(self): | ||
|
@@ -105,7 +106,10 @@ def partial_fit(self, X, weights=None, queue=None): | |
Returns the instance itself. | ||
""" | ||
self._queue = queue | ||
policy = self._get_policy(queue, X) | ||
# Not supported with spmd policy so IncrementalBasicStatistics must be specified | ||
policy = IncrementalBasicStatistics._get_policy( | ||
IncrementalBasicStatistics, queue, X | ||
) | ||
|
||
X = _check_array( | ||
X, dtype=[np.float64, np.float32], ensure_2d=False, force_all_finite=False | ||
|
@@ -123,7 +127,9 @@ def partial_fit(self, X, weights=None, queue=None): | |
self._onedal_params = self._get_onedal_params(False, dtype=dtype) | ||
|
||
X_table, weights_table = to_table(X, weights, queue=queue) | ||
self._partial_result = self._get_backend( | ||
# Not supported with spmd policy so IncrementalBasicStatistics must be specified | ||
self._partial_result = IncrementalBasicStatistics._get_backend( | ||
IncrementalBasicStatistics, | ||
"basic_statistics", | ||
None, | ||
"partial_compute", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ def test_on_gold_data(queue, is_deterministic, whiten, num_blocks, dtype): | |
|
||
result = incpca.finalize_fit() | ||
|
||
transformed_data = incpca.predict(X, queue=queue) | ||
transformed_data = incpca.transform(X, queue=queue) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for conformance purposes to sklearn (though not strictly necessary in the onedal folder)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly - pca predict does not exist in sklearn so would prefer to not use this convention if possible |
||
|
||
expected_n_components_ = 2 | ||
expected_components_ = np.array([[0.83849224, 0.54491354], [-0.54491354, 0.83849224]]) | ||
|
@@ -128,7 +128,7 @@ def test_on_random_data( | |
|
||
incpca.finalize_fit() | ||
|
||
transformed_data = incpca.predict(X, queue=queue) | ||
transformed_data = incpca.transform(X, queue=queue) | ||
tol = 3e-3 if transformed_data.dtype == np.float32 else 2e-6 | ||
|
||
n_components = incpca.n_components_ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the comment