models.mars()
MARS knot selection for hinge terms (Friedman’s forward pass, as R’s
Usage
models.mars(
x,
y,
weights=None,
max_terms=None,
threshold=0.001,
penalty=2.0,
min_span=None,
end_span=None,
prune=False,
family=None,
link=None
)earth with degree = 1), with an optional backward pass by GCV.
Its knots, RSS and GCV match earth’s on the Chalk portfolio, weighted and unweighted. With family the search runs on that GLM’s deviance (working response and weights at each step), which earth has no counterpart for.
Parameters
x: dict of str to list of float-
The numeric predictors, in order.
y: list of floatweights: list of float = None-
Case weights (exposure); all equal is the same as none.
max_terms: int = None-
earth’snk; by defaultmin(200, max(20, 2p)) + 1. threshold: float = 0.001-
Stop when a step adds less than this to R² (
0turns it off). penalty: float = 2.0-
GCV’s cost per knot.
min_span: int = None-
Cases between knots and free of knots at each end;
earth’s defaults by default. end_span: int = None-
Cases between knots and free of knots at each end;
earth’s defaults by default. prune: bool = False-
Run the backward pass by GCV (
pmethod = "backward"). family: str = None-
Search on this GLM’s deviance (
"poisson","gamma", …). link: str = None-
Search on this GLM’s deviance (
"poisson","gamma", …).
Returns
MarsFit
Examples
>>> x = [float(i) for i in range(60)]
>>> y = [1 + 0.5 * v + 3 * max(0.0, v - 31) for v in x]
>>> mars({"x": x}, y).knots("x")[31.0]