Skip to content

Error fitting logistic regression on mnist dataset #20019

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

Closed
palladiun opened this issue May 1, 2021 · 4 comments
Closed

Error fitting logistic regression on mnist dataset #20019

palladiun opened this issue May 1, 2021 · 4 comments

Comments

@palladiun
Copy link

palladiun commented May 1, 2021

Error fitting logistic regression on mnist dataset

When I try to fit the data , I get this error

ValueError                                Traceback (most recent call last)
<ipython-input-42-78e42af1b936> in <module>
----> 1 lr.fit(x_train,y_train)

/usr/local/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py in fit(self, X, y, sample_weight)
   1525 
   1526         X, y = check_X_y(X, y, accept_sparse='csr', dtype=_dtype, order="C",
-> 1527                          accept_large_sparse=solver != 'liblinear')
   1528         check_classification_targets(y)
   1529         self.classes_ = np.unique(y)

/usr/local/lib/python3.7/site-packages/sklearn/utils/validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)
    753                     ensure_min_features=ensure_min_features,
    754                     warn_on_dtype=warn_on_dtype,
--> 755                     estimator=estimator)
    756     if multi_output:
    757         y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,

/usr/local/lib/python3.7/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
    576         if force_all_finite:
    577             _assert_all_finite(array,
--> 578                                allow_nan=force_all_finite == 'allow-nan')
    579 
    580     if ensure_min_samples > 0:

/usr/local/lib/python3.7/site-packages/sklearn/utils/validation.py in _assert_all_finite(X, allow_nan, msg_dtype)
     58                     msg_err.format
     59                     (type_err,
---> 60                      msg_dtype if msg_dtype is not None else X.dtype)
     61             )
     62     # for object dtype data, we only check for NaNs (GH-13254)

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
@palladiun palladiun changed the title Error fitting logsitic regression on mnist dataset Error fitting logistic regression on mnist dataset May 1, 2021
@PSSF23
Copy link
Contributor

PSSF23 commented May 1, 2021

Not a sklearn problem. Better clean up your dataset before fitting.

@palladiun
Copy link
Author

It is the standard mnist dataset, it doesnt have any of the errors listed

@glemaitre
Copy link
Member

The error message mentioned that there are non-finite values. Please check the data.

Otherwise, we need the minimal example to reproduce the problem and investigate for a potential issue.

@adrinjalali
Copy link
Member

Closing, will reopen once we have a minimal reproducible example.

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

No branches or pull requests

4 participants