encode_mean function

Encode a given factor variable using means encoding