为这个新手问题道歉。DecisionTreeRegressor
我有一个带有多变量输出的 scikit learn 。如果输出格式为 [ output_var1, output_var2 ],其中每个变量都是连续数字而不是整数,为什么结果是 [1, 1] 而不是 [1.5, 1.5] ?在这个模型中需要改变什么才能得到 [1.5, 1.5] ?
from sklearn.tree import DecisionTreeRegressor
X = [ [1,1], [2,2], [3,3] ]
y = [ [1,1], [2,2], [3,3] ]
print('X:' , X)
print('-----------------------------')
print('y:' , y)
print('-----------------------------')
regr = DecisionTreeRegressor()
regr.fit(X, y)
X_test = [ [1.5, 1.5] ]
print('X_test:' , X_test)
print('-----------------------------')
y_result = regr.predict(X_test)
print('y_result:' , y_result )
结果:
X: [[1, 1], [2, 2], [3, 3]]
-----------------------------
y: [[1, 1], [2, 2], [3, 3]]
-----------------------------
X_test: [[1.5, 1.5]]
-----------------------------
y_result: [[1. 1.]]