-
Notifications
You must be signed in to change notification settings - Fork 554
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
Improve model round-tripping #6342
base: branch-25.04
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -72,6 +72,7 @@ def assert_estimator_roundtrip( | |
else: | ||
cuml_model.fit(X) | ||
|
||
original_params = cuml_model.get_params() | ||
# Convert to sklearn model | ||
sklearn_model = cuml_model.as_sklearn() | ||
check_is_fitted(sklearn_model) | ||
|
@@ -81,6 +82,8 @@ def assert_estimator_roundtrip( | |
# Convert back | ||
roundtrip_model = type(cuml_model).from_sklearn(sklearn_model) | ||
|
||
assert original_params == roundtrip_model.get_params() | ||
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. I think this should be true. Otherwise calling |
||
|
||
# Ensure roundtrip model is fitted | ||
check_is_fitted(roundtrip_model) | ||
|
||
|
@@ -115,7 +118,7 @@ def test_kmeans(random_state): | |
X, _ = make_blobs( | ||
n_samples=50, n_features=2, centers=3, random_state=random_state | ||
) | ||
original = KMeans(n_clusters=3, random_state=random_state) | ||
original = KMeans(n_clusters=13, random_state=random_state) | ||
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 a random value that isn't the default |
||
assert_estimator_roundtrip(original, SkKMeans, X) | ||
|
||
|
||
|
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.
We can make this nicer, left it like this for now to illustrate the point. I think we need some translation mechanism, not just blindly copying things.
In the GPU -> CPU direction attributes are already copied, but probably also needs adjusting?