public class ObjectIntMultiVectorCosine extends ObjectIntMultiVector implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
ObjectIntMultiVectorCosine.WeightedCosineDistanceFunction
Class for distance functions that compute distances between two
ObjectIntMultiVector s using weighted Cosine distance. |
ObjectIntMultiVector.ArrayMultiWeightProvider, ObjectIntMultiVector.MapMultiWeightProvider, ObjectIntMultiVector.MultiWeightIgnoreProvider, ObjectIntMultiVector.MultiWeightProvider, ObjectIntMultiVector.SDIteratorIntersectionResult, ObjectIntMultiVector.SortedDataIterator, ObjectIntMultiVector.WeightProvider
LocalAbstractObject.DataEqualObject, LocalAbstractObject.TextStreamFactory<T extends LocalAbstractObject>, LocalAbstractObject.TrivialDistanceFunction
data
counterDistanceComputations, counterLowerBoundDistanceComputations, counterPrecomputedDistanceSavings, counterUpperBoundDistanceComputations, MAX_DISTANCE, MIN_DISTANCE, suppData, trivialDistanceFunction, UNKNOWN_DISTANCE
Constructor and Description |
---|
ObjectIntMultiVectorCosine(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of ObjectIntMultiVectorCosine loaded from binary input buffer.
|
ObjectIntMultiVectorCosine(java.io.BufferedReader stream)
Creates a new instance of ObjectIntMultiVectorCosine from stream - it expects that the data is already sorted!
|
ObjectIntMultiVectorCosine(java.io.BufferedReader stream,
int arrays)
Creates a new instance of ObjectIntMultiVectorCosine from stream - it expects that the data is already sorted!
|
ObjectIntMultiVectorCosine(int[]... data)
Creates a new instance of ObjectIntMultiVectorCosine.
|
ObjectIntMultiVectorCosine(int[][] data,
boolean forceSort)
Creates a new instance of ObjectIntMultiVectorCosine.
|
ObjectIntMultiVectorCosine(int arrays,
int dimension)
Creates a new instance of randomly generated ObjectIntMultiVectorCosine.
|
Modifier and Type | Method and Description |
---|---|
protected float |
getDistanceImpl(LocalAbstractObject obj,
float distThreshold)
Implements the Cosine distance function.
|
static float |
getWeightedCosineDistance(ObjectIntMultiVector o1,
ObjectIntMultiVector.WeightProvider weightProviderO1,
ObjectIntMultiVector o2,
ObjectIntMultiVector.WeightProvider weightProviderO2)
Computes a distance between two
ObjectIntMultiVector s using
a metric weighted cosine distance. |
binarySerialize, cloneRandomlyModify, dataEquals, dataHashCode, getBinarySize, getDimensionality, getSize, getSortedIterator, getVectorData, getVectorData, getVectorDataCount, getVectorDataItem, getVectorDataItemCount, sortData, toString, writeData
clearSurplusData, clone, clone, create, create, createMetaDistancesHolder, excludeUsingPrecompDist, getDistance, getDistance, getDistance, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceFilter, getDistanceLowerBound, getDistanceLowerBoundImpl, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceStorePrecomputed, getDistanceUpperBound, getDistanceUpperBoundImpl, getFieldsForNames, getMaxDistance, getNormDistance, getPrecomputedDistance, getPrecomputedDistance, getRandomChar, getRandomNormal, chainDestroy, chainFilter, includeUsingPrecompDist, isDistanceCompatible, parseObjectComment, peekNextChar, readAttributesFromStream, readObjectComments, readObjectCommentsWithoutData, unchainFilter, write, write, writeAttributesToStream, writeObjectComment
clone, getLocatorURI, getNoDataObject, getObjectKey, getObjectKey, getObjectLocatorURI, setObjectKey
public ObjectIntMultiVectorCosine(int[][] data, boolean forceSort)
forceSort
is false, the provided data are expected to be sorted!data
- the data content of the new objectforceSort
- if false, the data is expected to be sortedpublic ObjectIntMultiVectorCosine(int[]... data)
data
- the data content of the new objectpublic ObjectIntMultiVectorCosine(int arrays, int dimension)
arrays
- the number of vector data arrays to createdimension
- number of dimensions to generatepublic ObjectIntMultiVectorCosine(java.io.BufferedReader stream, int arrays) throws java.io.IOException, java.lang.NumberFormatException
stream
- text stream to read the data fromarrays
- number of arrays to read from the streamjava.io.IOException
- when an error appears during reading from given stream.
or EOFException when end-of-file of the given stream is reached.java.lang.NumberFormatException
- when the line read from given stream does
not consist of comma-separated or space-separated numbers.public ObjectIntMultiVectorCosine(java.io.BufferedReader stream) throws java.io.IOException, java.lang.NumberFormatException
stream
- text stream to read the data fromjava.io.IOException
- when an error appears during reading from given stream.
or EOFException when end-of-file of the given stream is reached.java.lang.NumberFormatException
- when the line read from given stream does
not consist of comma-separated or space-separated numbers.public ObjectIntMultiVectorCosine(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the buffer to read the ObjectIntVector fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the bufferprotected float getDistanceImpl(LocalAbstractObject obj, float distThreshold)
getDistanceImpl
in class LocalAbstractObject
obj
- the object to compute distance todistThreshold
- the threshold value on the distancepublic static float getWeightedCosineDistance(ObjectIntMultiVector o1, ObjectIntMultiVector.WeightProvider weightProviderO1, ObjectIntMultiVector o2, ObjectIntMultiVector.WeightProvider weightProviderO2) throws java.lang.NullPointerException
ObjectIntMultiVector
s using
a metric weighted cosine distance. Specifically, the dot product of
the intersecting weights divided by the multiplication of their norms
is returned.o1
- the object to compute distance fromweightProviderO1
- the weight provider for object o1
o2
- the object to compute distance toweightProviderO2
- the weight provider for object o2
o1
and object o2
java.lang.NullPointerException
- if either weightProviderO1
or weightProviderO2
is null