@Override public IntFV getFeatureVector() { return new IntFV(new int[] { id }); }
/** * Convert the FV to a DoubleFV representation * @return the DoubleFV representation */ @Override public DoubleFV asDoubleFV() { return new DoubleFV(asDoubleVector()); }
@Override public MultidimensionalIntFV clone() { MultidimensionalIntFV model = (MultidimensionalIntFV) super.clone(); model.nbins = nbins.clone(); return model; }
/** * Convert the FV to a DoubleFV representation * @return the DoubleFV representation */ @Override public DoubleFV asDoubleFV() { return new DoubleFV(asDoubleVector()); }
@Override public MultidimensionalIntFV clone() { MultidimensionalIntFV model = (MultidimensionalIntFV) super.clone(); model.nbins = nbins.clone(); return model; }
/** * Normalise the FV to unit area. * * @return feature vector with all elements summing to 1. */ @Override public DoubleFV normaliseFV() { double [] dvals = asDoubleVector(); double sum = 0; for (int i=0; i<dvals.length; i++) sum += dvals[i]; for (int i=0; i<dvals.length; i++) dvals[i] /= sum; return new DoubleFV(dvals); }
@Override public IntFV getFeatureVector() { return new IntFV(new int[] { id }); }
/** * Normalise the FV to unit area. * * @return feature vector with all elements summing to 1. */ @Override public DoubleFV normaliseFV() { double [] dvals = asDoubleVector(); double sum = 0; for (int i=0; i<dvals.length; i++) sum += dvals[i]; for (int i=0; i<dvals.length; i++) dvals[i] /= sum; return new DoubleFV(dvals); }
@Override public IntFV subvector(int beginIndex) { return new IntFV(Arrays.copyOfRange(this.values, beginIndex, values.length)); }
/** * Lp Norm of the FV. * * @param * p the norm to compute * * @return feature vector normalised using the Lp norm */ @Override public DoubleFV normaliseFV(double p) { double [] dvals = asDoubleVector(); double pnorm = 0; for (int i=0; i<dvals.length; i++) pnorm += Math.pow(Math.abs(dvals[i]), p); pnorm = Math.pow(pnorm, 1.0 / p); for (int i=0; i<dvals.length; i++) dvals[i] /= pnorm; return new DoubleFV(dvals); }
@Override public IntFV subvector(int beginIndex) { return new IntFV(Arrays.copyOfRange(this.values, beginIndex, values.length)); }
/** * Element-wise normalisation to 0..1 using separated expected * minimum and maximum values for each element of the underlying * feature vector. * * @param min an array containing the minimum expected values * @param max an array containing the maximum expected values * @return feature vector with each value normalised to 0..1 */ @Override public DoubleFV normaliseFV(double [] min, double [] max) { double [] dvals = asDoubleVector(); for (int i=0; i<dvals.length; i++) { dvals[i] -= min[i]; dvals[i] /= (max[i]-min[i]); if (dvals[i]<0) dvals[i] = 0; if (dvals[i]>1) dvals[i] = 1; } return new DoubleFV(dvals); }
@Override public IntFV subvector(int beginIndex, int endIndex) { return new IntFV(Arrays.copyOfRange(this.values, beginIndex, endIndex)); }
/** * Min-Max normalisation of the FV. Each element of the underlying * feature vector is normalised to 0..1 based on the provided * minimum and maximum expected values. * * @param min the minimum expected value * @param max the maximum expected value * @return feature vector with each value normalised to 0..1 */ @Override public DoubleFV normaliseFV(double min, double max) { double [] dvals = asDoubleVector(); for (int i=0; i<dvals.length; i++) { dvals[i] -= min; dvals[i] /= (max-min); if (dvals[i]<0) dvals[i] = 0; if (dvals[i]>1) dvals[i] = 1; } return new DoubleFV(dvals); }
@Override public IntFV subvector(int beginIndex, int endIndex) { return new IntFV(Arrays.copyOfRange(this.values, beginIndex, endIndex)); }
/** * Lp Norm of the FV. * * @param * p the norm to compute * * @return feature vector normalised using the Lp norm */ @Override public DoubleFV normaliseFV(double p) { double [] dvals = asDoubleVector(); double pnorm = 0; for (int i=0; i<dvals.length; i++) pnorm += Math.pow(Math.abs(dvals[i]), p); pnorm = Math.pow(pnorm, 1.0 / p); for (int i=0; i<dvals.length; i++) dvals[i] /= pnorm; return new DoubleFV(dvals); }
@Override public IntFV concatenate(IntFV... ins) { int l = values.length; for (int i=0; i<ins.length; i++) l += ins[i].values.length; int[] data = new int[l]; System.arraycopy(values, 0, data, 0, values.length); int offset = values.length; for (int i=0; i<ins.length; i++) { System.arraycopy(ins[i].values, 0, data, offset, ins[i].values.length); offset += ins[i].values.length; } return new IntFV(data); }
/** * Element-wise normalisation to 0..1 using separated expected * minimum and maximum values for each element of the underlying * feature vector. * * @param min an array containing the minimum expected values * @param max an array containing the maximum expected values * @return feature vector with each value normalised to 0..1 */ @Override public DoubleFV normaliseFV(double [] min, double [] max) { double [] dvals = asDoubleVector(); for (int i=0; i<dvals.length; i++) { dvals[i] -= min[i]; dvals[i] /= (max[i]-min[i]); if (dvals[i]<0) dvals[i] = 0; if (dvals[i]>1) dvals[i] = 1; } return new DoubleFV(dvals); }