If the dependent variable is categorical, where categories are strings, the method model_predictions fails. The problem is that the the pred array is initialized as:
pred = np.zeros(self.data_size)
and that enforces predictions to be numerical. In order to solve that, the model_predictions could be rewritten to something like the following:
pred = [None] * self.data_size
for node in self:
if node.is_terminal:
max_val = max(node.members, key=node.members.get)
for i in node.indices:
pred[i] = max_val
return pred
If the dependent variable is categorical, where categories are strings, the method model_predictions fails. The problem is that the the pred array is initialized as:
and that enforces predictions to be numerical. In order to solve that, the model_predictions could be rewritten to something like the following:
Best regards