public Map < U , Double > getActiveFeatures ( Tensor featureVector ) { Preconditions . checkArgument ( featureVector . getDimensionSizes ( ) . length == 1 && featureVector . getDimensionSizes ( ) [ 0 ] == getNumberOfFeatures ( ) ) ; Map < U , Double > features = Maps . newHashMap ( ) ; Iterator < KeyValue > keyValueIter = featureVector . keyValueIterator ( ) ; while ( keyValueIter . hasNext ( ) ) { KeyValue featureKeyValue = keyValueIter . next ( ) ; features . put ( featureIndexes . get ( featureKeyValue . getKey ( ) [ 0 ] ) , featureKeyValue . getValue ( ) ) ; } return features ; }
Given a feature vector get the features which were active for it . This method inverts the mapping from feature sets to feature vectors performed by this class .