/** * SetValues - set the attribute values in Instsance x (having L labels) to z[]. * TODO: call above method */ public static final Instance setValues(Instance x, double z[], int L) { for(int a = 0; a < z.length; a++) { x.setValue(L+a,z[a]); } return x; }
public void updateTransform(Instance t_, double ypred[]) throws Exception { for(int pa : this.paY) { t_.setValue(this.map[pa],ypred[pa]); } }
// Create empty instance with three attribute values Instance inst = new DenseInstance(3); // Set instance's values for the attributes "length", "weight", and "position" inst.setValue(length, 5.3); inst.setValue(weight, 300); inst.setValue(position, "first"); // Set instance's dataset to be the dataset "race" inst.setDataset(race);
@Override protected void updateWeights(ProblemTransformationMethod h, Instances D) throws Exception { for(Instance x : D) { double y[] = h.distributionForInstance(x); for(int j = 0; j < y.length; j++) { x.setValue(j,(y[j] < 0.5) ? 0. : 1.); } } }
/** * CopyValues - Set x_dest[i++] = x_src[j] for all j in indices[]. */ public static final Instance copyValues(Instance x_dest, Instance x_src, int indices[]) { int i = 0; for(int j : indices) { x_dest.setValue(i++,x_src.value(j)); } return x_dest; }
/** Clear Labels -- set the value of all label attributes to 0.0 */ public static void clearLabels(Instance x) { int L = x.classIndex(); for(int j = 0; j < L; j++) x.setValue(j,0.0); }
/** * CopyValues - Set x_dest[i++] = x_src[j] for all j in indices[]. */ public static final Instance copyValues(Instance x_dest, Instance x_src, int indices[]) { int i = 0; for(int j : indices) { x_dest.setValue(i++,x_src.value(j)); } return x_dest; }
public static void clearLabels(Instance x) { int L = x.classIndex(); for(int j = 0; j < L; j++) x.setValue(j,0.0); }
/** * SetPath - set 'path[]' into the first L attributes of Instance 'xy'. * @param xy an Example (x,y) * @param path a label vector */ public static void setPath(Instance xy, double path[]) { int L = xy.classIndex(); // = path.length for(int j = 0; j < L; j++) { xy.setValue(j,(int)Math.round(path[j])); // x = x + path_j } }
@Override protected void updateWeights(ProblemTransformationMethod h, Instances D) throws Exception { for(Instance x : D) { double y[] = h.distributionForInstance(x); for(int j = 0; j < y.length; j++) { x.setValue(j,(y[j] < 0.5) ? 0. : 1.); } } }
/** * SetPath - set 'path[]' into the first L attributes of Instance 'xy'. * @param xy an Example (x,y) * @param path a label vector */ public static void setPath(Instance xy, double path[]) { int L = xy.classIndex(); // = path.length for(int j = 0; j < L; j++) { xy.setValue(j,(int)Math.round(path[j])); // x = x + path_j } }
/** * SetPath - set 'path[]' into the first L attributos of Instance 'xy'. * @param xy an Instance * @param path a label vector */ public static void setPath(Instance xy, double path[]) { int L = xy.classIndex(); // = path.length for(int j = 0; j < L; j++) { xy.setValue(j,(int)Math.round(path[j])); // x = x + path_j } }
public static final Instance copyValues(Instance x_dest, Instance x_src, int from, int offset) { int d = x_src.numAttributes(); for(int i = from, j = 0; i < d; i++, j++) { x_dest.setValue(j+offset,x_src.value(i)); } return x_dest; }
/** * CopyValues - Set x_dest[j+offset] = x_src[i+from]. */ public static final Instance copyValues(Instance x_dest, Instance x_src, int from, int offset) { int d = x_src.numAttributes(); for(int i = from, j = 0; i < d; i++, j++) { x_dest.setValue(j+offset,x_src.value(i)); } return x_dest; }
@Override public Instance extract(Edit edit) { Instance instance = newDenseInstance(); instance.setValue(attribute(0), edit.getTags().contains("vandalism")? "yes" : "no"); return instance; }
@Override public Instance extract(Edit edit) { Instance instance = newDenseInstance(); instance.setValue(attribute(0), edit.getOldRevision().getText().length() - edit.getNewRevision().getText().length() ); return instance; }
@Override public Instance extract(Edit edit) { Instance instance = newDenseInstance(); instance.setValue(attribute(0), edit.getOldRevision().getTokens().size() - edit.getNewRevision().getTokens().size() ); return instance; }
@Override public Instance extract(Edit edit) { Instance instance = newDenseInstance(); instance.setValue(attribute(0), (edit.getOldRevision().getTokens().size() + 1f) / (edit.getNewRevision().getTokens().size() + 1f) ); return instance; }
private Instance createInstance(Instances data, FeatureDefinition fd, FeatureVector fv) { // relevant features + one target Instance currInst = new DenseInstance(data.numAttributes()); currInst.setDataset(data); // read only relevant features for (String attName : this.featureNames) { int featNr = fd.getFeatureIndex(attName); String value = fv.getFeatureAsString(featNr, fd); currInst.setValue(data.attribute(attName), value); } return currInst; }