-
Notifications
You must be signed in to change notification settings - Fork 84
Correct possible bug #29
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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): | ||
| feat_non_neg.append(j) | ||
|
|
||
| ## find features without variation (constant features) | ||
|
|
@@ -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)]: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this preferred (genuinely curious)?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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[ | ||
|
|
@@ -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 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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[ | ||
|
|
@@ -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)]: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this preferred (genuinely curious)?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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[ | ||
|
|
@@ -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[ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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[ | ||
|
|
||
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.