Ik vindt een goed artikel die hier wat duidelijkheid in geeft:
Learning from Imbalanced Classes
In het kort staan daar de volgende opties:
- Do nothing. Sometimes you get lucky and nothing needs to be done. You can train on the so-called natural (or stratified) distribution and sometimes it works without need for modification.
- Balance the training set in some way:
- Oversample the minority class.
- Undersample the majority class.
- Synthesize new minority classes.
- Throw away minority examples and switch to an anomaly detection framework.
- At the algorithm level, or after it:
- Adjust the class weight (misclassification costs).
- Adjust the decision threshold.
- Modify an existing algorithm to be more sensitive to rare classes.
- Construct an entirely new algorithm to perform well on imbalanced data.
Orgineel:
def root_mean_squared_error(y_true, y_pred):
"""
RMSE loss function
"""
return K.sqrt(K.mean(K.square(y_pred - y_true), axis=-1))
Aangepast:
def root_mean_squared_error(y_true, y_pred):
"""
RMSE loss function
"""
return K.sqrt(K.mean(K.square(y_pred - y_true) + 3 * (y_true) * K.square(y_pred - y_true), axis=-1))
In dit geval maak ik de error 4x zo groot als y_true 1 is.
Ik zie helaas nog weinig verbetering. Of mijn toepassing van de formule is fout of (en?) ik moet een andere strategie bedenken om meer balans in mijn dataset te krijgen.
Geen opmerkingen:
Een reactie posten