python - 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 代码中,但我不知道如何!)
解决方案
推荐阅读
- python - 更新 mongoDB 对象中数组的选定元素
- tensorflow - 使用 tflearn,得到 ModuleNotFoundError: No module named 'tensorflow.contrib'
- python - 定义从 Raspberry(使用 4G 调制解调器 [Quectel ec25])到 Linux Socket 服务器的 TCP IP 数据传输协议
- java - 修改.avsc文件后如何生成java类
- arrays - 如何在 Fortran 中设置一个小代码复活节彩蛋 - 随机选择错误消息的引号
- python - 在使用 Sublime Text 时,我遇到了这个错误
- javascript - 使用 jsfuck 约定以流方式调用数组的方法
- django - 我如何覆盖用户保存 Django allauth.socialaccounts
- c++ - opreport 似乎报告了错误的模板实例化
- java - Android 尝试使用资源未找到方法 close()