Exemplo n.º 1
0
  @Override
  public SparseVector toSparseVector(StringVector features) {
    SparseVector x = new SparseVector();
    int index;

    if (bias > 0) x.add(new SparseItem(0, bias));

    for (StringItem f : features) {
      index = feature_map.index(f.getType(), f.getValue());
      if (index > 0) x.add(index, f.getWeight());
    }

    x.sort();
    return x;
  }
Exemplo n.º 2
0
 @Override
 public void addFeatures(StringVector features) {
   for (StringItem f : features) feature_map.add(f.getType(), f.getValue());
 }