## models.mars()


MARS knot selection for hinge terms (Friedman's forward pass, as R's


Usage


``` python
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](risk.Distortion.md#prospicio.risk.Distortion.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 float`  

`weights: list of float = None`  
Case weights (exposure); all equal is the same as none.

`max_terms: int = None`  
`earth`'s `nk`; by default `min(200, max(20, 2p)) + 1`.

`threshold: float = ``0.001`  
Stop when a step adds less than this to R² (`0` turns 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

``` python
>>> 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\]
