## models.Terms


The terms of a model: an intercept, numeric columns and factors.


Usage


``` python
models.Terms()
```


Build them up, then [fit](risk.Gpd.md#prospicio.risk.Gpd.fit) them to training data to learn the factor levels; the result builds the same design matrix on any data.


## Examples

``` python
>>> from prospicio.models import Terms
>>> data = {"age": [30.0, 45.0, 60.0], "region": ["N", "S", "W"]}
>>> coding = Terms().intercept().numeric("age").factor("region").fit(data)
>>> coding.names
```

\['(Intercept)', 'age', 'region\[S\]', 'region\[W\]'\]


## Methods

| Name | Description |
|----|----|
| [factor()](#factor) | Adds a factor in treatment coding. |
| [fit()](#fit) | Learns factor levels from training data. |
| [intercept()](#intercept) | Adds an intercept. |
| [numeric()](#numeric) | Adds a numeric column. |

------------------------------------------------------------------------


#### factor()


Adds a factor in treatment coding.


Usage


``` python
factor(name, reference=None)
```


##### Parameters


`name: str`  

`reference: str = None`  
Reference level; the first in sorted order by default.


##### Returns


`Terms`  


------------------------------------------------------------------------


#### fit()


Learns factor levels from training data.


Usage


``` python
fit(data)
```


##### Parameters


`data: dict of str to list`  
Numeric columns as lists of numbers, factors as lists of strings.


##### Returns


`Coding`  


##### Raises


`ValueError`  
If a column is missing or has the wrong kind.


------------------------------------------------------------------------


#### intercept()


Adds an intercept.


Usage


``` python
intercept()
```


##### Returns


`Terms`  


------------------------------------------------------------------------


#### numeric()


Adds a numeric column.


Usage


``` python
numeric(name)
```


##### Parameters


`name: str`  


##### Returns


`Terms`
