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
精彩评论