Description
Random forest classifier can be fit on multiple target columns where columns have string labels and are not numeric, but when trying to predict, an error is thrown.
Steps/Code to Reproduce
import numpy as np
from sklearn.datasets import make_classification
from sklearn.ensemble.forest import RandomForestClassifier
c = RandomForestClassifier()
X, y = make_classification()
y = np.array(['foo' if v else 'bar' for v in y]).reshape((y.shape[0], 1))
ys = np.hstack([y, y])
c.fit(X, ys)
c.predict(X)
Expected Results
No error is thrown.
Actual Results
File ".../local/lib/python2.7/site-packages/sklearn/ensemble/forest.py", line 550, in predict
axis=0)
ValueError: could not convert string to float: foo
Versions
Linux-4.13.0-45-generic-x86_64-with-Ubuntu-17.10-artful
('Python', '2.7.14 (default, Sep 23 2017, 22:06:14) \n[GCC 7.2.0]')
('NumPy', '1.14.5')
('SciPy', '1.1.0')
('Scikit-Learn', '0.19.1')