Confusion Matrix creation in predictive modeling in experiments with data

‘data’ and ‘reference’ should be factors with same levels.