/** * Compare index-aligned elements against another * {@link DoubleIndexedContainer}. */ protected boolean equalElements(DoubleArrayList other) { int max = size(); if (other.size() != max) { return false; } for (int i = 0; i < max; i++) { if (!(Double.doubleToLongBits(other.get(i)) == Double.doubleToLongBits( get(i)))) { return false; } } return true; }
/** * Returns the index'th feature weight. * @param index the index of the feature weight to return. * @return the index'th feature weight. */ public double getWeight(int index) { return b_weight ? d_weights.get(index) : 1d; }
/** * Returns the index'th feature weight. * @param index the index of the feature weight to return. * @return the index'th feature weight. */ public double getWeight(int index) { return d_weights.get(index); }
/** * Returns the index'th feature weight. * @param index the index of the feature weight to return. * @return the index'th feature weight. */ public double getWeight(int index) { return b_weight ? d_weights.get(index) : 1d; }
private double getUpdate(int y, int x) { return d_alpha / (d_rho + Math.sqrt(d_gs.get(x).get(y))); } }
private void add(DoubleArrayList list, int index, double value) { list.set(index, list.get(index) + value); }
public void addFeatures(StringFeatureVector vector) { List<String> types = vector.s_types; List<String> values = vector.s_values; DoubleArrayList weights = vector.d_weights; int i, size = vector.size(); for (i=0; i<size; i++) { s_types .add(types .get(i)); s_values.add(values.get(i)); if (weights != null) d_weights.add(weights.get(i)); } }
public String toString() { StringBuilder build = new StringBuilder(); int i, size = s_types.size(); for (i=0; i<size; i++) { build.append(AbstractTrainSpace.DELIM_COL); build.append(s_types.get(i)); build.append(DELIM); build.append(s_values.get(i)); if (b_weight) { build.append(DELIM); build.append(d_weights.get(i)); } } return build.toString().substring(AbstractTrainSpace.DELIM_COL.length()); } }
public String toString() { StringBuilder build = new StringBuilder(); int i, size = s_types.size(); for (i=0; i<size; i++) { build.append(AbstractTrainSpace.DELIM_COL); build.append(s_types.get(i)); build.append(DELIM); build.append(s_values.get(i)); if (b_weight) { build.append(DELIM); build.append(d_weights.get(i)); } } return build.toString().substring(AbstractTrainSpace.DELIM_COL.length()); } }
public String toString() { StringBuilder build = new StringBuilder(); int i, size = s_types.size(); for (i=0; i<size; i++) { build.append(AbstractTrainSpace.DELIM_COL); build.append(s_types.get(i)); build.append(DELIM); build.append(s_values.get(i)); if (b_weight) { build.append(DELIM); build.append(d_weights.get(i)); } } return build.toString().substring(AbstractTrainSpace.DELIM_COL.length()); } }
public void addFeatures(StringFeatureVector vector) { List<String> types = vector.s_types; List<String> values = vector.s_values; DoubleArrayList weights = vector.d_weights; int i, size = vector.size(); for (i=0; i<size; i++) { s_types .add(types .get(i)); s_values.add(values.get(i)); if (weights != null) d_weights.add(weights.get(i)); } }
/** * Compare index-aligned elements against another * {@link DoubleIndexedContainer}. */ protected boolean equalElements(DoubleArrayList other) { int max = size(); if (other.size() != max) { return false; } for (int i = 0; i < max; i++) { if (!(Double.doubleToLongBits(other.get(i)) == Double.doubleToLongBits( get(i)))) { return false; } } return true; }
public void addFeatures(StringFeatureVector vector) { List<String> types = vector.s_types; List<String> values = vector.s_values; DoubleArrayList weights = vector.d_weights; int i, size = vector.size(); for (i=0; i<size; i++) { s_types .add(types .get(i)); s_values.add(values.get(i)); if (weights != null) d_weights.add(weights.get(i)); } }
public String toString() { StringBuilder build = new StringBuilder(); int i, size = i_indices.size(); for (i=0; i<size; i++) { build.append(AbstractTrainSpace.DELIM_COL); build.append(i_indices.get(i)); if (b_weight) { build.append(DELIM); build.append(d_weights.get(i)); } } return build.toString().substring(AbstractTrainSpace.DELIM_COL.length()); } }
public String toString() { StringBuilder build = new StringBuilder(); int i, size = i_indices.size(); for (i=0; i<size; i++) { build.append(AbstractTrainSpace.DELIM_COL); build.append(i_indices.get(i)); if (b_weight) { build.append(DELIM); build.append(d_weights.get(i)); } } return build.toString().substring(AbstractTrainSpace.DELIM_COL.length()); } }
public String toString() { StringBuilder build = new StringBuilder(); int i, size = i_indices.size(); for (i=0; i<size; i++) { build.append(AbstractTrainSpace.DELIM_COL); build.append(i_indices.get(i)); if (b_weight) { build.append(DELIM); build.append(d_weights.get(i)); } } return build.toString().substring(AbstractTrainSpace.DELIM_COL.length()); } }
public double getSumOfSquaredWeights() { int size = i_indices.size(); if (b_weight) { double sum = 0; int i; for (i=0; i<size; i++) sum += UTMath.sq(d_weights.get(i)); return sum; } else return size; }
public double getSumOfSquaredWeights() { int size = i_indices.size(); if (b_weight) { double sum = 0; int i; for (i=0; i<size; i++) sum += UTMath.sq(d_weights.get(i)); return sum; } else return size; }
@Override public double[] getScores(SparseFeatureVector x) { double[] scores = d_weights.get(0).toArray(); int i, index, label, size = x.size(); DoubleArrayList weight; double value = 1; // features for (i=0; i<size; i++) { index = x.getIndex(i); if (x.hasWeight()) value = x.getWeight(i); if (isRange(index)) { weight = d_weights.get(index); for (label=0; label<n_labels; label++) { if (x.hasWeight()) scores[label] += weight.get(label) * value; else scores[label] += weight.get(label); } } } return scores; }
@Override public BytesRef binaryValue() { CollectionUtils.sortAndDedup(values); final byte[] bytes = new byte[values.size() * 8]; for (int i = 0; i < values.size(); ++i) { ByteUtils.writeDoubleLE(values.get(i), bytes, i * 8); } return new BytesRef(bytes); }