# How can I write a custom loss function to punish lower predicted values?

I am trying to write a custom loss function for XGBRegressor that needs to punish predicted values that are under some arbitrary threshold. The code I came up with does not affect the results at all, and I was wondering if I was doing something way off, or just the model does not perform well with the function I am trying to use.

def f(y_true, y_pred):
residual = (y_pred - y_true).astype("float")
grad = np.where(y_pred < 2, -0.2*residual, residual)
hess = 0.01 + np.repeat(0, len(y_pred))