![]() |
Chemical Data Processing Library Python API - Version 1.2.3
|
Functor class for calculating the Tversky Similarity [GSIM] of bitsets. More...
Public Member Functions | |
None | __init__ (float alpha=0.95, float beta=0.05) |
Constructor. More... | |
None | __init__ (TverskySimilarity func) |
Initializes a copy of the TverskySimilarity instance func. More... | |
int | getObjectID () |
Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
TverskySimilarity | assign (TverskySimilarity func) |
Replaces the current state of self with a copy of the state of the TverskySimilarity instance func. More... | |
float | __call__ (Util.BitSet bs1, Util.BitSet bs2) |
Calculates the Tversky Similarity [GSIM] of the bitsets bs1 and bs2. More... | |
Properties | |
objectID = property(getObjectID) | |
Functor class for calculating the Tversky Similarity [GSIM] of bitsets.
None CDPL.Descr.TverskySimilarity.__init__ | ( | float | alpha = 0.95 , |
float | beta = 0.05 |
||
) |
Constructor.
alpha | Weights the contribution of the first bitset. |
beta | Weights the contribution of the second bitset. |
None CDPL.Descr.TverskySimilarity.__init__ | ( | TverskySimilarity | func | ) |
Initializes a copy of the TverskySimilarity instance func.
func | The TverskySimilarity instance to copy. |
int CDPL.Descr.TverskySimilarity.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python TverskySimilarity
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 TverskySimilarity
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()
.
TverskySimilarity CDPL.Descr.TverskySimilarity.assign | ( | TverskySimilarity | func | ) |
Replaces the current state of self with a copy of the state of the TverskySimilarity
instance func.
func | The TverskySimilarity instance to copy. |
float CDPL.Descr.TverskySimilarity.__call__ | ( | Util.BitSet | bs1, |
Util.BitSet | bs2 | ||
) |
Calculates the Tversky Similarity [GSIM] of the bitsets bs1 and bs2.
The Tversky Similarity \( S_{ab} \) is calculated by:
[ S_{ab} = \frac{N_{ab}}{\alpha * N_a + \beta * N_b + N_{ab}} ]
where \( N_{ab} \) is the number of bits that are set in both bitsets, \( N_a \) is the number of bits that are only set in the first bitset and \( N_b \) is the number of bits that are only set in the second bitset. \( \alpha \) and \( \beta \) are bitset contribution weighting factors.
The Tversky measure is asymmetric. Setting the parameters \( \alpha = \beta = 1.0 \) makes it identical to the Tanimoto measure.
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. |