本文整理匯總了Java中weka.filters.Filter.setInputFormat方法的典型用法代碼示例。如果您正苦於以下問題:Java Filter.setInputFormat方法的具體用法?Java Filter.setInputFormat怎麽用?Java Filter.setInputFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.filters.Filter
的用法示例。
在下文中一共展示了Filter.setInputFormat方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: predictInstanceDistribution
import weka.filters.Filter; //導入方法依賴的package包/類
public double[] predictInstanceDistribution(Reader reader) throws Exception {
// assume that the file contains only 1 instance
// load instances
Instances data = new Instances(reader);
// remove reportID attribute
String[] options = weka.core.Utils.splitOptions("-R 1"); // removes the first attribute in instances (should be the document id?)
String filterName = "weka.filters.unsupervised.attribute.Remove";
Filter filter = (Filter) Class.forName(filterName).newInstance();
if (filter instanceof OptionHandler) {
((OptionHandler) filter).setOptions(options);
}
filter.setInputFormat(data);
// make the instances
Instances unlabeled = Filter.useFilter(data, filter);
double[][] dist = this.predictDataDistribution(unlabeled);
return dist[0];
}
示例2: trainModelFromFile
import weka.filters.Filter; //導入方法依賴的package包/類
public void trainModelFromFile(String fnTrainData) throws Exception {
// load instances
Instances data = new Instances(new BufferedReader(new FileReader(fnTrainData)));
// preprocess instances
String[] options = weka.core.Utils.splitOptions("-R 1");
String filterName = "weka.filters.unsupervised.attribute.Remove";
Filter filter = (Filter) Class.forName(filterName).newInstance();
if (filter instanceof OptionHandler) {
((OptionHandler) filter).setOptions(options);
}
filter.setInputFormat(data);
// make the instances
Instances unlabeled = Filter.useFilter(data, filter);
// train model
this.trainModel(unlabeled);
}
示例3: removeAttribute
import weka.filters.Filter; //導入方法依賴的package包/類
public Instances removeAttribute(String attrIndex, Instances data) throws Exception {
String[] options = weka.core.Utils.splitOptions("-R " + attrIndex);
String filterName = "weka.filters.unsupervised.attribute.Remove";
Filter filter = (Filter) Class.forName(filterName).newInstance();
if (filter instanceof OptionHandler) {
((OptionHandler) filter).setOptions(options);
}
filter.setInputFormat(data);
// make the instances
return Filter.useFilter(data, filter);
}
示例4: buildAttributeFilterFor
import weka.filters.Filter; //導入方法依賴的package包/類
private static Filter buildAttributeFilterFor(AttributeFilter attributeFilter, Instances dataSet) throws Exception
{
ASEvaluation evaluator = attributeFilter.getEvalClazz().newInstance();
((OptionHandler) evaluator).setOptions(Utils.splitOptions(attributeFilter.getEvalConfig()));
ASSearch search = attributeFilter.getSearchClazz().newInstance();
((OptionHandler) search).setOptions(Utils.splitOptions(attributeFilter.getSearchConfig()));
Filter filter = new AttributeSelection();
filter.setInputFormat(dataSet);
((AttributeSelection) filter).setEvaluator(evaluator);
((AttributeSelection) filter).setSearch(search);
return filter;
}
示例5: buildInstanceFilterFor
import weka.filters.Filter; //導入方法依賴的package包/類
private static Filter buildInstanceFilterFor(InstanceFilter instanceFilter, Instances dataSet) throws Exception
{
Filter filter = instanceFilter.getClazz().newInstance();
filter.setInputFormat(dataSet);
filter.setOptions(Utils.splitOptions(instanceFilter.getConfig()));
filter.setDebug(true);
return filter;
}