A category seen only once or twice gives an unreliable mean. Blending that mean with a prior, weighted by a, keeps the encoding stable when data is sparse.
Implement target_statistic(sum_y, count, prior, a), returning (sum_y + a * prior) / (count + a).
Add the prior's pseudo-count to the label sum and the denominator.
No results yet
Run your code to check it against the examples, or submit to run every test.