The predict is used for predicting field features
The predict API is used to predict the likelihood of a feature given a hypothesis. For example, if you know the previous product, you may try to predict the user's next query.
/api/v1/_predict
{
"from" : From,
"where" : null | Proposition,
"predict" : PropositionSet,
"exclusiveness" : null | boolean,
"select" : null | Selection,
"offset" : null | long,
"limit" : null | long
}
Predict the operation type, which the user wants the system to do
POST /api/v1/_predict
{
"from" : "messages",
"where": {
"message" : "Show me the laptops"
},
"predict" : "operation",
"limit" : 3
}
{
"offset" : 0,
"total" : 6,
"hits" : [ {
"$p" : 0.4728461980747268,
"field" : "operation",
"feature" : "show"
}, {
"$p" : 0.2871113675960302,
"field" : "operation",
"feature" : "recommend"
}, {
"$p" : 0.10464336838183909,
"field" : "operation",
"feature" : "buy"
} ]
}
You can select the returned fields, and provide explanations for the results with select- expression
POST /api/v1/_predict
{
"from" : "impressions",
"where": {
"customer" : 5
},
"predict" : "query",
"select" : ["$p", "feature", "$why"],
"limit" : 1
}
The results now omit 'field' field, and include explanations. Note the explanation format. Explanation contains essentiall 3 different components for an estimate of form p(X_i|A, B, C):
The normalizer of form 1 / sum((p(X_0) + p(X_1) + ...))
The base probability p(X)
And probability lifts. A probability lift (p(A|X) / p(A)) tells essentially that how much more likely the X (e.g. click) is on condition A (product has 5 star review. For example: the lift may say a product is clicked with 2.3x likelihood (or 130% higher likelihood), when it has 5 stars.
{
"offset" : 0,
"total" : 16,
"hits" : [ {
"$p" : 0.2132183405811782,
"feature" : "best",
"$why" : {
"type" : "product",
"factors" : [ {
"type" : "normalizer",
"value" : 0.5461266221766155
}, {
"type" : "baseP",
"value" : 0.1798780487804878
}, {
"type" : "relatedVariableLift",
"variable" : "customer:5",
"value" : 2.3999899776609483
}, {
"type" : "relatedVariableLift",
"variable" : "customer.tags:nyc",
"value" : 0.8849735066158054
} ]
}
} ]
}
You can predict also through the links
POST /api/v1/_predict
{
"from" : "messages",
"where": {
"message" : "Show me the laptops"
},
"predict" : "product.tags",
"limit" : 1
}
{
"offset" : 0,
"total" : 9,
"hits" : [ {
"$p" : 0.2464245064165069,
"field" : "product.tags",
"feature" : "premium"
} ]
}