【发布时间】:2021-06-05 22:45:26
【问题描述】:
我正在尝试创建一个决策树,下面是我的代码:
X=updated[['dayofthemonth','hour']]
y=updated['Encounters']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=80, shuffle=True)
gpc = RandomForestRegressor(random_state=0).fit(X_train, y_train)
pre=gpc.predict(X_test)
gpc.score(X_test, y_test)
pre
我也在尝试用它创建一个决策树,所以我更新了代码如下:
X=updated[['dayofthemonth','hour']]
y=updated['Encounters']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=80, shuffle=True)
gpc = RandomForestRegressor(random_state=0).fit(X_train, y_train)
pre=gpc.predict(X_test)
gpc.score(X_test, y_test)
pre
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, y)
但仍然出现以下错误:
ValueError: Unknown label type: 'continuous'
【问题讨论】:
标签: python scikit-learn random-forest decision-tree