-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimbalance_common.py
More file actions
18 lines (16 loc) · 806 Bytes
/
imbalance_common.py
File metadata and controls
18 lines (16 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Compute Imbalance ratio for each label
IRs = (float(train_oh_diagnoses_df.shape[0])
/ train_oh_diagnoses_df.sum(axis=0)) - 1.0
# IRs = IRs.clip(upper=25).to_numpy()
class_weights = np.ones(shape=IRs.shape + (2,))
class_weights[:, 1] = IRs
label_frequencies = train_oh_diagnoses_df.sum(axis=0)/float(train_oh_diagnoses_df.shape[0])
# Add the corresponding entry to the hyperparameters dict
hp_values['class_weight_cap'] = {'enable': True,
'name': "IR_cap",
'min_value': 1,
'max_value': 200,
'sampling': 'log',
'default': 2,
'label_frequencies': label_frequencies
}