gemd.entity.value.discrete_categorical module
Discrete distribution across several categories.
- class gemd.entity.value.discrete_categorical.DiscreteCategorical(probabilities: Optional[Union[str, Mapping[str, float]]] = None)
Bases:
CategoricalValue
Distribution over a discrete set of categories.
- Parameters
probabilities (str or Map[str, float]) –
The categories and their probabilities.
If a string is provided, that string corresponds to the only category and is given a probability of 1.0
If a dictionary is provided, then each key is a category and its value is the probability of that category. The probabilities must sum to 1.0.
- as_dict() Dict[str, Any]
Convert the object to a dictionary.
- Returns
A dictionary representation of the object, where the keys are its fields.
- Return type
dict
- static build(d: Mapping[str, Any]) DictSerializableType
Build an object from a JSON dictionary.
This differs from from_dict in that the values themselves may also be dictionaries corresponding to serialized DictSerializable objects.
- Parameters
d (dict) – The object as a serialized dictionary.
- Returns
The deserialized object.
- Return type
- dump() Dict[str, Any]
Convert the object to a JSON dictionary, so that every entry is serialized.
Uses the json encoder client, so objects with uids are converted to LinkByUID dictionaries.
- Returns
A string representation of the object as a dictionary.
- Return type
str
- classmethod from_dict(d: Mapping[str, Any]) DictSerializableType
Reconstitute the object from a dictionary.
- Parameters
d (dict) – The object as a dictionary of key-value pairs that correspond to the object’s fields.
- Returns
The deserialized object.
- Return type
- property probabilities: Mapping[str, float]
Get the map from categories to probabilities.
- skip = {}
- typ = 'discrete_categorical'