import numpy as np
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import RandomForestRegressor
X = np.asarray([('a', 1, 2), ('b', 2, 3), ('a', 3, 2), ('c', 1, 3)])
y = np.asarray([1, 2.5, 3, 4])
X[:, (0)] = LabelEncoder().fit_transform(X[:, (0)])
regressor = RandomForestRegressor(n_estimators=150, min_samples_split=1)
regressor.fit(X, y)
print(X)
print(regressor.predict(X))
Regression trees or Random Forest regressor with categorical inputs