开发者

WEKA: how to disable the filter from labeled data?

开发者 https://www.devze.com 2023-02-20 14:32 出处:网络
I\'m applying the following filter to my data. string[] options = new string[2]; options[0] = \"-R\"; options[1] = \"1-2\";

I'm applying the following filter to my data.

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, re开发者_Python百科move);  
unlabeled = Filter.useFilter(unlabeled, remove);  

However I would like to add the removed fields when I print the labeled data in the end.

How can I re-add the columns ?

Thanks

P.S>. One more question, can I just ignore fields instead of removing them ?


Assuming that you want to run a classifier on the data and ignore the attributes you've been removing, you want to use a FilteredClassifier with the Remove filter.

// 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
0

精彩评论

暂无评论...
验证码 换一张
取 消