mlflow/mlflow · error · MlflowException

INVALID_PARAMETER_VALUE

INVALID_PARAMETER_VALUE

Error message

Unrecognized predictions format: '{predictions_format}'

What it means

`PredictionsResponse.get()` supports converting predictions only to 'pandas' or 'ndarray' format. Any other `predictions_format` value raises INVALID_PARAMETER_VALUE.

Source

Thrown at mlflow/deployments/__init__.py:72

        """
        import numpy as np
        import pandas as pd
        from pandas.core.dtypes.common import is_list_like

        if predictions_format == "dataframe":
            predictions = self["predictions"]
            if isinstance(predictions, str):
                return pd.DataFrame(data=[predictions])
            if isinstance(predictions, dict) and not any(
                is_list_like(p) and getattr(p, "ndim", 1) == 1 for p in predictions.values()
            ):
                return pd.DataFrame(data=predictions, index=[0])
            return pd.DataFrame(data=predictions)
        elif predictions_format == "ndarray":
            return np.array(self["predictions"], dtype)
        else:
            raise MlflowException(
                f"Unrecognized predictions format: '{predictions_format}'",
                INVALID_PARAMETER_VALUE,
            )

    def to_json(self, path=None):
        """Get the JSON representation of the MLflow Predictions Response.

        Args:
            path: If specified, the JSON representation is written to this file path.

        Returns:
            If ``path`` is unspecified, the JSON representation of the MLflow Predictions
            Response. Else, None.

        """
        if path is not None:
            with open(path, "w") as f:
                json.dump(dict(self), f)

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Use `predictions_format='pandas'` or `predictions_format='ndarray'` exactly
  2. Fix the typo if 'numpy' was intended — the correct value is 'ndarray'
  3. Call `.to_dict()`/`.to_json()` if you need raw JSON instead of the typed converters

Example fix

// before
resp.get(predictions_format='numpy')
// after
resp.get(predictions_format='ndarray')
Defensive patterns

Strategy: validation

Validate before calling

VALID = {'pandas', 'ndarray'}
assert predictions_format in VALID, f'unsupported format: {predictions_format}'

Type guard

def is_valid_predictions_format(fmt) -> bool:
    return fmt in ('pandas', 'ndarray')

Try / catch

try:
    preds = response.get(predictions_format=fmt)
except MlflowException as e:
    if 'Unrecognized predictions format' in str(e):
        preds = response.get(predictions_format='pandas')
    else:
        raise

Prevention

When it happens

Trigger: Calling `mlflow.deployments.predict(...)` or a `PredictionsResponse`'s `get(predictions_format=...)` with a format string other than 'pandas' or 'ndarray' (e.g. 'numpy', 'df', 'json').

Common situations: Typos like 'numpy' instead of 'ndarray'; passing None/other objects where a string format is expected; copying examples from other libraries' client APIs.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/2d9cc0b0333be202. Report an issue: GitHub.