I thought if the `userVal` can't be found, we should raise a panic? If the given string isn't belong to the categories, we just can't continue our training or predicting. With raising a panic, we don't need to check if the returned value is less than 0 or not everytime.
I'm not sure which one is more idiomatic, though.