Logistic Regression — API Reference
Auto-generated from the source docstrings. For the problem formulation and a usage example, see the Logistic Regression task page.
Types
dp_testing_platform.tasks.logistic_regression.types
LogisticRegressionMetadata
dataclass
Metadata for logistic regression.
Attributes:
| Name | Type | Description |
|---|---|---|
dim |
int
|
Dimension of the feature vectors. |
n_samples |
int
|
Number of samples in the dataset. |
LogisticRegressionInput
dataclass
Input for logistic regression.
Attributes:
| Name | Type | Description |
|---|---|---|
X |
Array2D
|
Feature matrix, shape (n_samples, dim). |
y |
Array1D
|
Binary labels, shape (n_samples,). Values in {0, 1}. |
LogisticRegressionOutput
dataclass
Output for logistic regression.
Attributes:
| Name | Type | Description |
|---|---|---|
theta |
Array1D
|
Estimated coefficient vector, shape (dim,). |
Algorithms
dp_testing_platform.tasks.logistic_regression.algorithms.newton_method
LogisticRegressionNewton
Bases: BaseAlgorithm
Non-private Newton's method for logistic regression (baseline).
Second-order optimization with backtracking line search. No privacy guarantees. Standard/textbook second-order optimizer (Newton-Raphson with Armijo line search); not a DP mechanism and has no single canonical paper.
Reference
Non-private baseline; no DP source paper.
Hyperparameters
tol: Convergence tolerance. Default: 1e-6. max_iter: Maximum iterations. Default: 100. alpha: Armijo condition parameter. Default: 0.25. beta: Line search step reduction factor. Default: 0.5.
dp_testing_platform.tasks.logistic_regression.algorithms.vanilla_gradient_descent
LogisticRegressionVanillaGD
Bases: BaseAlgorithm
Non-private gradient descent for logistic regression (baseline).
Full-batch gradient descent on cross-entropy loss. No privacy guarantees. Standard/textbook first-order optimizer; not a DP mechanism and has no single canonical paper.
Reference
Non-private baseline; no DP source paper.
Hyperparameters
lr: Learning rate. Default: 0.1. max_iter: Maximum iterations. Default: 100.
Instance generators
dp_testing_platform.tasks.logistic_regression.instance_generators.gaussian_instance_generator
GaussianCovariates
Bases: InstanceGenerator
Gaussian instance generator for logistic regression.
Generates X ~ N(0, I) and y ~ Bernoulli(sigmoid(X @ theta)).
Metrics
dp_testing_platform.tasks.logistic_regression.metrics
Metric registry for logistic_regression task.
l2_error
L2 error between output.theta and a reference vector (ground truth).
dp_noisy_error
dp_noisy_error(output: LogisticRegressionOutput, evaluation_metadata: LogisticRegressionMetadata, evaluation_input: LogisticRegressionInput, budget: DPBudget, seed: int) -> float
Noisy classification error rate for DP model selection.
A selection cost — lower is better, matching the argmin the DP selection tuners take. Satisfies eps-DP under the add/remove-one (unbounded DP) neighboring relation. The private quantity is the SUM of misclassified predictions S = sum(1{incorrect}); adding or removing one evaluation record changes S by at most one [0, 1] term, so S has add/remove L1 sensitivity 1. Releasing S + Laplace(0, 1/eps) is therefore eps-DP, and dividing by the PUBLIC evaluation count n is post-processing. Equivalently the released error is err + Laplace(0, 1/(neps)) — i.e. the effective noise scale on the rate is 1/(neps), n-times smaller than naively treating the rate as a sensitivity-1 statistic (which over-noises and swamps the signal for private model selection). Gaussian noise is NOT used here — it cannot satisfy pure eps-DP for any finite noise scale.