Parity
Tutorials
Check out this tutorial to begin using the Parity class
How To Guides
There are currently no how to’s for Parity.
If there are scenarios that you want us to explain, contact us!
DAML API
- class daml.metrics.Parity(expected_labels: ndarray, observed_labels: ndarray, num_classes: int | None = None)
Class for evaluating statistics of observed and expected class labels, including:
Chi Squared test for statistical independence between expected and observed labels
- Parameters:
expected_labels (np.ndarray) – List of class labels in the expected dataset
observed_labels (np.ndarray) – List of class labels in the observed dataset
num_classes (Optional[int]) – The number of unique classes in the datasets. If this is not specified, it will be inferred from the set of unique labels in expected_labels and observed_labels
- evaluate() Tuple[float64, float64]
Perform a one-way chi-squared test between observation frequencies and expected frequencies that tests the null hypothesis that the observed data has the expected frequencies.
This function acts as an interface to the scipy.stats.chisquare method, which is documented at https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chisquare.html https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chisquare.html
- Returns:
np.float64 – chi-squared value of the test
np.float64 – p-value of the test
- set_labels(expected_labels: ndarray, observed_labels: ndarray, num_classes: int | None = None)
Calculates the label distributions for expected and observed labels and performs validation on the results.
- Parameters:
expected_labels (np.ndarray) – List of class labels in the expected dataset
observed_labels (np.ndarray) – List of class labels in the observed dataset
num_classes (Optional[int]) – The number of unique classes in the datasets. If this is not specified, it will be inferred from the set of unique labels in expected_labels and observed_labels
- Raises:
ValueError – If x is empty