给定一组规则生成决策树
这几天我一直在思考这个问题,但没有找到最佳解决方案,因此提出这个问题。
假设我们有一组 N 个变量,用户可以组合这些变量来创建规则列表和以下操作,例如:
variables V_1,V_2,V_3
V_1 > 5 -> "Turn left"
V_2 < 6 -> "Turn right"
1 < V_1 < 4 -> "Continue straight"
V_1 = 0 AND V_2 > 6 AND V3 > 5 -> "Go backwards"
default -> "Stay"
变量不一定是整数,并假设规则全部由 AND 列表组成后面跟着一个动作的子句。
我想要做的是建立一个决策树,它允许我快速处理像 (0,7,9) 这样的输入并返回正确的操作。 到目前为止,我唯一的想法是划分变量空间并查看输入状态适合的位置,但这似乎是一个缓慢的解决方案:有人知道可能更快的东西吗?
in the last few days I've been thinking about this problem without finding an optimal solution, hence this question.
Let's say we have a set of N variables, which a user can compose to create a list of rules and the following action, such as:
variables V_1,V_2,V_3
V_1 > 5 -> "Turn left"
V_2 < 6 -> "Turn right"
1 < V_1 < 4 -> "Continue straight"
V_1 = 0 AND V_2 > 6 AND V3 > 5 -> "Go backwards"
default -> "Stay"
Variables won't necessarly be integers, and suppose that the rules are all composed by a list of AND clauses followed by an action.
What i want to do is to build a decision tree that would allow me to fast process an input like (0,7,9) and return the proper action.
As of now, my only idea is to partition the variable space and the see where the input state fits, but it seems a slow soluition : anybody knows something that may be faster?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是什么让它变慢?很多规则?长规则?变量很多?规则处理速度慢?
如果你没有太多
变量规则,我显然会选择哈希表。这是针对您所说的问题的树的示例(不一定是最佳的)。
What makes it slow? Lot of rules? Long rules? Lot of variables? Slow rules processing?
If you have not to many
variablesrules, I would clearly go for a hash table.This is an example of tree (not necessarily optimal) for the problem you stated.