Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Missing import at documentation preprocessing.rst #28381

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
alanlivio opened this issue Feb 7, 2024 · 0 comments · Fixed by #28382
Closed

Missing import at documentation preprocessing.rst #28381

alanlivio opened this issue Feb 7, 2024 · 0 comments · Fixed by #28382
Labels
Documentation Needs Triage Issue requires triage

Comments

@alanlivio
Copy link
Contributor

Describe the issue linked to the documentation

Missing import to sklearn.preprocessing

import pandas as pd
import numpy as np
bins = [0, 1, 13, 20, 60, np.inf]
labels = ['infant', 'kid', 'teen', 'adult', 'senior citizen']
transformer = preprocessing.FunctionTransformer(
    pd.cut, kw_args={'bins': bins, 'labels': labels, 'retbins': False}
)
X = np.array([0.2, 2, 15, 25, 97])
transformer.fit_transform(X)

Suggest a potential alternative/fix

import pandas as pd
import numpy as np
from sklearn import preprocessing

bins = [0, 1, 13, 20, 60, np.inf]
labels = ['infant', 'kid', 'teen', 'adult', 'senior citizen']
transformer = preprocessing.FunctionTransformer(
    pd.cut, kw_args={'bins': bins, 'labels': labels, 'retbins': False}
)
X = np.array([0.2, 2, 15, 25, 97])
transformer.fit_transform(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Needs Triage Issue requires triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant