![]() |
Chemical Data Processing Library Python API - Version 1.2.3
|
Functor class for calculating the Manhattan Similarity [GSIM] of bitsets. More...
Public Member Functions | |
None | __init__ () |
Initializes the ManhattanSimilarity instance. | |
None | __init__ (ManhattanSimilarity func) |
Initializes a copy of the ManhattanSimilarity instance func. More... | |
int | getObjectID () |
Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
ManhattanSimilarity | assign (ManhattanSimilarity func) |
Replaces the current state of self with a copy of the state of the ManhattanSimilarity instance func. More... | |
float | __call__ (Util.BitSet bs1, Util.BitSet bs2) |
Calculates the Manhattan Similarity [GSIM] of the bitsets bs1 and bs2. More... | |
Properties | |
objectID = property(getObjectID) | |
Functor class for calculating the Manhattan Similarity [GSIM] of bitsets.
None CDPL.Descr.ManhattanSimilarity.__init__ | ( | ManhattanSimilarity | func | ) |
Initializes a copy of the ManhattanSimilarity instance func.
func | The ManhattanSimilarity instance to copy. |
int CDPL.Descr.ManhattanSimilarity.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python ManhattanSimilarity
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 ManhattanSimilarity
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()
.
ManhattanSimilarity CDPL.Descr.ManhattanSimilarity.assign | ( | ManhattanSimilarity | func | ) |
Replaces the current state of self with a copy of the state of the ManhattanSimilarity
instance func.
func | The ManhattanSimilarity instance to copy. |
float CDPL.Descr.ManhattanSimilarity.__call__ | ( | Util.BitSet | bs1, |
Util.BitSet | bs2 | ||
) |
Calculates the Manhattan Similarity [GSIM] of the bitsets bs1 and bs2.
The Manhattan Similarity \( S_{ab} \) is calculated by:
[ S_{ab} = \frac{N_a + N_b}{N_a + N_b + N_{ab} + 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 set only in the first bitset, \( N_b \) is the number of bits that are set only in the second bitset and \( N_{!ab} \) is the number of bits that are not set in both bitsets.
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. |