首页 > 解决方案 > Python中的决策树桩

问题描述

我正在尝试将 Matlab 代码传输到 Python,并得到完全相同的结果。在 Matlab 代码中,我有一个决策树桩,如下所示:

switch Model
    case 'DecisionStump'

        Weights = Pt; % Train the weak learner by weights Pt

        tree = fitctree(X,Y,'minparent',size(X,1)-sum(Weights==0),'prune','off','mergeleaves','off','Weights', Weights, 'CategoricalPredictors', CategoricalPredictors);

        h = compact(tree);

我使用下面的 python 代码来构建完全相同的决策树桩:

clf_tree = DecisionTreeClassifier(max_depth = 1)

但是,这两个程序得到的结果略有不同,如果我错过任何事情,如果有人能帮助我,那就太好了。(也许分类预测器应该包含在我的 python 代码中,但我不知道如何!)

标签: pythonmatlabscikit-learndecision-tree

解决方案


推荐阅读