Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TypeError Traceback (most recent call last)
Cell In[60], line 4
2 scaler = StandardScaler()
3 X_train_num = scaler.fit_transform(X_train_num)
----> 4 ohe = OneHotEncoder(sparse=False)
5 X_train_cat = ohe.fit_transform(df_train[categorical_columns].values)
6 X_train_cat

You get above error when categorical values are oneHotEncoded using sparse as parameter. This is because in scikit-learn ≥1.2, the OneHotEncoder no longer uses the sparse parameter. Instead, it now uses sparse_output.
So create OneHotEncoder class using spare_output as argument like below,
ohe = OneHotEncoder(sparse_output=False)