BDT可以做广场吗?

问题描述 投票:0回答:1

我试图将背景与信号分开,其中已知数量x^2 - y^2是背景和信号不同的物理原因。如果我提供x和y作为输入变量,BDT很难弄清楚如何实现分离。 BDT无法做广场吗?

machine-learning neural-network physics decision-tree nonlinear-functions
1个回答
0
投票

不,二元决策树无法获取输入要素的平方。给定输入特征x,y,它将尝试通过沿垂直和水平线细分x,y平面来近似所需的函数。让我们看一个例子:我将决策树分类器拟合到方形网格点,并绘制决策边界。

from sklearn.tree import DecisionTreeClassifier
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-5.5, 5.5, 1)
y = np.arange(-5.0, 6.0, 1)
xx, yy = np.meshgrid(x,y)
#the function we want to learn:
target = xx.ravel()**2 - yy.ravel()**2 > 0
data = np.c_[xx.ravel(), yy.ravel()]
#Fit a decision tree:
clf = DecisionTreeClassifier()
clf.fit(data, target)

#Plot the decision boundary:
xxplot, yyplot = np.meshgrid(np.arange(-7, 7, 0.1),
                     np.arange(-7, 7, 0.1))

Z = clf.predict(np.c_[xxplot.ravel(), yyplot.ravel()]) 

# Put the result into a color plot
Z = Z.reshape(xxplot.shape)
plt.contourf(xxplot, yyplot, Z, cmap=plt.cm.hot)

# Plot also the training points
plt.scatter(xx.ravel(), yy.ravel(), c=target, cmap=plt.cm.flag)
plt.xlabel("x")
plt.ylabel("y")
plt.title("Decision boundary for a binary decision tree learning a function x**2 - y**2 > 0")
plt.show()

enter image description here

在这里,您可以看到决策树可以学习的边界类型:分段矩形。他们不会很好地接近你的功能,特别是在训练点很少的地方。由于您知道x ^ 2 - y ^ 2是确定答案的数量,因此您可以将其添加为新功能,而不是尝试学习它。

© www.soinside.com 2019 - 2024. All rights reserved.