Custom loss functions are under appreciated by a lot of people new to the field. Good to see a writeup on it, especially one with nice charts and an example on real data.
Thanks for the feedback. As someone just getting started in this area, I was having trouble finding clear examples. Using the R interface probably isn't the best way to get started with custom loss functions, because the error messages you get from nested python calls are usually not too descriptive.