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

Add float32 support for SGDClassifier and SGDRegressor #5776

Closed
elanmart opened this issue Nov 10, 2015 · 6 comments · Fixed by #25587
Closed

Add float32 support for SGDClassifier and SGDRegressor #5776

elanmart opened this issue Nov 10, 2015 · 6 comments · Fixed by #25587

Comments

@elanmart
Copy link

Hi,

I was wondreing why sklearn does not allow me to specify the dtype I'd like to use.

I'm working with rather large dataset, which fits into my RAM as float32, but when I'm trying to train a simple SGD on it, the model tries to copy my data into float64, causing MemoryError.

I can change this in my local sklearn build, but I guess there is a good reason why this is not a free parameter?

@amueller
Copy link
Member

PR welcome ;)
It would be great to have both 32 and 64 bit everywhere, I think.
This means using fused types everywhere in Cython.

One of the reasons not to do that was the explosion in the generated C code, but I think with #5492 we need to be somewhat less careful about that.

@lorentzenchr
Copy link
Member

#13243 implemented float32 support for SequentialDataset. This has to be propagated to _plain_sgd in _sgd_fast.pyx (and other places) in order to enable to preserve float32 X ndarrays in SGDClassifier and SGDRegressor.

@lorentzenchr lorentzenchr added Enhancement help wanted module:linear_model cython float32 Issues related to support for 32bit data Performance and removed Performance Hard Hard level of difficulty labels Feb 9, 2023
@jjerphan
Copy link
Member

jjerphan commented Feb 9, 2023

@OmarManzoor: you might be interested in this slightly harder Cython issue.

@OmarManzoor
Copy link
Contributor

@jjerphan Thank you for suggesting.

@OmarManzoor
Copy link
Contributor

@jjerphan Do we need to change the _sgd_fast.pxd file in relation to this? On checking its usages it is mainly being used inside the _sag_fast module which I think already supports float32 and float64.

@OmarManzoor
Copy link
Contributor

@jjerphan Do we need to change the _sgd_fast.pxd file in relation to this? On checking its usages it is mainly being used inside the _sag_fast module which I think already supports float32 and float64.

On further investigation I don't think we need to change this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants