Weka中的有監督的離散化方法
阿新 • • 發佈:2018-12-22
對應分析Weka中weka.filters.supervised.attribute.Discretize
涉及的其他類包括weka.filters.Filter
分析的巨集觀程式碼
Discretize disc=new Discretize()
disc.setInputFormat(data)
Instances afterDiscretize=Filter.useFilter(data,disc)
Filter.useFilter()
Filter.useFilter(Instances data, Filter filter){
for (int i = 0; i < data.numInstances(); i++) {
filter .input(data.instance(i));
//進一步呼叫bufferInput():把instance複製一份後交給Filter的m_InputFormat變數,這相當於輸入資料的一個完整copy
//
}
filter.batchFinished();//呼叫離散化計算的主體部分calculateCutPoints()詳細分析見下文
Instances newData = filter.getOutputFormat();
Instance processed;
while ((processed = filter.output()) != null) {
newData.add(processed);
}
}
return newData
Discretize.calculateCutPoints()
calculateCutPoints(){
m_CutPoints = new double[getInputFormat().numAttributes()][];
calculateCutPointsByMDL(i, copy);//對第i個屬性進行離散化
}