package modelkit

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Modelkit.Multinomial_logistic_regression

Weighted multinomial logistic regression with an L2 coefficient penalty.

At least three positively weighted integer classes are required and stored in ascending order. The solver jointly minimizes stable softmax cross-entropy and the coefficient penalty under a sum-to-zero class-score constraint; intercepts are not penalized. c is the positive inverse regularization strength. Deterministic damped Newton iterations stop on gradient or step tolerance, and iteration exhaustion is a typed convergence failure.

Coefficient rows, intercept entries, decision columns, and probability columns all follow ascending class order. Exact prediction ties select the lowest label. For k classes, n samples, and p augmented features, fitting costs O(iterations * (n * k squared * p squared + k cubed * p cubed)); prediction costs O(n * k * p).

type params = {
  1. c : float;
  2. fit_intercept : bool;
  3. tolerance : float;
  4. max_iterations : int;
}
type t
type fitted
val create : ?c:float -> ?fit_intercept:bool -> ?tolerance:float -> ?max_iterations:int -> unit -> (t, Error.t) result
val coefficients : fitted -> Matrix.t

Returns a classes * features matrix in classes order.

val intercepts : fitted -> Vector.t
val classes : fitted -> int array
val report : fitted -> Solver_report.t
val decision_function : fitted -> feature_schema:Feature_schema.t -> x:Matrix.t -> (Matrix.t, Error.t) result
val predict_proba : fitted -> feature_schema:Feature_schema.t -> x:Matrix.t -> (Matrix.t, Error.t) result
include CLASSIFIER with type t := t and type params := params and type fitted := fitted and type rng = Rng.t
include ESTIMATOR with type target = Target.classification Target.t and type prediction = Target.classification Target.t with type t := t with type params := params with type fitted := fitted with type rng = Rng.t
include SPECIFICATION with type t := t with type params := params
val clone : t -> t
val params : t -> params
type rng = Rng.t
val fit : t -> ?sample_weight:Sample_weight.t -> rng:rng -> feature_schema:Feature_schema.t -> x:Matrix.t -> y:target -> unit -> (fitted, Error.t) result
val predict : fitted -> feature_schema:Feature_schema.t -> x:Matrix.t -> (prediction, Error.t) result
val fitted_params : fitted -> params
val feature_schema : fitted -> Feature_schema.t