Created
December 23, 2020 11:38
-
-
Save suhaskv/879088406058aaed340dc052b28756f7 to your computer and use it in GitHub Desktop.
VSB Power Line Blog - Get the imbalance ratio in each phase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Store the imbalance ratio values of each phase | |
avg_imb = [] | |
for phase in metadata_train['phase'].unique(): | |
num_0 = metadata_train[(metadata_train.phase==(phase)) & (metadata_train.target==0)].shape[0] | |
num_1 = metadata_train[(metadata_train.phase==(phase)) & (metadata_train.target==1)].shape[0] | |
imbalance_ratio = num_0/num_1 | |
avg_imb.append(imbalance_ratio) | |
print(f"Imbalance ratio - phase {phase}: {imbalance_ratio}") | |
print(f"Average imbalance ratio: {np.round(np.sum(avg_imb)/len(avg_imb), 2)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment