Models

Type-directed model interfaces — the classifier / regressor typeclasses. Two Lean-style typeclasses give a *named, type-directed* interface over predictive models, so the same code drives a neural network and a scikit-learn model alike: * ``Classifier`` — a model whose target is a discrete class. ``classify`` returns a vector of per-class scores. * ``Regressor`` — a model whose target is a real number. ``regress`` returns the predicted number. The *concrete* model types are specific — ``NN.Network`` (a neural network), and ``Learning``'s ``SklearnClassifier`` / ``SklearnRegressor`` (fitted scikit-learn estimators) — and each opts into the matching class. The shared feature representation is a ``Tensor.Vector`` (one sample). Scope note: typeclass methods are dictionary projections, *opaque to the SMT backend* (the same caveat ``Num`` documents). So the dimension invariants ``Tensor`` / ``NN`` and the shape/metric refinements ``Learning`` verify on their concrete operations are not carried as laws through these generic methods — a width mismatch surfaces at runtime, not compile time. Use the classes for type-directed dispatch and reuse; drop to ``NN.predict`` / ``Learning.predict`` directly for the static guarantee. ── Classes ──────────────────────────────────────────────────────────── The classifier typeclass: discrete target, vector of class scores.
Imports
open Tensor; open NN; open Learning;
Table of Contents

Types

Classifier

(inductive)
The classifier typeclass: discrete target, vector of class scores.
inductive Classifier m

Regressor

(inductive)
The regressor typeclass: continuous target, a single predicted value.
inductive Regressor m

Constructors

For each type in this module: inductive types list their declared constructors; opaque types list any local function whose name starts with mk and which returns a value of that type.

Classifier (inductive)

mk

constructor
The classifier typeclass: discrete target, vector of class scores.
Classifier m

Regressor (inductive)

mk

constructor
The regressor typeclass: continuous target, a single predicted value.
Regressor m

Functions

cls_inputs

def cls_inputs ∀m:Β (_d1470: Classifier m) (model: m) : Int

cls_classes

def cls_classes ∀m:Β (_d1471: Classifier m) (model: m) : Int

classify

def classify ∀m:Β (_d1472: Classifier m) (model: m) (x: Vector) : Vector

reg_inputs

def reg_inputs ∀m:Β (_d1473: Regressor m) (model: m) : Int

regress

def regress ∀m:Β (_d1474: Regressor m) (model: m) (x: Vector) : Float

__inst_Classifier_Network

def __inst_Classifier_Network : Classifier Network

__inst_Regressor_Network

def __inst_Regressor_Network : Regressor Network

__inst_Classifier_SklearnClassifier

def __inst_Classifier_SklearnClassifier : Classifier SklearnClassifier

__inst_Regressor_SklearnRegressor

def __inst_Regressor_SklearnRegressor : Regressor SklearnRegressor