QTZPOC-20
QTZPOC-20: Add skip_predict_timestamp flag to model_config to prevent timestamp reinsertion in prediction data, and document other ad-hoc behavioral flags.
This commit is contained in:
@@ -1110,6 +1110,11 @@ Legacy MinIO object layout (relative key):
|
||||
`joblib`. The flavor is configuration, never discovered from the artifact, and there is
|
||||
no fallback between flavors: a failing loader propagates.
|
||||
|
||||
`model_config` also carries ad-hoc behavioral flags, unrelated to flavor, e.g.
|
||||
`skip_predict_timestamp` (default `False`): when `True`, `request_predict` does not reinsert the
|
||||
`timestamp` column derived from the index into the transformed data before calling predict. Full
|
||||
list: [docs/model-flavors.md § Other `model_config` flags](docs/model-flavors.md#other-model_config-flags).
|
||||
|
||||
`joblib` reads the artifact directly — download, `<artifact>/model.pkl`, `joblib.load` — and writes on
|
||||
retrain (`model.pkl` + `code/`, no `MLmodel`, so only this runtime reads it back).
|
||||
|
||||
|
||||
@@ -18,6 +18,16 @@ reads the artifact's `MLmodel` manifest to guess it.
|
||||
`predict_flavor` drives `load_predict_model` (artifact `prediction_model`); `transform_flavor` drives
|
||||
`load_transform_model` (artifact `data_model`). Both default to `sklearn` when the key is absent.
|
||||
|
||||
## Other `model_config` flags
|
||||
|
||||
Ad-hoc behavioral overrides, read directly with `.get(key, default)` — not part of the model
|
||||
document written by import (`model-import.md` § 12), and not validated against a schema:
|
||||
|
||||
| Key | Default | Effect |
|
||||
|---|---|---|
|
||||
| `skip_transform` | `False` | `fit_models` (retrain) skips calling `transform` before fitting. |
|
||||
| `skip_predict_timestamp` | `False` | `request_predict` skips reinserting the `timestamp` column (from the index) into the transformed data before calling predict. |
|
||||
|
||||
## Accepted values
|
||||
|
||||
| Flavor | Read | Write (retrain) | How it loads |
|
||||
|
||||
@@ -237,6 +237,9 @@ class MLFlow(MinioManager):
|
||||
- data (dict): Transformed data for prediction
|
||||
- model_name (str): Name of the MLFlow model to use
|
||||
- model_retention (int): Model retention period in minutes
|
||||
Optional keys (in model_config):
|
||||
- skip_predict_timestamp (bool): If True, don't reinsert the
|
||||
timestamp column from the index before predicting. Default False.
|
||||
|
||||
Returns:
|
||||
dict: Prediction results from MLFlow model
|
||||
@@ -258,10 +261,11 @@ class MLFlow(MinioManager):
|
||||
# Convert numpy.nan to None for model compatibility
|
||||
data.replace(np.nan, None, inplace=True)
|
||||
|
||||
data['timestamp'] = data.index
|
||||
data['timestamp'] = to_datetime(
|
||||
data['timestamp'], format=DATETIME_FORMAT_WITH_TZ
|
||||
).dt.strftime(DATETIME_FORMAT)
|
||||
if not model_config.get('skip_predict_timestamp', False):
|
||||
data['timestamp'] = data.index
|
||||
data['timestamp'] = to_datetime(
|
||||
data['timestamp'], format=DATETIME_FORMAT_WITH_TZ
|
||||
).dt.strftime(DATETIME_FORMAT)
|
||||
|
||||
# Request prediction from MLFlow model
|
||||
response_data = await self.model_monitoring_repository.predict(
|
||||
|
||||
Reference in New Issue
Block a user