Jason Kim (Jun Chul Kim)
Jason Kim (Jun Chul Kim)
I think a better solution is using [pandas.DataFrame.sparse.from_spmatrix](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sparse.from_spmatrix.html) explicitly. ```python df_output = pd.DataFrame.sparse.from_spmatrix(cat_encoder.transform(df_test_unknown), columns=cat_encoder.get_feature_names_out(), index=df_test_unknown.index) ```
Oh.. I think I found where the confusion is coming from. In the book, the author suggested using dense matrix as just an alternative. > Alternatively, you can set sparse=False...