Skip to content
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

[UserWarning] Fixing UserWarnings in two tests. #409

Merged
merged 4 commits into from
Jun 12, 2024
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
9 changes: 5 additions & 4 deletions test/transforms/test_cat_to_num_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def test_cat_to_num_transform_on_categorical_only_dataset(with_nan):
# The transform uses m-target estimation, where each categorical
# feature is transformed to (num_count + target_mean)/(num_rows + 1).
# This test tests the correctness in multiclass classification task.
src_tensor = (num_rows + target_mean[0]) / (num_rows + 1)
assert torch.allclose(
out.feat_dict[stype.numerical][:, 0].float(),
torch.tensor((num_rows + target_mean[0]) / (num_rows + 1),
device=out.device).repeat(num_rows))
src_tensor.clone().detach().to(out.device).repeat(num_rows))

# assert that there are no categorical features
assert (stype.categorical not in out.col_names_dict)
Expand Down Expand Up @@ -135,10 +135,11 @@ def test_cat_to_num_transform_with_loading(task_type):
# (num_count + target_mean)/(num_rows + 1).
# This test tests the correctness in multiclass classification
# task.
src = (num_rows + dataset.tensor_frame.y.float().mean()) / (num_rows +
1)
assert torch.allclose(
out.feat_dict[stype.numerical][:, total_numerical_cols].float(),
torch.tensor((num_rows + dataset.tensor_frame.y.float().mean()) /
(num_rows + 1), device=out.device).repeat(num_rows))
src.clone().detach().to(out.device).repeat(num_rows))
else:
# when the task is multiclass classification, the number of
# columns changes.
Expand Down
Loading