如何设计一棵树问问题以做出决定?

时间:2019-06-13 06:37:28

标签: python machine-learning tree data-science decision-tree

我正在尝试编写一个程序,该程序将询问一系列问题,以便最终返回建议。我该怎么办?

我尝试使用树,但无法正确完成。

例如,这可以是一系列:

Q : Is the care damaged fully?
A : No

Q : How bad is the damage? [Totaled | Average | Light]
A : Average

Q : Is it able to start?
A : No

Q : Is it towable?
A : Y 

.
.
.
.

Okay, recommended service plan : [name of package]

1 个答案:

答案 0 :(得分:0)

这似乎是作业或作业的编码问题,所以我将不提供编码解决方案。您可以尝试if else个条件来实现这一点。使用嵌套的if条件应该非常简单。您也可以为此使用switch case

如果您将数据保存在csv或文本文件中,并且被允许使用ML库,则可以训练模型并以代码形式从中提取树规则。