| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- module DataFrame.Model
- data Segmented cfg = Segmented {
- segBase :: !cfg
- segOn :: !(Maybe [Text])
- segMaxCard :: !Int
- segMinRows :: !Int
- segPool :: !Double
- segmented :: cfg -> Segmented cfg
- segmentOn :: Segmented cfg -> [Text] -> Segmented cfg
- pooled :: Segmented cfg -> Double -> Segmented cfg
- data Segment model = Segment {}
- data SegmentedModel a model = SegmentedModel {
- smCatCols :: ![Text]
- smSegments :: ![Segment model]
- smFellBack :: ![([Text], Int)]
- smFallback :: !model
- smExpr :: !(Expr a)
- class Fit cfg (Expr a) => SegmentFit cfg a where
Documentation
module DataFrame.Model
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
| Show cfg => Show (Segmented cfg) Source # | |||||||||
| Eq cfg => Eq (Segmented cfg) Source # | |||||||||
| (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 # | |||||||||
Defined in DataFrame.Segmented Associated Types
| |||||||||
| type FrameReq (Segmented cfg) (Expr a) Source # | |||||||||
Defined in DataFrame.Segmented | |||||||||
| type ModelOf (Segmented cfg) (Expr a) Source # | |||||||||
Defined in DataFrame.Segmented | |||||||||
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).
One fitted segment: its categorical key, row count, and base model.
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
| (Show model, Show a) => Show (SegmentedModel a model) Source # | |||||
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 # | |||||
Defined in DataFrame.Segmented Associated Types
Methods predict :: SegmentedModel a model -> Prediction (SegmentedModel a model) Source # | |||||
| type Prediction (SegmentedModel a model) Source # | |||||
Defined in DataFrame.Segmented | |||||
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
| (Columnable a, Ord a) => SegmentFit LogisticConfig a Source # | Logistic segments support independent fitting (lambda = 0) only, for now. |
Defined in DataFrame.Segmented Methods fitSegments :: LogisticConfig -> Double -> Expr a -> [DataFrame] -> [ModelOf LogisticConfig (Expr a)] Source # | |
| SegmentFit LinearConfig Double Source # | Linear segments with exact closed-form pooling. |
Defined in DataFrame.Segmented Methods fitSegments :: LinearConfig -> Double -> Expr Double -> [DataFrame] -> [ModelOf LinearConfig (Expr Double)] Source # | |
| SegmentFit SRConfig Double Source # | Symbolic-regression segments support independent fitting (lambda = 0) only. |