Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Fixed data_frame_tool to handle category columns correctly #456

Merged
merged 1 commit into from
Feb 26, 2020
Merged
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
2 changes: 1 addition & 1 deletion src/python/tests_extended/data_frame_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _process_input_list(self, df, input_metas, require):
if (df[input_meta.name].dtype) == 'datetime64[ns]':
input_array = np.array([dt.timestamp() for dt in df[input_meta.name]]).astype(np.int64)
elif (str(df[input_meta.name].dtype)) == 'category':
input_array = np.array([dt + 1 for dt in df[input_meta.name]]).astype(np.uint32) # in ONNX models trained in ML.NET "categorical columns" are 1 based, not 0 based
input_array = np.array([key + 1 for key in df[input_meta.name].array.codes]).astype(np.uint32) # in ONNX models trained in ML.NET input coming from "categorical columns" is 1 based indices, whereas Categorical columns save indices that are 0 based, and that need to be retrieved from .array.codes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.array.codes [](start = 82, length = 12)

yep!

else:
# With strings we must cast first to np.object then then reshape
# so we do it for everything
Expand Down