本文整理了Java中weka.filters.unsupervised.attribute.Add.setAttributeType()
方法的一些代码示例,展示了Add.setAttributeType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Add.setAttributeType()
方法的具体详情如下:
包路径:weka.filters.unsupervised.attribute.Add
类名称:Add
方法名:setAttributeType
[英]Sets the type of attribute to generate.
[中]设置要生成的属性的类型。
代码示例来源:origin: org.dkpro.tc/dkpro-tc-ml-weka
public Instances getPredictionInstancesSingleLabel(Instances testData, Classifier cl)
throws Exception
{
StringBuffer classVals = new StringBuffer();
for (int i = 0; i < testData.classAttribute().numValues(); i++) {
if (classVals.length() > 0) {
classVals.append(",");
}
classVals.append(testData.classAttribute().value(i));
}
// get predictions
List<Double> labelPredictionList = new ArrayList<Double>();
for (int i = 0; i < testData.size(); i++) {
labelPredictionList.add(cl.classifyInstance(testData.instance(i)));
}
// add an attribute with the predicted values at the end off the attributes
Add filter = new Add();
filter.setAttributeName(WekaTestTask.PREDICTION_CLASS_LABEL_NAME);
if (classVals.length() > 0) {
filter.setAttributeType(new SelectedTag(Attribute.NOMINAL, Add.TAGS_TYPE));
filter.setNominalLabels(classVals.toString());
}
filter.setInputFormat(testData);
testData = Filter.useFilter(testData, filter);
// fill predicted values for each instance
for (int i = 0; i < labelPredictionList.size(); i++) {
testData.instance(i).setValue(testData.classIndex() + 1, labelPredictionList.get(i));
}
return testData;
}
代码示例来源:origin: dkpro/dkpro-tc
public Instances getPredictionInstancesSingleLabel(Instances testData, Classifier cl)
throws Exception
{
StringBuffer classVals = new StringBuffer();
for (int i = 0; i < testData.classAttribute().numValues(); i++) {
if (classVals.length() > 0) {
classVals.append(",");
}
classVals.append(testData.classAttribute().value(i));
}
// get predictions
List<Double> labelPredictionList = new ArrayList<Double>();
for (int i = 0; i < testData.size(); i++) {
labelPredictionList.add(cl.classifyInstance(testData.instance(i)));
}
// add an attribute with the predicted values at the end off the attributes
Add filter = new Add();
filter.setAttributeName(WekaTestTask.PREDICTION_CLASS_LABEL_NAME);
if (classVals.length() > 0) {
filter.setAttributeType(new SelectedTag(Attribute.NOMINAL, Add.TAGS_TYPE));
filter.setNominalLabels(classVals.toString());
}
filter.setInputFormat(testData);
testData = Filter.useFilter(testData, filter);
// fill predicted values for each instance
for (int i = 0; i < labelPredictionList.size(); i++) {
testData.instance(i).setValue(testData.classIndex() + 1, labelPredictionList.get(i));
}
return testData;
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.tc/de.tudarmstadt.ukp.dkpro.tc.weka-gpl
filter.setAttributeName(TestTask.PREDICTION_CLASS_LABEL_NAME);
if (classVals.length() > 0) {
filter.setAttributeType(new SelectedTag(Attribute.NOMINAL, Add.TAGS_TYPE));
filter.setNominalLabels(classVals.toString());
代码示例来源:origin: Waikato/weka-trunk
public void testAddDate() {
m_Filter = getFilter();
((Add) m_Filter).setAttributeType(new SelectedTag(Attribute.DATE, Add.TAGS_TYPE));
testBuffered();
testType(Attribute.DATE);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
public void testAddString() {
m_Filter = getFilter();
((Add) m_Filter).setAttributeType(new SelectedTag(Attribute.STRING, Add.TAGS_TYPE));
testBuffered();
testType(Attribute.STRING);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
public void testAddDate() {
m_Filter = getFilter();
((Add) m_Filter).setAttributeType(new SelectedTag(Attribute.DATE, Add.TAGS_TYPE));
testBuffered();
testType(Attribute.DATE);
}
代码示例来源:origin: Waikato/weka-trunk
public void testAddString() {
m_Filter = getFilter();
((Add) m_Filter).setAttributeType(new SelectedTag(Attribute.STRING, Add.TAGS_TYPE));
testBuffered();
testType(Attribute.STRING);
}
代码示例来源:origin: Waikato/weka-trunk
setAttributeType(new SelectedTag(tmpStr, TAGS_TYPE));
} else {
setAttributeType(new SelectedTag(Attribute.NUMERIC, TAGS_TYPE));
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
setAttributeType(new SelectedTag(tmpStr, TAGS_TYPE));
} else {
setAttributeType(new SelectedTag(Attribute.NUMERIC, TAGS_TYPE));
代码示例来源:origin: dkpro/dkpro-tc
add.setAttributeIndex("first");
add.setAttributeType(new SelectedTag(Attribute.STRING, Add.TAGS_TYPE));
add.setInputFormat(newData);
filteredData = Filter.useFilter(newData, add);
代码示例来源:origin: org.dkpro.tc/dkpro-tc-ml-weka
add.setAttributeIndex("first");
add.setAttributeType(new SelectedTag(Attribute.STRING, Add.TAGS_TYPE));
add.setInputFormat(newData);
filteredData = Filter.useFilter(newData, add);
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.tc/de.tudarmstadt.ukp.dkpro.tc.weka-gpl
add.setAttributeIndex("first");
add.setAttributeType(new SelectedTag(Attribute.STRING, Add.TAGS_TYPE));
add.setInputFormat(newData);
filteredData = Filter.useFilter(newData, add);
内容来源于网络,如有侵权,请联系作者删除!