![]() |
Chemical Data Processing Library Python API - Version 1.2.3
|
Functor class for calculating Cosine Similarities [WCOS] of bitsets and vectors. More...
Public Member Functions | |
None | __init__ () |
Initializes the CosineSimilarity instance. | |
None | __init__ (CosineSimilarity func) |
Initializes a copy of the CosineSimilarity instance func. More... | |
int | getObjectID () |
Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
CosineSimilarity | assign (CosineSimilarity func) |
Replaces the current state of self with a copy of the state of the CosineSimilarity instance func. More... | |
float | __call__ (Util.BitSet bs1, Util.BitSet bs2) |
Calculates the Cosine Similarity [WCOS] of the bitsets bs1 and bs2. More... | |
float | __call__ (Math.FVector v1, Math.FVector v2) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2. More... | |
float | __call__ (Math.DVector v1, Math.DVector v2) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2. More... | |
float | __call__ (Math.LVector v1, Math.LVector v2) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2. More... | |
float | __call__ (Math.ULVector v1, Math.ULVector v2) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2. More... | |
Properties | |
objectID = property(getObjectID) | |
Functor class for calculating Cosine Similarities [WCOS] of bitsets and vectors.
None CDPL.Descr.CosineSimilarity.__init__ | ( | CosineSimilarity | func | ) |
Initializes a copy of the CosineSimilarity instance func.
func | The CosineSimilarity instance to copy. |
int CDPL.Descr.CosineSimilarity.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python CosineSimilarity
instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b
thus cannot tell reliably whether the two CosineSimilarity
instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID()
.
CosineSimilarity CDPL.Descr.CosineSimilarity.assign | ( | CosineSimilarity | func | ) |
Replaces the current state of self with a copy of the state of the CosineSimilarity
instance func.
func | The CosineSimilarity instance to copy. |
float CDPL.Descr.CosineSimilarity.__call__ | ( | Util.BitSet | bs1, |
Util.BitSet | bs2 | ||
) |
Calculates the Cosine Similarity [WCOS] of the bitsets bs1 and bs2.
The Cosine Similarity S_{ab} is calculated by:
[ S_{ab} = \frac{N_{ab}}{\sqrt{N_a * N_b}} ]
where N_{ab} is the number of bits that are set in both bitsets, N_a is the number of bits that are set in the first bitset and N_b is the number of bits that are set in the second bitset.
If the specified bitsets bs1 and bs2 are of different size, missing bits at the end of the smaller bitset are assumed to be zero.
bs1 | The first bitset. |
bs2 | The second bitset. |
float CDPL.Descr.CosineSimilarity.__call__ | ( | Math.FVector | v1, |
Math.FVector | v2 | ||
) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2.
The Cosine Similarity S_{12} is calculated by:
[ S_{12} = \frac{\vec{v}_1 \cdot \vec{v}_2}{{\left | \vec{v}_1 \right |}{\left | \vec{v}_2 \right |}} ]
v1 | The first vector. |
v2 | The second vector. |
float CDPL.Descr.CosineSimilarity.__call__ | ( | Math.DVector | v1, |
Math.DVector | v2 | ||
) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2.
The Cosine Similarity S_{12} is calculated by:
[ S_{12} = \frac{\vec{v}_1 \cdot \vec{v}_2}{{\left | \vec{v}_1 \right |}{\left | \vec{v}_2 \right |}} ]
v1 | The first vector. |
v2 | The second vector. |
float CDPL.Descr.CosineSimilarity.__call__ | ( | Math.LVector | v1, |
Math.LVector | v2 | ||
) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2.
The Cosine Similarity S_{12} is calculated by:
[ S_{12} = \frac{\vec{v}_1 \cdot \vec{v}_2}{{\left | \vec{v}_1 \right |}{\left | \vec{v}_2 \right |}} ]
v1 | The first vector. |
v2 | The second vector. |
float CDPL.Descr.CosineSimilarity.__call__ | ( | Math.ULVector | v1, |
Math.ULVector | v2 | ||
) |
Calculates the Cosine Similarity [WCOS] of the vectors v1 and v2.
The Cosine Similarity S_{12} is calculated by:
[ S_{12} = \frac{\vec{v}_1 \cdot \vec{v}_2}{{\left | \vec{v}_1 \right |}{\left | \vec{v}_2 \right |}} ]
v1 | The first vector. |
v2 | The second vector. |