# Bag Of Words Stats Table Pos/Neg

Functions of this type do a lookup in a stats table trained with the statsTable.bagOfWords.train procedure type and return the probability of outcome for each of the words provided as input.

## Configuration

A new function of type statsTable.bagOfWords.posneg named <id> can be created as follows:

mldb.put("/v1/functions/"+<id>, {
"type": "statsTable.bagOfWords.posneg",
"params": {
"numPos": <int>,
"numNeg": <int>,
"minTrials": <int>,
"outcomeToUse": <string>,
"statsTableFileUrl": <Url>
}
})

with the following key-value definitions for params:

Field, Type, DefaultDescription

numPos
int
50

Number of top positive words to use

numNeg
int
50

Number of top negative words to use

minTrials
int
50

Minimum number of trials a word needs to have in order to be considered

outcomeToUse
string

This must be one of the outcomes the stats table was trained with.

statsTableFileUrl
Url

URL of the model file (with extension '.st') to load. This file is created by the statsTable.bagOfWords.train procedure type.

## Input and Output Values

Functions of this type have a single input value named words which is a row.

Functions of this type have a single output value named probs which is also a row. The row will contain P(outcome | word) for each valid word given the function configuration.