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
14 changes: 7 additions & 7 deletions smogn/over_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def over_sampling(
num_dtypes = ["int64", "float64"]

for j in range(d):
if data.iloc[:, j].dtype in num_dtypes and any(data.iloc[:, j] > 0):
if data.iloc[:, j].dtype in num_dtypes and all(data.iloc[:, j] > 0):
Copy link
Owner

Choose a reason for hiding this comment

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

What is this doing that any() is not?

Copy link
Author

Choose a reason for hiding this comment

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

all() assures all elements are positive.
any() only assures that some elements are positive (there may also be negative elements).
I made this change because I thought the former is expected here.

feat_non_neg.append(j)

## find features without variation (constant features)
Expand Down Expand Up @@ -264,7 +264,7 @@ def over_sampling(

## generate synthetic y response variable by
## inverse distance weighted
for z in feat_list_num:
for z in feat_list_num[0:(d - 1)]:
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this preferred (genuinely curious)?

Copy link
Author

Choose a reason for hiding this comment

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

I made this change because synth_matrix[:,z] was only defined for 0:(d-1).

a = abs(data.iloc[i, z] - synth_matrix[
i * x_synth + j, z]) / feat_ranges[z]
b = abs(data.iloc[knn_matrix[
Expand All @@ -281,8 +281,8 @@ def over_sampling(

if a == b:
synth_matrix[i * x_synth + j,
(d - 1)] = data.iloc[i, (d - 1)] + data.iloc[
knn_matrix[i, neigh], (d - 1)] / 2
(d - 1)] = (data.iloc[i, (d - 1)] + data.iloc[
knn_matrix[i, neigh], (d - 1)]) / 2
Copy link
Owner

Choose a reason for hiding this comment

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

This is good.

else:
synth_matrix[i * x_synth + j,
(d - 1)] = (b * data.iloc[
Expand Down Expand Up @@ -360,7 +360,7 @@ def over_sampling(

## generate synthetic y response variable by
## inverse distance weighted
for z in feat_list_num:
for z in feat_list_num[0:(d - 1)]:
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this preferred (genuinely curious)?

Copy link
Author

Choose a reason for hiding this comment

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

I made this change because synth_matrix[:,z] was only defined for 0:(d-1).

a = abs(data.iloc[i, z] - synth_matrix[
x_synth * n + count, z]) / feat_ranges[z]
b = abs(data.iloc[knn_matrix[i, neigh], z] - synth_matrix[
Expand All @@ -374,9 +374,9 @@ def over_sampling(
x_synth * n + count, feat_list_nom])

if a == b:
synth_matrix[x_synth * n + count, (d - 1)] = data.iloc[
synth_matrix[x_synth * n + count, (d - 1)] = (data.iloc[
Copy link
Owner

Choose a reason for hiding this comment

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

This is good.

i, (d - 1)] + data.iloc[
knn_matrix[i, neigh], (d - 1)] / 2
knn_matrix[i, neigh], (d - 1)]) / 2
else:
synth_matrix[x_synth * n + count, (d - 1)] = (b * data.iloc[
i, (d - 1)] + a * data.iloc[
Expand Down