Exploring techniques for keyed prediction
In this section, we will discuss the ideas and techniques needed for keyed prediction. Keyed prediction has three main tasks that need to be performed at a high level:
- Passing keys with features from the client side
- Removing keys from the features before being passed to the model for prediction
- Tagging predictions with keys from the server side
We will discuss these three tasks in the following subsections. To describe these three steps, let’s first create a basic keyed prediction scenario using pandas and scikit-learn in the following code snippet:
- We will train a basic linear regression model with the data passed from the client. We avoid the key column during training by specifying the trainable columns in the Features array:
import pandas as pd
from sklearn.linear_model import LinearRegression
Features = ["#Bedroom", "#Bathroom"]
def train(X: pd.DataFrame, y: pd.Series):
...