Documentation

CslibFrontier.MachineLearning.UniformLearning.BestOf

Best-of-k selection for membership-query learners #

A learner whose hypothesis is good only with small probability p becomes a learner with confidence 1 - η by the standard repetition-and-selection argument: run it on k independent seeds, estimate the agreement of each of the k hypotheses with the target on t fresh uniform points by membership queries, and output a hypothesis of largest empirical agreement (UniformLearning.QueryLearner.bestOf). This is the confidence boosting step of [Carmosino, Impagliazzo, Kabanets and Kolokolova, Theorem 2.11, p. 10:9] [CIKK16], which applies it to the Nisan–Wigderson reconstruction learner.

The hypotheses are fixed before the estimation queries, so the combined learner makes at most k * q + t queries when each run makes at most q (UniformLearning.QueryLearner.queriesAtMost_bestOf), and its output is the hypothesis of one of the runs (UniformLearning.QueryLearner.exists_eval_bestOf_eq). Any bound on the hypotheses of all runs, such as their circuit or formula complexity, therefore bounds the output (UniformLearning.QueryLearner.le_sup_eval_bestOf).

The seeds of the combined learner are k independent seeds of the given learner together with t independent uniform points (UniformLearning.QueryLearner.bestOfSeed). If the given learner has error above ε with probability at most δ, the combined learner has error above ε + 2θ with probability at most δ ^ k + 2 k exp (-2 t θ²): every run fails with probability δ ^ k, and otherwise some agreement estimate is off by t θ with probability at most 2 k exp (-2 t θ²) by Hoeffding's inequality and a union bound (UniformLearning.QueryLearner.learns_bestOf). For a learner with error at most ε with probability at least p, taking k ≥ log (2/η) / p and t ≥ log (4k/η) / (2θ²) gives error at most ε + 2θ with probability at least 1 - η (UniformLearning.QueryLearner.learns_bestOf_of_success). For a weak learner, with agreement at least 1/2 + γ with probability at least p, taking θ = γ/4 gives agreement at least 1/2 + γ/2 with probability at least 1 - η once t ≥ 8 log (4k/η) / γ² (UniformLearning.QueryLearner.learns_bestOf_of_weak).

As for the other query learners here, only the number of queries is certified; running time is not. Selection compares exact integer agreement counts; ties go to the first maximizing run.

Main definitions #

Main results #

References #

def Cslib.MachineLearning.UniformLearning.QueryLearner.agreeCount {ι : Type u_1} {t : ℕ} (g h : (ι → Bool) → Bool) (x : Fin t → ι → Bool) :

The number of the sample points x i at which the hypothesis h agrees with the target g.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.agreeCount_eq_card {ι : Type u_1} {t : ℕ} (g h : (ι → Bool) → Bool) (x : Fin t → ι → Bool) :
agreeCount g h x = {i : Fin t | h (x i) = g (x i)}.card

Unfolding of agreeCount as the cardinality of the agreeing sample indices.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.agreeCount_le {ι : Type u_1} {t : ℕ} (g h : (ι → Bool) → Bool) (x : Fin t → ι → Bool) :
agreeCount g h x ≤ t

The agreement count on t sample points is at most t.

def Cslib.MachineLearning.UniformLearning.QueryLearner.selectBest {ι : Type u_1} {k t : ℕ} [NeZero k] (g : (ι → Bool) → Bool) (hs : Fin k → (ι → Bool) → Bool) (x : Fin t → ι → Bool) :
Fin k

The index of a hypothesis among hs with the largest agreement count with g on the sample x; the first such index.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.agreeCount_le_selectBest {ι : Type u_1} {k t : ℕ} [NeZero k] (g : (ι → Bool) → Bool) (hs : Fin k → (ι → Bool) → Bool) (x : Fin t → ι → Bool) (j : Fin k) :
agreeCount g (hs j) x ≤ agreeCount g (hs (selectBest g hs x)) x

The selected hypothesis has the largest agreement count.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.selectBest_congr {ι : Type u_1} {k t : ℕ} [NeZero k] {g g' : (ι → Bool) → Bool} (hs : Fin k → (ι → Bool) → Bool) (x : Fin t → ι → Bool) (h : ∀ (i : Fin t), g (x i) = g' (x i)) :
selectBest g hs x = selectBest g' hs x

