Documentation

CslibFrontier.MachineLearning.OnlineLearning.MistakeBound.Basic

The realizable mistake-bound model #

This file sets up Littlestone's model of online learning in the realizable case [Littlestone1988, §3] [ShalevShwartzBenDavid2014, §21.1]. Learning proceeds in rounds. In each round an adversary presents an instance x, the learner predicts a label in Bool, and then the adversary reveals the true label y. The learner errs when its prediction differs from y. The labels must stay consistent with some target concept c of a known concept class C : ConceptClass α Bool. The quantity of interest is the worst-case number of mistakes.

A deterministic learner is a function OnlineLearner α := List (α × Bool) → α → Bool. It sees the labelled history of the previous rounds and the current instance. mistakes A S counts the rounds of the labelled sequence S on which A errs. S is realizable by C when its version space versionSpace C S, the set of concepts of C that agree with every example of S, is nonempty. The mistake bound of A on C is the supremum of mistakes A S over all finite realizable S, in ℕ∞. The optimal mistake bound of C is the infimum of the mistake bounds over all deterministic learners. Littlestone writes these as M_A(C), defined just before Definition 1, and opt(C), Definition 1 [Littlestone1988, §3]. The supremum ranges over all finite sequences, so mistakeBound A C ≤ m says that A makes at most m mistakes on every realizable sequence of every length, matching Littlestone's quantification over all sequences. Littlestone sets M_A(∅) = -1; here the empty class has no realizable sequence, so its mistake bound is 0 (mistakeBound_empty).

Since the learner is deterministic, adaptivity gives the adversary nothing more. An Adversary chooses each instance and each label as a function of the history and of the learner's prediction. mistakeBound_eq_iSup_adversary shows that the mistake bound is also the supremum over adversaries and horizons of the mistakes on the realizable transcripts. mistakeBound_eq_iSup_concept restates the bound in Littlestone's form: the target concept c ∈ C is fixed and the adversary chooses only the instances.

Relation to other models. The library's PACLearning.VersionSpace and PACLearning.Realizable (cslib) are the batch analogues of versionSpace and Realizable, indexed by Fin m. The list form here follows the online history directly. This model differs from prediction with expert advice, which compares the learner with the best of a set of experts on arbitrary outcomes and measures regret. Here a single learner competes with the requirement of realizability and pays for each mistake absolutely; there are no experts and no losses beyond the mistake count. The non-realizable extension, with randomized learners, Hedge over deterministic experts and regret against the best concept, is in MistakeBound.Randomized and MistakeBound.Agnostic.

Main definitions #

Main results #

References #

@[reducible, inline]

A deterministic online learner: from the labelled history of the previous rounds and the current instance, it predicts a label.

Equations
Instances For

    mistakesFrom A h S: the number of mistakes of A on the rounds S, after the history h. Each round predicts from the history so far and then appends its example to it.

    Equations
    Instances For

      The number of mistakes of the learner A on the labelled sequence S, started from the empty history.

      Equations
      Instances For

        The version space: the concepts of C that agree with every example of S.

        Equations
        Instances For

          The mistake bound M_A(C) of the learner A on the class C [Littlestone1988, §3]: the supremum of the mistakes of A over all finite sequences realizable by C. For the empty class this is 0, where Littlestone sets M_A(∅) = -1.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            The optimal mistake bound opt(C) [Littlestone1988, §3, Definition 1]: the least mistake bound of a deterministic learner on C.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Mistake counts #

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakesFrom_cons {α : Type u_1} (A : OnlineLearner α) (h : List (α × Bool)) (x : α) (y : Bool) (S : List (α × Bool)) :
              mistakesFrom A h ((x, y) :: S) = (if A h x = y then 0 else 1) + mistakesFrom A (h ++ [(x, y)]) S

              The mistakes on S ++ S' are those on S, then those on S' after the history h ++ S.

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakesFrom_classifier {α : Type u_1} (c : α → Bool) (h S : List (α × Bool)) :
              mistakesFrom (fun (x : List (α × Bool)) (x_1 : α) => c x_1) h S = List.countP (fun (p : α × Bool) => decide (c p.1 ≠ p.2)) S

              The mistakes of a fixed classifier c, as a learner that ignores its history, are the examples it labels wrongly.

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakesFrom_eq_card {α : Type u_1} (A : OnlineLearner α) (h S : List (α × Bool)) :
              mistakesFrom A h S = {t : Fin S.length | A (h ++ List.take (↑t) S) S[t].1 ≠ S[t].2}.card

              After the history h, the mistakes on S are the rounds t on which the prediction from h and the first t examples of S is wrong.

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakes_eq_card {α : Type u_1} (A : OnlineLearner α) (S : List (α × Bool)) :
              mistakes A S = {t : Fin S.length | A (List.take (↑t) S) S[t].1 ≠ S[t].2}.card

              The mistakes of A on S are the rounds t on which the prediction from the first t examples is wrong.

              Version spaces #

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mem_versionSpace {α : Type u_1} {C : PACLearning.ConceptClass α Bool} {S : List (α × Bool)} {c : α → Bool} :
              c ∈ versionSpace C S ↔ c ∈ C ∧ ∀ p ∈ S, c p.1 = p.2

              Realizability #

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.realizable_iff {α : Type u_1} {C : PACLearning.ConceptClass α Bool} {S : List (α × Bool)} :
              Realizable C S ↔ ∃ c ∈ C, ∀ p ∈ S, c p.1 = p.2
              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.realizable_map {α : Type u_1} {C : PACLearning.ConceptClass α Bool} {c : α → Bool} (hc : c ∈ C) (xs : List α) :
              Realizable C (List.map (fun (x : α) => (x, c x)) xs)

              A sequence labelled by a concept of C is realizable by C.

              Mistake bounds #

              @[simp]

              The empty class has no realizable sequence, so every learner has mistake bound 0 on it. Littlestone's convention M_A(∅) = -1 is not used.

              theorem Cslib.MachineLearning.OnlineLearning.MistakeBound.mistakeBound_eq_iSup_concept {α : Type u_1} (A : OnlineLearner α) (C : PACLearning.ConceptClass α Bool) :
              mistakeBound A C = ⨆ c ∈ C, ⨆ (xs : List α), ↑(mistakes A (List.map (fun (x : α) => (x, c x)) xs))

              The mistake bound in Littlestone's form [Littlestone1988, §3]: the target c ∈ C is fixed and the adversary chooses the instances, each labelled by c.

              Adaptive adversaries #

              An adaptive adversary. From the labelled history it chooses the next instance (next), and from the history and the learner's prediction it chooses the label (label).

              • next : List (α × Bool) → α

                The next instance, as a function of the history.

              • label : List (α × Bool) → Bool → Bool

                The label, as a function of the history and of the learner's prediction.

              Instances For

                The labelled history after t rounds of the learner A against the adversary B.

                Equations
                Instances For

                  The oblivious adversary that presents the fixed sequence S, then repeats p₀.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Adaptive adversaries are no stronger than realizable sequences: the mistake bound of a deterministic learner is the supremum, over adversaries B and horizons t, of its mistakes on the transcripts that are realizable by C.