Skip to content

[BUG] numpy.float64 values in prediction results cause JSON serialization failure #401

@Abiram08

Description

@Abiram08

Describe the bug
In src/sktime_mcp/runtime/executor.py line 171, predictions are
returned via .to_dict() without converting numpy types to Python
native types. This causes JSON serialization to fail in MCP responses
since numpy.float64 is not JSON serializable.

Location
src/sktime_mcp/runtime/executor.py:171

Minimal reproduction
Run any fit_predict call and inspect the returned dict — values will
be numpy.float64 instead of Python float.

Expected
Prediction values should be Python native float.

Actual
Prediction values are numpy.float64, which fails JSON serialization.

Proposed fix
Convert values at dict construction:
result = {str(k): float(v) if hasattr(v, 'item') else v
for k, v in predictions_copy.to_dict().items()}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions