/** * Instantiates a new sparse instance. * * @param weight the weight * @param attributeValues the attribute values * @param indexValues the index values * @param numberAttributes the number attributes */ public FilteredSparseInstance(double weight, double[] attributeValues, int[] indexValues, int numberAttributes) { super(numberAttributes); this.weight = weight; this.instanceData = new FilteredSparseInstanceData(attributeValues, indexValues, numberAttributes); }
/** * Value of the attribute in the indexAttribute position. * If this value is absent, a NaN value (marker of missing value) * is returned, otherwise this method returns the actual value. * * @param indexAttribute the index attribute * @return the double */ @Override public double value(int indexAttribute) { int location = locateIndex(indexAttribute); if ((location >= 0) && (indexValues[location] == indexAttribute)) { return attributeValues[location]; } else { // returns a NaN value which represents missing values instead of a 0 (zero) return Double.NaN; } } }