Skip to content

Instantly share code, notes, and snippets.

@terrah27
Created February 3, 2019 21:18
Show Gist options
  • Save terrah27/9b57c2ff82d58f23874254101fc1e1bb to your computer and use it in GitHub Desktop.
Save terrah27/9b57c2ff82d58f23874254101fc1e1bb to your computer and use it in GitHub Desktop.
# still using our separated classes fraud and not_fraud from above
# downsample majority
not_fraud_downsampled = resample(not_fraud,
replace = False, # sample without replacement
n_samples = len(fraud), # match minority n
random_state = 27) # reproducible results
# combine minority and downsampled majority
downsampled = pd.concat([not_fraud_downsampled, fraud])
# checking counts
downsampled.Class.value_counts()
1 360
0 360
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment