/** * Convert the FV to a DoubleFV representation * @return the DoubleFV representation */ @Override public DoubleFV asDoubleFV() { return new DoubleFV(asDoubleVector()); }
/** * Convert the FV to a DoubleFV representation * @return the DoubleFV representation */ @Override public DoubleFV asDoubleFV() { return new DoubleFV(asDoubleVector()); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }