Skip to content
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

ENH: Adding IncrementalRidge support into sklearnex #1957

Merged
merged 18 commits into from
Aug 27, 2024

Conversation

DDJHB
Copy link
Contributor

@DDJHB DDJHB commented Jul 24, 2024

Description

This pr introduces Incremental Ridge to sklearnex.

Fixes # - issue number(s) if exists

  • I have reviewed my changes thoroughly before submitting this pull request.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes, if necessary (updated in # - add PR number)
  • The unit tests pass successfully.
  • I have run it locally and tested the changes extensively.
  • I have resolved any merge conflicts that might occur with the base branch.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)
  • I have added a respective label(s) to PR if I have a permission for that.

@DDJHB
Copy link
Contributor Author

DDJHB commented Jul 29, 2024

/intelci: run

@ethanglaser
Copy link
Contributor

General comment: not sure this needs to go into preview. A bit of a unique situation since batch ridge regression is currently in preview, but considering there is no stock scikit-learn IncrementalRidge estimator it can probably go straight into sklearnex/linear_model

@DDJHB DDJHB changed the title ENH: Adding IncrementalRidge support into sklearnex.preview ENH: Adding IncrementalRidge support into sklearnex Jul 31, 2024
@DDJHB
Copy link
Contributor Author

DDJHB commented Jul 31, 2024

/intelci: run

@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 2, 2024

/intelci: run

@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 5, 2024

/intelci: run

@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 6, 2024

/intelci: run

@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 7, 2024

/intelci: run

@icfaust
Copy link
Contributor

icfaust commented Aug 8, 2024

Private CI Green with unrelated failures.

Copy link
Contributor

@icfaust icfaust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes, otherwise first round looks good.

Comment on lines 257 to 259
if self.coef_.shape[0] == 1 and self._y_ndim_1:
self.coef_ = self.coef_.ravel()
self.intercept_ = self.intercept_[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this code came from the IncrementalLinearRegression, but _y_ndim_1 seems somehow unnecessary. Can't the dimensions of y be queried from the intercept or coefficients? i.e. cant we just use np.squeeze on the result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, nice suggestion

@pytest.mark.parametrize("queue", get_queues())
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.skip(reason="pickling not implemented for oneDAL entities")
def test_pickle(queue, dtype):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make sure there is a ticket or note in another ticket to remove this skip when serialization is implemented for IncrementalRidge

@control_n_jobs(
decorated_methods=["fit", "partial_fit", "predict", "_onedal_finalize_fit"]
)
class IncrementalRidge(MultiOutputMixin, BaseEstimator, RegressorMixin):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class IncrementalRidge(MultiOutputMixin, BaseEstimator, RegressorMixin):
class IncrementalRidge(MultiOutputMixin, RegressorMixin, BaseEstimator):

BaseEstimator is generally latest in the MRO for sklearn estimators. I'm not sure what may overwrite the RegressorMixin or MultiOutputMixin, but just to be sure and to match convention.

)
return self

def fit(self, X, y):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm opening pandora's box here but Ridge takes sample_weight https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/linear_model/_ridge.py#L911 . This is also the case for preview Ridge. Please add a keyword for conformance purposes and add an error if its not None. I know that may seem unnecessary, but generally trying to conform to related estimators is top priority. You can let me know if you find that unneccessary.

@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 9, 2024

/intelci: run

@DDJHB DDJHB marked this pull request as ready for review August 20, 2024 11:34
@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 26, 2024

/intelci: run

Copy link
Contributor

@icfaust icfaust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change on line 217 of onedal/linear_model/incremental_linear_model.py otherwise good to merge

@DDJHB
Copy link
Contributor Author

DDJHB commented Aug 27, 2024

/intelci: run

@DDJHB DDJHB merged commit efd8d92 into uxlfoundation:main Aug 27, 2024
17 of 18 checks passed
md-shafiul-alam pushed a commit to md-shafiul-alam/scikit-learn-intelex that referenced this pull request Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants