{"record":{"id":"89ba939a4c5a0d9a","repo":"mlflow/mlflow","slug":"unsupported-data-type","errorCode":null,"errorMessage":"Unsupported data type.","messagePattern":"Unsupported data type\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mlflow/data/evaluation_dataset.py","lineNumber":155,"sourceCode":"        else:\n            data = data.applymap(_hash_array_like_element_as_bytes)\n        return _hash_uint64_ndarray_as_bytes(pd.util.hash_pandas_object(data))\n    elif isinstance(data, np.ndarray) and len(data) > 0 and isinstance(data[0], list):\n        # convert numpy array of lists into numpy array of the string representation of the lists\n        # because lists are not hashable\n        hashable = np.array(str(val) for val in data)\n        return _hash_ndarray_as_bytes(hashable)\n    elif isinstance(data, np.ndarray) and len(data) > 0 and isinstance(data[0], np.ndarray):\n        # convert numpy array of numpy arrays into 2d numpy arrays\n        # because numpy array of numpy arrays are not hashable\n        hashable = np.array(data.tolist())\n        return _hash_ndarray_as_bytes(hashable)\n    elif isinstance(data, np.ndarray):\n        return _hash_ndarray_as_bytes(data)\n    elif isinstance(data, list):\n        return _hash_ndarray_as_bytes(np.array(data))\n    else:\n        raise ValueError(\"Unsupported data type.\")\n\n\ndef _gen_md5_for_arraylike_obj(md5_gen, data):\n    \"\"\"\n    Helper method to generate MD5 hash array-like object, the MD5 will calculate over:\n     - array length\n     - first NUM_SAMPLE_ROWS_FOR_HASH rows content\n     - last NUM_SAMPLE_ROWS_FOR_HASH rows content\n    \"\"\"\n    len_bytes = _hash_uint64_ndarray_as_bytes(np.array([len(data)], dtype=\"uint64\"))\n    md5_gen.update(len_bytes)\n    if len(data) < EvaluationDataset.NUM_SAMPLE_ROWS_FOR_HASH * 2:\n        md5_gen.update(_hash_array_like_obj_as_bytes(data))\n    else:\n        if isinstance(data, pd.DataFrame):\n            # Access rows of pandas Df with iloc\n            head_rows = data.iloc[: EvaluationDataset.NUM_SAMPLE_ROWS_FOR_HASH]\n            tail_rows = data.iloc[-EvaluationDataset.NUM_SAMPLE_ROWS_FOR_HASH :]","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/data/evaluation_dataset.py#L137-L173","documentation":"MLflow computes an MD5 digest of evaluation datasets by hashing array-like inputs (pandas DataFrames, numpy arrays, or lists). If the data object passed to the internal hashing helper is none of these supported types, a plain ValueError('Unsupported data type.') is raised from _hash_array_like_obj_as_bytes.","triggerScenarios":"Calling mlflow.models.evaluate() (or creating an EvaluationDataset whose digest must be computed) with data/targets that is not a pandas DataFrame, numpy ndarray, or list — e.g. a dict, tuple, pandas Series, list of dicts, ragged list, or numpy object array whose conversion to np.array fails or yields an unsupported type.","commonSituations":"Passing a pandas Series or a dict as targets; passing a list of unequal-length lists (np.array raises inside); using sparse/scipy arrays; forgetting to convert a loader's output (e.g. sklearn Bunch, torch tensor) to numpy before evaluate().","solutions":["Convert the input to a supported type: np.asarray(obj) for arrays/targets or pd.DataFrame(obj) for tabular data before calling evaluate().","If data is a list of lists, make all elements the same length so np.array(data) succeeds.","Check types at the call site with isinstance(data, (np.ndarray, list, pd.DataFrame)) and handle the else branch explicitly.","For non-numeric containers like list of dicts, build a DataFrame with pd.json_normalize first."],"exampleFix":"// before\nmlflow.models.evaluate(model, data=X_tuple, targets=y_series)\n// after\nimport numpy as np\nmlflow.models.evaluate(\n    model,\n    data=np.asarray(X_tuple),\n    targets=np.asarray(y_series),\n)","handlingStrategy":"type-guard","validationCode":"def check_hashable_input(data, targets=None):\n    import pandas as pd, numpy as np\n    ok = lambda o: isinstance(o, (pd.DataFrame, np.ndarray, list))\n    if not ok(data):\n        raise TypeError(f\"data must be DataFrame/ndarray/list, got {type(data)}\")\n    if targets is not None and not ok(targets):\n        raise TypeError(f\"targets must be DataFrame/ndarray/list, got {type(targets)}\")","typeGuard":"function isSupportedArrayLike(x) { return x instanceof pd.DataFrame || x instanceof np.ndarray || Array.isArray(x); }","tryCatchPattern":"try:\n    mlflow.models.evaluate(model, data=data, targets=targets)\nexcept ValueError as e:\n    if \"Unsupported data type\" in str(e):\n        data, targets = np.asarray(data), np.asarray(targets)\n        mlflow.models.evaluate(model, data=data, targets=targets)\n    else:\n        raise","preventionTips":["Convert all inputs with np.asarray()/pd.DataFrame() immediately before evaluate().","Avoid dict/tuple/Series/tensor inputs to evaluate(); MLflow only hashes DataFrame, ndarray, and list.","Assert isinstance(data, (np.ndarray, list, pd.DataFrame)) at the top of your eval script."],"tags":["python","mlflow","type-error","evaluation"],"backgroundTag":"unsupported-data-type","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}