Source code for schrodinger.application.matsci.mlearn.sklearn_json.common
"""
Module for serializing and deserializing models common in various contexts
Copyright Schrodinger, LLC. All rights reserved.
"""
import numpy as np
[docs]def serialize_params_random_state(params_dict):
if isinstance(params_dict['random_state'], np.random.RandomState):
state = list(params_dict['random_state'].get_state())
state[1] = state[1].tolist()
params_dict['random_state'] = state
[docs]def deserialize_params_random_state(params_dict):
if isinstance(params_dict['random_state'], list):
state = np.random.RandomState()
state.set_state(params_dict['random_state'])
params_dict['random_state'] = state