@Override public int size() { return data.size(); }
@Override public int size() { return data.size(); }
public int size() { return data.size(); }
public float getMeanValueB8Band(){ return this.sumValueB8Band/(float)standardDeviationPixelValues.size(); }
public float getMeanValueB4Band(){ return this.sumValueB4Band/(float)standardDeviationPixelValues.size(); }
public float getMeanValueB11Band(){ return this.sumValueB11Band/(float)standardDeviationPixelValues.size(); }
@Override public void write(DataOutput out) throws IOException { out.writeBoolean(isSingleton); if (isSingleton) { out.writeInt(singletonIndex); out.writeFloat(singletonValue); } else { out.writeInt(entries.size()); for (int i = 0; i < entries.size(); ++i) { out.writeFloat(entries.getFloat(i)); } } }
public Features(int numFeatures) { this.values = new FloatArrayList(numFeatures); this.values.size(numFeatures); }
/** * Get a particular entry of the vector. * * @param i the entry * @return the value of the entry. */ public float get(int i) { // The default value is 0.0 if (i >= entries.size()) { return 0.0f; } return entries.getFloat(i); }
public float getMeanStandardDeviationB8Band(){ // compute the standard deviation float averageStandardDeviationB8PixelValue = getMeanValueB8Band(); float sum = 0.0f; for (float pixelValue : standardDeviationPixelValues) { float value = pixelValue - averageStandardDeviationB8PixelValue; sum += Math.pow((value), 2); } float average = sum / (float)standardDeviationPixelValues.size(); return (float)Math.sqrt(average); }
@Override public void writeVectorLine(VectorLine vectorLine) { try { outputStream.writeInt(vectorLine.getSampleId()); outputStream.writeLong(vectorLine.getExampleId()); outputStream.writeInt(vectorLine.getVectorId()); outputStream.writeInt(vectorLine.getVectorElements().size()); for (float vectorElement : vectorLine.getVectorElements()) { outputStream.writeFloat(vectorElement); } } catch (IOException e) { throw new UncheckedIOException("Unable to write bytes for vector line to file", e); } } }
/** * Add the vector specified. This is a vector addition that does an * element-by-element addition. * * @param other the vector to add. */ public void add(FloatDenseVector other) { if (isSingleton) { throw new RuntimeException("Cannot add to singleton vector"); } if (other.isSingleton) { ensureCapacity(other.singletonIndex + 1); entries.set(other.singletonIndex, entries.getFloat(other.singletonIndex) + other.singletonValue); } else { ensureCapacity(other.entries.size()); for (int i = 0; i < other.entries.size(); ++i) { entries.set(i, entries.getFloat(i) + other.entries.getFloat(i)); } } }
public Selection select(FloatPredicate predicate) { Selection bitmap = new BitmapBackedSelection(); for (int idx = 0; idx < data.size(); idx++) { float next = data.getFloat(idx); if (predicate.test(next)) { bitmap.add(idx); } } return bitmap; }
public Selection select(FloatBiPredicate predicate, float value) { Selection bitmap = new BitmapBackedSelection(); for (int idx = 0; idx < data.size(); idx++) { float next = data.getFloat(idx); if (predicate.test(next, value)) { bitmap.add(idx); } } return bitmap; }
public Features(INDArray inputs, int dimension) { final int size = inputs.size(dimension); values=new FloatArrayList(size); values.size(size); int[] indices = {0, 0}; for (int i = 0; i < size; i++) { indices[1] = i; float value = inputs.getFloat(indices); setFeatureValue(value, i); } }
private void execute(){ Spectrum spec; FloatArrayList pixelsValues = new FloatArrayList(); FloatArrayList meanValues = new FloatArrayList(); for (String sourceBand : this.sourceBands) { pixelsValues.clear(); Band band = this.sourceProduct.getBand(sourceBand); for (int intIndex = 0; intIndex < this.spectrumClassReferencePixels.getXPixelPositions().size(); intIndex++) { int x = this.spectrumClassReferencePixels.getXPixelPositions().getInt(intIndex); int y = this.spectrumClassReferencePixels.getYPixelPositions().getInt(intIndex); pixelsValues.add(band.getSampleFloat(x, y)); } double sum = 0; for (float value : pixelsValues) { sum += value; } meanValues.add((float) sum / pixelsValues.size()); } spec = new Spectrum(spectrumClassReferencePixels.getClassName(), meanValues.toFloatArray(new float[meanValues.size()])); this.spectrumContainer.addElements(spec); }
public float estimateCalibratedP(INDArray testFeatures) { assert testFeatures.data().length() == featureMapper.numberOfFeatures() : "number of features does not match predictive model input length."; INDArray inputs = Nd4j.zeros(1, numCalibratingInputFeatures); // INDArray labels = Nd4j.zeros(1, 1); // DataSet dataset = new DataSet(inputs,labels); int indexOfNewRecordInMinibatch = 0; // calculate the model output and use as features for the calibration model: FloatArrayList floats = getModelInternalActivations(testFeatures); assert floats.size() == numCalibratingInputFeatures : "number of features does not match calibrating model input length."; indices[0] = indexOfNewRecordInMinibatch; for (int i = 0; i < numCalibratingInputFeatures; i++) { indices[1] = i; // dataset.getFeatures().putScalar(indices, floats.getFloat(i)); inputs.putScalar(indices, floats.getFloat(i)); } calibratingModel.init(); // System.out.println("size:" + inputs); float[] predicted = calibratingModel.output(inputs, false).getRow(0).data().asFloat(); return predicted[0]; }