def __init__(self, features_dict): self.features_dict = features_dict self._check_schema_version() self.entityset = deserialize_es(features_dict["entityset"]) self._deserialized_features = {} # name -> feature primitive_deserializer = PrimitivesDeserializer() primitive_definitions = features_dict["primitive_definitions"] self._deserialized_primitives = { k: primitive_deserializer.deserialize_primitive(v) for k, v in primitive_definitions.items() }
def test_primitive_serialization(universal_sentence_encoder): sentences = pd.Series([ "", "I like to eat pizza", "The roller coaster was built in 1885.", "When will humans go to mars?", "Mitochondria is the powerhouse of the cell", ]) serialized_primitive = serialize_primitive(universal_sentence_encoder) deserializer = PrimitivesDeserializer() deserialized_primitive = deserializer.deserialize_primitive( serialized_primitive) a = pd.DataFrame(deserialized_primitive(sentences)) a = a.mean().round(7).to_numpy() b = np.array([-0.0007475, 0.0032088, 0.0018552, 0.0008256, 0.0028342]) np.testing.assert_array_almost_equal(a, b)