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

Suppress scikit-learn warning "X has feature names" #51

Closed
lars-reimann opened this issue Mar 20, 2023 · 1 comment · Fixed by #53
Closed

Suppress scikit-learn warning "X has feature names" #51

lars-reimann opened this issue Mar 20, 2023 · 1 comment · Fixed by #53
Assignees
Labels
released Included in a release

Comments

@lars-reimann
Copy link
Member

Describe the bug

scikit-learn issues a UserWarning when calling the predict method:

C:\Users\Lars\AppData\Local\pypoetry\Cache\virtualenvs\safe-ds-wkHRa4ib-py3.11\Lib\site-packages\sklearn\base.py:432: UserWarning: X has feature names, but LinearRegression was fitted without feature names
  warnings.warn(

To Reproduce

Run this code:

from safeds.data import SupervisedDataset
from safeds.data.tabular import Table

training_set = Table({
    "a":      [3, 4,  8,  6, 5],
    "b":      [2, 2,  1,  6, 3],
    "c":      [1, 1,  1,  1, 1],
    "result": [6, 7, 10, 13, 9]
})

supervised_training_set = SupervisedDataset(
    training_set,
    target_column="result"
)


from safeds.ml.regression import LinearRegression

model = LinearRegression()
model.fit(supervised_training_set)

test_set = Table({
    "a": [1, 1, 0, 2, 4],
    "b": [2, 0, 5, 2, 7],
    "c": [1, 4, 3, 2, 1]})

model.predict(dataset=test_set)

Expected behavior

No warning, or at least a warning of our system. We should not leak implementation details.

Screenshots (optional)

No response

Additional Context (optional)

No response

@github-project-automation github-project-automation bot moved this to Backlog in Library Mar 20, 2023
@lars-reimann lars-reimann added the good first issue Good for newcomers label Mar 20, 2023
@lars-reimann lars-reimann self-assigned this Mar 20, 2023
@lars-reimann lars-reimann moved this from Backlog to Todo in Library Mar 20, 2023
@lars-reimann lars-reimann removed the good first issue Good for newcomers label Mar 20, 2023
@lars-reimann lars-reimann moved this from Todo to In Progress in Library Mar 20, 2023
@lars-reimann lars-reimann linked a pull request Mar 20, 2023 that will close this issue
lars-reimann added a commit that referenced this issue Mar 20, 2023
Closes #51.

### Summary of Changes

Suppress a warning from `scikit-learn` that is not relevant for us.

See also:
https://stackoverflow.com/questions/69326639/sklearn-warning-valid-feature-names-in-version-1-0

---------

Co-authored-by: lars-reimann <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to ✔️ Done in Library Mar 20, 2023
lars-reimann pushed a commit that referenced this issue Mar 24, 2023
## [0.3.0](v0.2.0...v0.3.0) (2023-03-24)

### Features

* make `Column` and `Row` iterable ([#55](#55)) ([74eea1f](74eea1f)), closes [#47](#47)

### Bug Fixes

* "UserWarning: X has feature names" when predicting ([#53](#53)) ([74b0753](74b0753)), closes [#51](#51)
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Included in a release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant