Analysis tools for similarity measures
The analysis tools can be used to study the properties of similarity measures and similarity matrices.
- class madas.analysis.MetricSpaceTest(fingerprints: List[Fingerprint] | None = None, similarity_matrix: SimilarityMatrix | None = None, show_progress: bool = True)
Class for fingerprints to test if the fingerprints and their respective similarity measures span a metric space.
Usage:
mst = MetricSpaceTest(fingerprints: List[Fingerprint])is_metric = all(mst())- call_single(test_name: str) bool
Call a single test.
Arguments:
- test_name: str
Name of the test. Choose from: ‘uniqueness’, ‘identity’, ‘symmetry’, ‘triangle inequality’
Returns:
- result: bool
Result of the test.
Raises:
KeyError: Name of the test is not recogized.
- static identity(similarity_matrix: SimilarityMatrix, show_progress: bool = True)
Test identity property of a similarity matrix.
Tests: S(i,i) == 1 for all fingerprints i and similarity S
Arguments:
- similarity_matrix: SimilarityMatrix
Similarity matrix to test.
Keyword arguments:
- show_progress: bool
Show progress of test.
default: True
Returns:
- result: bool
Result of the test: True: identical fingerprints have S == 1, False else
- static symmetry(similarity_matrix: SimilarityMatrix, show_progress: bool = True)
Test symmetry property of a similarity matrix. The threshold for being equal is 1e-8.
Tests: S(i,j) == S(j,i) for fingerprints i,j and similarity S
Arguments:
- similarity_matrix: SimilarityMatrix
Similarity matrix to test.
Keyword arguments:
- show_progress: bool
Show progress of test.
default: True
Returns:
- result: bool
Result of the test: True: matrix is symmetric, False else
- static triangle_inequality(similarity_matrix: SimilarityMatrix, show_progress: bool = True)
Test triangle inequality property of a similarity matrix. The threshold for being equal is 1e-8.
Tests: S(i,k) + S(j,k) <= S(j,i) + 1 for fingerprints i,j,k and similarity S
Arguments:
- similarity_matrix: SimilarityMatrix
Similarity matrix to test.
Keyword arguments:
- show_progress: bool
Show progress of test.
default: True
Returns:
- result: bool
Result of the test: True: matrix obays triangle inequality, False else
- static uniqueness(similarity_matrix: SimilarityMatrix, fingerprints: List[Fingerprint], show_progress: bool = True)
Test uniqueness property of a similarity matrix.
Tests: i != j -> S(i,j) != 1 for fingerprints i,j and similarity S
Arguments:
- similarity_matrix: SimilarityMatrix
Similarity matrix to test.
- fingerprints: List[Fingerprint]
List of fingerprints to verfy if two fingerprints are equal.
Keyword arguments:
- show_progress: bool
Show progress of test.
default: True
Returns:
- result: bool
Result of the test: True: fingerprints are unique, False else
- class madas.analysis.StrideSpectrumComparison(grid_id: str = 'nonuniform:-2:0.05:1.05:0.3:8:0.5:-1:1:1024', cutoff: List[float] = [-1, 1], eref_stepsize: float = 0.1, show_progress: bool = True, **kwargs)
Compare two spectra by “striding” small spectum-fingerprint feature regions along the x-axis.
- Usage:
For spectra 1 and 2 with x-values x1 and x2 and y-values y1 and y2:
ssc = StrideSpectrumComparison() stride_list, similarities = ssc(x1, y1, x2, y2)
Returns:
- stride_list: list of float
List of strides that were used for calculating the similarities
- similarities: list of float
Similiarity of the spectra in a window centered at the respective stride