The bayesopt function uses a special technique to handle categorical variables. One-hot coding is not used. Instead, bayesopt encodes the categorical variable as an integer variable, and uses an ARD Gaussian Process kernel with a fixed spatial scale on that dimension that is so small that neighboring integer values have virtually no effect on each other. The value of the objective function model at x=7 has no effect on the model's value at x=8. The result is that the distinct integer values must be probed individually to learn what the objective function is at that value. One-hot coding would probably produce similar behavior but would increase the number of variables and require a constraint between them to make sure only one dimension is probed at a time.