@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; }