cancel
Showing results for 
Search instead for 
Did you mean: 
Machine Learning
cancel
Showing results for 
Search instead for 
Did you mean: 

MLFlow Output Signature

pablobd
Contributor

I want to define the output of a MLFlow model to include a dictionary of string to float. I did this, but it doesn't work. Do you know if it's possible at all?

 

 
from mlflow.types.schema import Schema, ColSpec
 
output_schema = Schema([ ColSpec("dictionary_output", "map[string,float]") ])
1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @pablobd, The issue you’re facing might be due to the fact that MLflow’s ColSpec does not directly support a dictionary or map data type. The ColSpec class is used to specify the type and optionally the name of a single column in the data....

 

However, you can potentially work around this by having your model output a string representation of the dictionary, and then convert this string back to a dictionary in your application code. 

 

In this example, the model’s output is a JSON string, which is a string representation of the dictionary. This string can be easily converted back to a dictionary using json.loads() in your application code.

 

If you have further questions or need more help, feel free to ask!

View solution in original post

2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @pablobd, The issue you’re facing might be due to the fact that MLflow’s ColSpec does not directly support a dictionary or map data type. The ColSpec class is used to specify the type and optionally the name of a single column in the data....

 

However, you can potentially work around this by having your model output a string representation of the dictionary, and then convert this string back to a dictionary in your application code. 

 

In this example, the model’s output is a JSON string, which is a string representation of the dictionary. This string can be easily converted back to a dictionary using json.loads() in your application code.

 

If you have further questions or need more help, feel free to ask!

pablobd
Contributor

Solved with the json module that converts the dict into string, thanks! 🙂

import json

json.dumps(...)
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.