how to pass mixed (categorical and numeric) features to Decision Tree Regressor in sklearn?
问题 How can I pass Categorical and numeric features to DecisionTreeRegressor in sklearn? below code shows how to use the code in general for numeric features: make_tree = tree.DecisionTreeRegressor() fit_tree = make_tree.fit(X_train, y_train) 回答1: First, all categorical features should be encoded (represented by numbers) to be interpretable for the regression models. To do so, you can use, LabelEncoder followed by OneHotEncoder. In the case of high-cardinal features, you can use FeatureHasher. As