Created
May 29, 2019 07:59
-
-
Save lorey/c14472e68ccf3320277f9e144582dc6e to your computer and use it in GitHub Desktop.
Function to flatten hierarchical parameters when training a pandas pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hierarchical_to_flattened_parameters(parameters_dict): | |
""" | |
Flatten an hierarchical dict to an sklearn parameter set. | |
:param parameters_dict: hierarchical dict | |
:return: flattened dict | |
""" | |
return json_normalize(parameters_dict, sep='__').to_dict(orient='records')[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment