For regression, this might not be the best solution. Maybe you can to consider two floating point values for the same if their difference is very small. Could you check how they handled this in other implementations?

It is just an idea though, no need to change it right away, but please check what I mention above.