Skip to content

Instantly share code, notes, and snippets.

@ashhadulislam
Created December 24, 2021 16:09
Show Gist options
  • Save ashhadulislam/e0f8f0a3710969d579c8446aa0a0df86 to your computer and use it in GitHub Desktop.
Save ashhadulislam/e0f8f0a3710969d579c8446aa0a0df86 to your computer and use it in GitHub Desktop.
X_new,y_new,_,_=knnor.fit_resample(X,y,
num_neighbors=10, # the number of neighbors that will be used for generation of each artificial point
max_dist_point=0.01, # the maximum distance at which the new point will be placed
proportion_minority=0.3, # proportion of the minority population that will be used to generate the artificial point
final_proportion=2 # final number of minority datapoints
# example, if num majority =15 and num minority =5,
# putting final_proportion as 1 will add 10 artificial minority points
)
print("Shape after augmentation",X_new.shape,y_new.shape)
elements_count = collections.Counter(y_new)
# printing the element and the frequency
print("Final distribution:")
for key, value in elements_count.items():
print(f"{key}: {value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment