fair_seldonian.algorithms package
Submodules
fair_seldonian.algorithms.qsa module
- fair_seldonian.algorithms.qsa.QSA(X, Y, T, seldonian_type, init_sol, init_sol1, config=SeldonianConfig(delta=0.05, inequality=<Inequality.HOEFFDING_INEQUALITY: 2>, constraint='TP(1) TP(0) - abs 0.25 TP(1) * -', candidate_ratio=0.4))[source]
This function is used to run the qsa (Quasi-Seldonian Algorithm)
- Parameters:
X (ndarray) – The features of the dataset
Y (ndarray) – The corresponding labels of the dataset
T (ndarray) – The corresponding sensitive attributes of the dataset
seldonian_type (str) – The mode used in the experiment
init_sol (Tensor | None) – The initial theta values for the model
init_sol1 (Tensor | None) – The additional initial theta values for the model
config (SeldonianConfig) – Algorithm configuration
- Returns:
(thetexit
- Return type:
a, theta1, passed_safety) tuple
- fair_seldonian.algorithms.qsa.safety_test(theta, theta1, safe_data_X, safe_data_Y, safe_data_T, seldonian_type, config=SeldonianConfig(delta=0.05, inequality=<Inequality.HOEFFDING_INEQUALITY: 2>, constraint='TP(1) TP(0) - abs 0.25 TP(1) * -', candidate_ratio=0.4))[source]
This function does the safety test.
- Parameters:
theta (Tensor) – The optimal theta values for the model
theta1 (Tensor) – The additional optimal theta values for the model
safe_data_X (ndarray) – The features of the safety dataset
safe_data_Y (ndarray) – The corresponding labels of the safety dataset
safe_data_T (ndarray) – The corresponding sensitive attributes of the safety dataset
seldonian_type (str) – The mode used in the experiment
config (SeldonianConfig) – Algorithm configuration
- Returns:
Bool value of whether the candidate solution passed safety test or not.
- Return type:
- fair_seldonian.algorithms.qsa.get_cand_solution(cand_data_X, cand_data_Y, cand_data_T, seldonian_type, init_sol, init_sol1, config=SeldonianConfig(delta=0.05, inequality=<Inequality.HOEFFDING_INEQUALITY: 2>, constraint='TP(1) TP(0) - abs 0.25 TP(1) * -', candidate_ratio=0.4))[source]
This function provides the candidate solution.
- Parameters:
cand_data_X (ndarray) – The features of the candidate dataset
cand_data_Y (ndarray) – The corresponding labels of the candidate dataset
cand_data_T (ndarray) – The corresponding sensitive attributes of the candidate dataset
seldonian_type (str) – The mode used in the experiment
init_sol (Tensor | None) – The initial theta values for the model
init_sol1 (Tensor | None) – The additional initial theta values for the model
config (SeldonianConfig) – Algorithm configuration
- Returns:
The candidate solution (theta, theta1).
- Return type:
- fair_seldonian.algorithms.qsa.cand_obj(theta, cand_data_X, cand_data_Y, cand_data_T, seldonian_type, config)[source]
Objective function minimized by the optimizer.
- Parameters:
theta (ndarray) – The theta values for the model
cand_data_X (ndarray) – The features of the candidate dataset
cand_data_Y (ndarray) – The corresponding labels of the candidate dataset
cand_data_T (ndarray) – The corresponding sensitive attributes of the candidate dataset
seldonian_type (str) – The mode used in the experiment
config (SeldonianConfig) – Algorithm configuration
- Returns:
The objective value.
- Return type: