dataframe-learn-2.4.1.0: Interpretable, expression-returning machine learning for the dataframe ecosystem.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Segmented

Description

Fit a separate base model per categorical value-combination, routing each row to its segment at predict time; unseen or too-small segments fall back to a global fit. Optional partial pooling (linear base) shrinks small segments.

Synopsis

Documentation

data Segmented cfg Source #

A base estimator cfg wrapped to fit one model per categorical value-combination. segOn picks the columns (Nothing = auto-detect), segMinRows the smallest own-model segment, segPool the pooling strength λ.

Constructors

Segmented 

Fields

Instances

Instances details
Show cfg => Show (Segmented cfg) Source # 
Instance details

Defined in DataFrame.Segmented

Methods

showsPrec :: Int -> Segmented cfg -> ShowS #

show :: Segmented cfg -> String #

showList :: [Segmented cfg] -> ShowS #

Eq cfg => Eq (Segmented cfg) Source # 
Instance details

Defined in DataFrame.Segmented

Methods

(==) :: Segmented cfg -> Segmented cfg -> Bool #

(/=) :: Segmented cfg -> Segmented cfg -> Bool #

(Fit cfg (Expr a), SegmentFit cfg a, Predict (ModelOf cfg (Expr a)), Prediction (ModelOf cfg (Expr a)) ~ Expr a, Columnable a) => Fit (Segmented cfg) (Expr a) Source # 
Instance details

Defined in DataFrame.Segmented

Associated Types

type ModelOf (Segmented cfg) (Expr a) 
Instance details

Defined in DataFrame.Segmented

type ModelOf (Segmented cfg) (Expr a) = SegmentedModel a (ModelOf cfg (Expr a))
type FrameReq (Segmented cfg) (Expr a) 
Instance details

Defined in DataFrame.Segmented

type FrameReq (Segmented cfg) (Expr a) = 'AnyFrame

Methods

fit :: Segmented cfg -> Expr a -> FrameFor (Expr a) -> FitResult (FrameFor (Expr a)) (ModelOf (Segmented cfg) (Expr a)) Source #

type FrameReq (Segmented cfg) (Expr a) Source # 
Instance details

Defined in DataFrame.Segmented

type FrameReq (Segmented cfg) (Expr a) = 'AnyFrame
type ModelOf (Segmented cfg) (Expr a) Source # 
Instance details

Defined in DataFrame.Segmented

type ModelOf (Segmented cfg) (Expr a) = SegmentedModel a (ModelOf cfg (Expr a))

segmented :: cfg -> Segmented cfg Source #

Wrap a base config with the defaults: auto-detect, cap 32, min 30 rows, no pooling.

segmentOn :: Segmented cfg -> [Text] -> Segmented cfg Source #

Segment only on the named columns (each must be Text), overriding auto-detect.

pooled :: Segmented cfg -> Double -> Segmented cfg Source #

Set the pooling strength λ (shrink segments toward the reference).

data Segment model Source #

One fitted segment: its categorical key, row count, and base model.

Constructors

Segment 

Fields

Instances

Instances details
Show model => Show (Segment model) Source # 
Instance details

Defined in DataFrame.Segmented

Methods

showsPrec :: Int -> Segment model -> ShowS #

show :: Segment model -> String #

showList :: [Segment model] -> ShowS #

data SegmentedModel a model Source #

A fitted segmented model: the columns segmented on, the per-segment models (ascending key order), the observed combinations that fell back (key + row count), the global fallback model, and the compiled routing expression.

Constructors

SegmentedModel 

Fields

Instances

Instances details
(Show model, Show a) => Show (SegmentedModel a model) Source # 
Instance details

Defined in DataFrame.Segmented

Methods

showsPrec :: Int -> SegmentedModel a model -> ShowS #

show :: SegmentedModel a model -> String #

showList :: [SegmentedModel a model] -> ShowS #

Predict (SegmentedModel a model) Source # 
Instance details

Defined in DataFrame.Segmented

Associated Types

type Prediction (SegmentedModel a model) 
Instance details

Defined in DataFrame.Segmented

type Prediction (SegmentedModel a model) = Expr a

Methods

predict :: SegmentedModel a model -> Prediction (SegmentedModel a model) Source #

type Prediction (SegmentedModel a model) Source # 
Instance details

Defined in DataFrame.Segmented

type Prediction (SegmentedModel a model) = Expr a

class Fit cfg (Expr a) => SegmentFit cfg a where Source #

How a base estimator fits its per-segment models under pooling strength λ. The default fits each segment independently and rejects λ > 0; the linear instance overrides it with closed-form shrinkage. Every base model needs an instance.

Minimal complete definition

Nothing

Methods

fitSegments :: cfg -> Double -> Expr a -> [DataFrame] -> [ModelOf cfg (Expr a)] Source #

Fit the qualifying segments (each a numeric-only frame, in order).

Instances

Instances details
(Columnable a, Ord a) => SegmentFit LogisticConfig a Source #

Logistic segments support independent fitting (lambda = 0) only, for now.

Instance details

Defined in DataFrame.Segmented

SegmentFit LinearConfig Double Source #

Linear segments with exact closed-form pooling. λ = 0 is independent OLS; λ > 0 shrinks each segment's coefficients toward the n_g-weighted mean of the per-segment fits.

Instance details

Defined in DataFrame.Segmented

SegmentFit SRConfig Double Source #

Symbolic-regression segments support independent fitting (lambda = 0) only.

Instance details

Defined in DataFrame.Segmented