Selection reads the target only at the sample points.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.selectBest_eq_iff {ι : Type u_1} {k t : ℕ} [NeZero k] (g : (ι → Bool) → Bool) (hs : Fin k → (ι → Bool) → Bool) (x : Fin t → ι → Bool) (j : Fin k) :
selectBest g hs x = j ↔ ∀ (j' : Fin k), if ↑j' < ↑j then agreeCount g (hs j') x < agreeCount g (hs j) x else agreeCount g (hs j') x ≤ agreeCount g (hs j) x

Tie-breaking characterization of selectBest: j is the selected index iff it has maximal agreement count and strictly beats every earlier index j' < j.

def Cslib.MachineLearning.UniformLearning.QueryLearner.bestOf {ι : Type u_1} {Ω : Type u_2} [Fintype ι] (A : QueryLearner ι Ω) (k t : ℕ) [NeZero k] :
QueryLearner ι ((Fin k → Ω) × (Fin t → ι → Bool))

Best-of-k selection: run A on the seeds ω 0, …, ω (k - 1), query the target at the sample points x 0, …, x (t - 1), and output a hypothesis of a run with the largest number of agreements with the target at those points.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.eval_bestOf {ι : Type u_1} {Ω : Type u_2} [Fintype ι] (A : QueryLearner ι Ω) (k t : ℕ) [NeZero k] (f : (ι → Bool) → Bool) (ω : Fin k → Ω) (x : Fin t → ι → Bool) :
(A.bestOf k t (ω, x)).eval f = (A (ω (selectBest f (fun (j : Fin k) => (A (ω j)).eval f) x))).eval f

Run on the target f, bestOf outputs the hypothesis of the run selected by its agreement with f on the sample.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.exists_eval_bestOf_eq {ι : Type u_1} {Ω : Type u_2} [Fintype ι] (A : QueryLearner ι Ω) (k t : ℕ) [NeZero k] (f : (ι → Bool) → Bool) (ω : Fin k → Ω) (x : Fin t → ι → Bool) :
∃ (j : Fin k), (A.bestOf k t (ω, x)).eval f = (A (ω j)).eval f

The output of bestOf is the hypothesis of one of the runs.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.le_sup_eval_bestOf {ι : Type u_1} {Ω : Type u_2} [Fintype ι] (A : QueryLearner ι Ω) (k t : ℕ) [NeZero k] (f : (ι → Bool) → Bool) (ω : Fin k → Ω) (x : Fin t → ι → Bool) (c : ((ι → Bool) → Bool) → ℕ) :
c ((A.bestOf k t (ω, x)).eval f) ≤ Finset.univ.sup fun (j : Fin k) => c ((A (ω j)).eval f)

Any measure c of the output hypothesis, such as its circuit complexity, is at most the largest value of c on the hypotheses of the runs.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.queriesAtMost_bestOf {ι : Type u_1} {Ω : Type u_2} {k t : ℕ} [Fintype ι] [NeZero k] {A : QueryLearner ι Ω} {q : ℕ} (hA : A.QueriesAtMost q) :
(A.bestOf k t).QueriesAtMost (k * q + t)

If every run makes at most q queries, bestOf makes at most k * q + t: k * q for the runs and t for the agreement estimates.

noncomputable def Cslib.MachineLearning.UniformLearning.QueryLearner.bestOfSeed {ι : Type u_1} {Ω : Type u_2} [Fintype ι] [DecidableEq ι] (μ : PMF Ω) (k t : ℕ) :
PMF ((Fin k → Ω) × (Fin t → ι → Bool))

The seed distribution of bestOf: k independent seeds drawn from μ and t independent uniform sample points.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.learns_bestOf {ι : Type u_1} {Ω : Type u_2} {k t : ℕ} [Fintype ι] [DecidableEq ι] [NeZero k] {A : QueryLearner ι Ω} {μ : PMF Ω} {C : PACLearning.ConceptClass (ι → Bool) Bool} {ε δ θ : ℝ} (hA : A.Learns μ C ε δ) (hδ : 0 ≤ δ) (hθ : 0 ≤ θ) :
(A.bestOf k t).Learns (bestOfSeed μ k t) C (ε + 2 * θ) (δ ^ k + 2 * ↑k * Real.exp (-2 * ↑t * θ ^ 2))

Confidence of best-of-k selection. If A has error above ε with probability at most δ, then bestOf A k t has error above ε + 2θ with probability at most δ ^ k + 2 k exp (-2 t θ²).

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.learns_bestOf_of_success {ι : Type u_1} {Ω : Type u_2} {k t : ℕ} [Fintype ι] [DecidableEq ι] [NeZero k] {A : QueryLearner ι Ω} {μ : PMF Ω} {C : PACLearning.ConceptClass (ι → Bool) Bool} {ε p θ η : ℝ} (hA : A.Learns μ C ε (1 - p)) (hp : p ≤ 1) (hθ : 0 ≤ θ) (hη : 0 < η) (hk : Real.log (2 / η) ≤ p * ↑k) (ht : Real.log (4 * ↑k / η) ≤ 2 * ↑t * θ ^ 2) :
(A.bestOf k t).Learns (bestOfSeed μ k t) C (ε + 2 * θ) η

Boosting the confidence. If A has error at most ε with probability at least p, then bestOf A k t with k ≥ log (2/η) / p runs and t ≥ log (4k/η) / (2θ²) sample points has error at most ε + 2θ with probability at least 1 - η: all runs fail with probability at most η / 2, and some agreement estimate is off by tθ with probability at most η / 2.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.learns_bestOf_of_weak {ι : Type u_1} {Ω : Type u_2} {k t : ℕ} [Fintype ι] [DecidableEq ι] [NeZero k] {A : QueryLearner ι Ω} {μ : PMF Ω} {C : PACLearning.ConceptClass (ι → Bool) Bool} {γ p η : ℝ} (hA : A.Learns μ C (1 / 2 - γ) (1 - p)) (hγ : 0 < γ) (hp : p ≤ 1) (hη : 0 < η) (hk : Real.log (2 / η) ≤ p * ↑k) (ht : 8 * Real.log (4 * ↑k / η) ≤ ↑t * γ ^ 2) :
(A.bestOf k t).Learns (bestOfSeed μ k t) C (1 / 2 - γ / 2) η

From weak to confident learning. If A outputs a hypothesis with agreement at least 1/2 + γ (error at most 1/2 - γ) with probability at least p, then bestOf A k t with k ≥ log (2/η) / p runs and t ≥ 8 log (4k/η) / γ² sample points outputs a hypothesis with agreement at least 1/2 + γ/2 with probability at least 1 - η. This is learns_bestOf_of_success with θ = γ / 4.