簡體   English   中英

weka.attributeSelection.InfoGainAttributeEval太慢。 關於如何加快速度的任何想法?

[英]weka.attributeSelection.InfoGainAttributeEval is too slow. Any ideas on how to speed it up?

我正在開發一個應用程序,該應用程序需要動態地為一組特定的實例動態地對屬性進行排名。 現在,我正在使用信息獲取來對屬性進行排名,但是它有點太慢了。

注意:我使用的數據集大約有50,000個屬性。

我正在運行的代碼

AttributeSelection attsel = new AttributeSelection();
InfoGainAttributeEval eval = new InfoGainAttributeEval();
Ranker search = new Ranker();
attsel.setEvaluator(eval);
attsel.setSearch(search);
double[][] attrRanks = new double[data.numAttributes()][2];
try {
    attsel.SelectAttributes(data);
    attrRanks = attsel.rankedAttributes();
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

事實證明,排名實際上是相當快的,但是創建約30,000-40,000個屬性對象的過程需要一段時間。 我刪除了那部分代碼,它開始正常工作。 新密碼

GainRatioAttributeEval eval = new GainRatioAttributeEval();
try{
    eval.buildEvaluator(data);
} catch(Exception e) {
    LOGGER.error("Couldn't evaluate gain ratio", e);
}
Double infogain = Double.MIN_VALUE;
ObjectNode objNode;
int k, i;
double[][] ig = new double[data.numAttributes()][2];
for(int j=0;j<data.numAttributes();j++){
    try {
        ig[j][0] = j;
        ig[j][1] = eval.evaluateAttribute(j);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        LOGGER.error("Couldn't evaluate gain ratio for empty entrezIds.",e);
    }
}
Arrays.sort(ig, new Comparator<double[]>(){
    @Override
    public int compare(double[] o1, double[] o2) {
        // TODO Auto-generated method stub
          if (o1[1] > o2[1]) {
                return -1;
            } else if (o1[1] < o2[1]) {
                return 1;
            }
                    return 0;
    }
});
//Ig is sorted array.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM