ML之DT:基于简单回归问题训练决策树(DIY数据集+三种深度的二元DT性能比较)

ML之DT:基于简单回归问题训练决策树(DIY数据集+三种深度的二元DT性能比较)


输出结果

设计思路

核心代码

for i in range(1, len(xPlot)):
    lhList = list(xPlot[0:i])
    rhList = list(xPlot[i:len(xPlot)])

    lhAvg = sum(lhList) / len(lhList)
    rhAvg = sum(rhList) / len(rhList)

    lhSse = sum([(s - lhAvg) * (s - lhAvg) for s in lhList])
    rhSse = sum([(s - rhAvg) * (s - rhAvg) for s in rhList])

    sse.append(lhSse + rhSse)
    xMin.append(max(lhList))
(0)

相关推荐