pasteur.attribute.StratifiedValue#
- class pasteur.attribute.StratifiedValue(name, head, common=None, ignore_nan=False)[source]#
A version of CategoricalValue which uses a Stratification to represent the domain knowledge of the Value.
Each unique value is mapped to a tree with nodes where the child order matters. By traversing the tree in DFS, each leaf is mapped to an integer.
Attributes
Returns the maximum height of this value.
Methods
downsample(value, height)Receives an array named value and downsamples it based on the provided height, by grouping certain values together.
get_domain(height)Returns the domain of the attribute in the given height.
get_domain_multiple(heights, vals)Returns a list of human readable values for each discrete value.
get_mapping(height)Returns a numpy array that associates discrete values with groups at the given height.
get_mapping_multiple(heights, common, vals)get_naive_mapping_multiple(heights, common, vals)Returns whether this value is ordinal, other than for the elements it shares in common with the other attributes.
prefix_rename(prefix)rename(name[, name_cnt])replace(**kwargs)upsample(value, height[, deterministic])Does the opposite of downsample.
- property domain#
- downsample(value, height)#
Receives an array named value and downsamples it based on the provided height, by grouping certain values together. The proper implementation is provided by pasteur.hierarchy.
- get_human_readable()[source]#
Returns a list of human readable values for each discrete value.
- Return type:
list[str]
- get_mapping(height)[source]#
Returns a numpy array that associates discrete values with groups at the given height.
- property height#
Returns the maximum height of this value.
-
ignore_nan:
bool#
- is_ordinal()[source]#
Returns whether this value is ordinal, other than for the elements it shares in common with the other attributes.
- Return type:
bool
-
name:
str#
- select_height()#
- Return type:
int
- upsample(value, height, deterministic=True)#
Does the opposite of downsample. If deterministic is True, for each group at a given height one of its values is chosen arbitrarily to represent all children of the group.
If deterministic is False, the group is sampled based on this Value’s histogram (not implemented in this class; see pasteur.hierarchy).