本文整理汇总了Java中weka.core.DenseInstance.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java DenseInstance.setValue方法的具体用法?Java DenseInstance.setValue怎么用?Java DenseInstance.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.DenseInstance
的用法示例。
在下文中一共展示了DenseInstance.setValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createArff
import weka.core.DenseInstance; //导入方法依赖的package包/类
public Instances createArff(String comment) {
ArrayList<Attribute> atts = new ArrayList<Attribute>();
ArrayList<String> classes = new ArrayList<String>();
classes.add("good");
classes.add("bad");
atts.add(new Attribute("text", (ArrayList<String>) null));
// make sure that the name of the class attribute is unlikely to
// clash with any attribute created via the StringToWordVector filter
atts.add(new Attribute("@@[email protected]@", classes));
Instances data = new Instances("weka_SO_comments_model", atts, 0);
data.setClassIndex(data.numAttributes() - 1);
DenseInstance instance = new DenseInstance(2);
Attribute messageAtt = data.attribute("text");
instance.setValue(messageAtt, messageAtt.addStringValue(comment));
data.add(instance);
// System.out.println(data.toString());
return data;
}
示例2: featureVectorToInstances
import weka.core.DenseInstance; //导入方法依赖的package包/类
/**
* Method to get a Instances object from a featureVector
* @param featureVector the featureVector to convert in Instances
* @return an Instances object (in other words a set of Instance)
*/
public Instances featureVectorToInstances(ArrayList<Double> featureVector) {
Instances instances = new Instances("Instances", attributes, 0);
DenseInstance instance = new DenseInstance(attributes.size());
for (int i = 0; i < featureVector.size(); i++)
instance.setValue(i, featureVector.get(i));
// instance.setValue(featureVector.size(), -1);
instances.add(instance);
// Set class attribute
instances.setClassIndex(attributes.size() - 1);
return instances;
}
示例3: featureMatrixToInstances
import weka.core.DenseInstance; //导入方法依赖的package包/类
/**
* Method to get a Instances object from a featureMatrix
* @param featureMatrix the featureMatrix to convert in Instances
* @return an Instances object (in other words a set of Instance)
*/
public Instances featureMatrixToInstances(
ArrayList<ArrayList<Double>> featureMatrix) {
Instances instances = new Instances("Instances", attributes, 0);
DenseInstance instance = new DenseInstance(attributes.size());
for (int i = 0; i < featureMatrix.size(); i++) {
for (int j = 0; j < featureMatrix.size(); j++) {
instance.setValue(j, featureMatrix.get(i).get(j));
}
// instance.setValue(featureVector.size(), -1);
instances.add(instance);
// Set class attribute
instances.setClassIndex(attributes.size() - 1);
}
return instances;
}
示例4: toWekaInstance
import weka.core.DenseInstance; //导入方法依赖的package包/类
/**
* toWekaInstance
*
* @param dataset
* @return
*/
public Instance toWekaInstance(Instances dataset) {
// create instance
DenseInstance instance = new DenseInstance(13);
instance.setDataset(dataset);
// set values
instance.setValue(0, this.getMean());
instance.setValue(1, this.getMedian());
instance.setValue(2, this.getMin());
instance.setValue(3, this.getMax());
instance.setValue(4, this.getStd());
instance.setValue(5, this.getLowQuantile());
instance.setValue(6, this.getHighQuantile());
instance.setValue(7, this.getIqr());
instance.setValue(8, this.getKurtosis());
instance.setValue(9, this.getRange());
instance.setValue(10, this.getPower());
instance.setValue(11, this.getTotalF0());
instance.setValue(12, stressed ? "stressed" : "unstressed");
// return instance
return instance;
}
示例5: makeInstance
import weka.core.DenseInstance; //导入方法依赖的package包/类
/**
* Method that converts a text message into an instance.
*/
private static Instance makeInstance(String text, Instances data) {
// Create instance of length two.
DenseInstance instance = new DenseInstance(2);
// Set value for message attribute
Attribute messageAtt = data.attribute("text");
instance.setValue(messageAtt, messageAtt.addStringValue(text));
// Give instance access to attribute information from the dataset.
instance.setDataset(data);
return instance;
}