fairlens.metrics.DistanceMetric¶
-
class
DistanceMetric
(**kwargs)[source]¶ Bases:
abc.ABC
Base class for distance metrics that compare samples from two distributions.
Computes the distance between the probability distributions of x and y with respect to the target attribute.
Subclasses must implement a distance method.
Methods
Initialize distance metric.
Check whether the input is valid.
Distance between the distribution of numerical data in x and y.
Returns a p-value for the test that x and y are sampled from the same distribution.
-
__call__
(x, y)[source]¶ Calculate the distance between two distributions.
- Parameters
x (pd.Series) – The data in the column representing the first group.
y (pd.Series) – The data in the column representing the second group.
- Returns
The computed distance.
- Return type
Optional[float]
-
abstract
check_input
(x, y)[source]¶ Check whether the input is valid. Returns False if x and y have different dtypes by default.
- Parameters
x (pd.Series) – The data in the column representing the first group.
y (pd.Series) – The data in the column representing the second group.
- Returns
Whether or not the input is valid.
- Return type
bool
-
abstract
distance
(x, y)[source]¶ Distance between the distribution of numerical data in x and y. Derived classes must implement this.
- Parameters
x (pd.Series) – Numerical data in a column.
y (pd.Series) – Numerical data in a column.
- Returns
The computed distance.
- Return type
float
-
abstract property
id
¶ A string identifier for the method. Used by fairlens.metrics.stat_distance(). Derived classes must implement this.
-