我想这样修改Weka的J48算法:
我想更改J48算法,以类似于RandomForest算法(负责在节点中找到最佳拆分的代码)来划分数据。
我要做什么?我知道我必须将C45ModelSelection代码的一部分改为RandomForest中的代码:
C45ModelSelection.java
...
// Find "best" attribute to split on.
minResult = 0;
for (i=0;i<data.numAttributes();i++){
if ((i != (data).classIndex()) &&
(currentModel[i].checkModel()))
// Use 1E-3 here to get a closer approximation to the original
// implementation.
if ((currentModel[i].infoGain() >= (averageInfoGain-1E-3)) &&
Utils.gr(currentModel[i].gainRatio(),minResult)){
bestModel = currentModel[i];
minResult = currentModel[i].gainRatio();
}
}..。
发布于 2014-11-25 06:35:25
看起来您希望用RandomForest拆分代码替换拆分代码。此代码似乎存在于RandomTree.java的RandomTree.buildTree函数中
拆分代码看起来与J48代码略有不同,因此您可能需要考虑除了拆分代码之外还需要进行哪些其他更改,才能使功能正常工作,但这将是实现您的目标的一个很好的起点。
希望这能有所帮助!
https://stackoverflow.com/questions/27112580
复制相似问题