fair_seldonian.models package#
Submodules#
fair_seldonian.models.logistic_regression module#
- fair_seldonian.models.logistic_regression.eval_ghat(
- theta,
- theta1,
- X,
- Y,
- 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,
- optimizer='Powell',
- max_iter=10000,
- penalty=100.0),
- Parameters:
theta (torch.Tensor)
theta1 (torch.Tensor)
X (np.ndarray)
Y (Array)
T (Array)
seldonian_type (str)
config (SeldonianConfig)
- Return type:
Bound
- fair_seldonian.models.logistic_regression.f_hat(theta, theta1, X, Y)[source]#
Main objective function: negative log loss (higher is better).
Note that
torch.nn.CrossEntropyLossis the wrong tool here. It expects raw logits and applieslog_softmaxinternally, so stacking the predicted probabilities into a two-column tensor and passing them to it computes-log softmax([1-p, p])_y- a different function, with a floor of 0.3133 for a perfect classifier and a ceiling near 1.31. That both mislabels any axis called “log loss” and compresses the range roughly tenfold, which destroys the resolution of small between-method differences.- Parameters:
theta (torch.Tensor | None) – The optimal theta values for the model
theta1 (torch.Tensor | None) – The additional optimal theta values for the model
X (np.ndarray) – The features of the dataset
Y (Array) – The true labels of the dataset
- Returns:
The negative log loss
- Return type:
- fair_seldonian.models.logistic_regression.ghat(
- theta,
- theta1,
- X,
- Y,
- T,
- candidate_ratio,
- 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,
- optimizer='Powell',
- max_iter=10000,
- penalty=100.0),
- Parameters:
theta (torch.Tensor)
theta1 (torch.Tensor)
X (np.ndarray)
Y (Array)
T (Array)
candidate_ratio (float)
seldonian_type (str)
config (SeldonianConfig)
- Return type:
Bound
- fair_seldonian.models.logistic_regression.predict(theta, theta1, X)[source]#
This is the predict function for Logistic Regression. Currently, it implements: 1 / (1 + e^-(X.theta + theta1))