Created
November 6, 2022 13:52
-
-
Save rdisipio/468d703186bd858282735f739788e6cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.preprocessing import KBinsDiscretizer | |
n_bins = 10 # the more, the merrier | |
scaled_feature_names = [f"q_{x}" for x in feature_names] | |
qt = KBinsDiscretizer(n_bins=n_bins, encode='ordinal', strategy='quantile') | |
X_qt = qt.fit_transform(X).astype(np.int32) # nb: bin number must be an integer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment