2011-03-30 58 views
0

我將以下過濾器應用於我的數據。WEKA:如何從標記的數據中禁用過濾器?

string[] options = new string[2]; 
options[0] = "-R"; 
options[1] = "1-2"; 

Remove remove = new Remove(); // new instance of filter 
remove.setOptions(options); 

remove.setInputFormat(train); 
train = Filter.useFilter(train, remove); 
unlabeled = Filter.useFilter(unlabeled, remove); 

但是我想在最後打印帶標籤的數據時添加刪除的字段。

如何重新添加列?

謝謝

P.S>。還有一個問題,我可以忽略字段而不是刪除它們嗎?

回答

1

假設您想要對數據運行分類並忽略已刪除的屬性,則需要使用帶刪除過濾器的FilteredClassifier

// Untested Java, I use Weka through JRuby 
NaiveBayes naiveBayes = new NaiveBayes(); 
Remove remove = new Remove(); 
remove.setOptions(Utils.splitOptions("-R 1-2")); 
FilteredClassifier model = new FilteredClassifier(naiveBayes, remove); 

// Use model to classify as normal