Open RainFung opened 5 days ago
Hello, if the weights you want to apply are based on the labels you could simply do something like that:
from sklearn.metrics import r2_score
class R2Score(Metric):
def __init__(self):
self._name = "r2"
self._maximize = True
def __call__(self, y_true, y_pred):
weights_example=y_true**2
return r2_score(y_true, y_pred, sample_weight=weights_example)
if the weights are just external weights then you won't be able to easily access them inside tabnet .fit
unfortunately. You can still monitor a proxy r2_score without weights during training and compute your out of fold weighted r2_score at the end of each fold.
how can i add weight for r2_score