Reference · The Applied Higher-Order Functions catalogue
rainbow.algorithms.proofs.ahof.logistic-regression
AHoF Logistic Regression: a probabilistic linear classifier that models the class probability as the logistic sigmoid of a linear score, P(y=1|x) = sigmoid(w.x + b), trained by maximizing the log-likelihood (gradient ascent). At prediction time a point is labelled positive when its predicted probability reaches the decision threshold (1/2 by default, equivalently the linear score reaching 0): classify-positive? probability threshold = decide (threshold <= probability) over exact-rational probabilities. Proved native and axiom-free: the classification decision; that a probability at least 1/2 is labelled positive; the certificate that a positive label really means probability >= threshold (native nnrat/at-most) -- calibrated by the threshold; and that a probability below 1/2 is labelled negative. The sigmoid, the log-likelihood gradient, and the weight updates are executable; what is proved is the probability-threshold decision. Requires nnrat/at-most, audit/decide-nnrat-at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.logistic-regression` prints this classification.
logistic/classify-positive?
logistic/classify-positive? : (x₁ x₂ : ℚ≥0) → data/Bool
ℚ≥0 = nnrat/NonnegativeRational
logistic/high-probability-positive
logistic/high-probability-positive : → bo/is-safe 3/4 1/2 = data/true
= = equality/Eq
logistic/positive-meets-threshold
logistic/positive-meets-threshold : → 1/2 ≤ 3/4
≤ = nnrat/at-most
logistic/low-probability-negative
logistic/low-probability-negative : → bo/is-safe 1/4 1/2 = data/false
= = equality/Eq