corneto.data.Sample#
- class corneto.data.Sample(features=<factory>)#
Bases:
object
Represents a sample as a collection of features. Each feature is stored as a value. If a feature needs metadata, it should be represented as a dict with a mandatory “value” key.
Methods
__init__
([features])add_feature
(name, value)Adds a feature to this sample.
filter
(predicate)Filters the features and returns a new dict containing only those that satisfy the predicate.
filter_by
(key, value)Returns features that have metadata matching the given key and value.
filter_values
(predicate[, value_key])Filters the features and returns a new dict containing only those that satisfy the predicate.
filter_values_by
(key, value[, value_key])Returns features that have metadata matching the given key and value.
get_value
(feature_name[, key])Returns the value of a specific feature.
get_values
([key])Returns a dictionary of feature names and their values.
Attributes
- add_feature(name, value)#
Adds a feature to this sample. Raises an error if the feature already exists.
- get_values(key='value')#
Returns a dictionary of feature names and their values.
- filter_values(predicate, value_key='value')#
Filters the features and returns a new dict containing only those that satisfy the predicate.
- filter_values_by(key, value, value_key='value')#
Returns features that have metadata matching the given key and value.
- get_value(feature_name, key='value')#
Returns the value of a specific feature.
- filter(predicate)#
Filters the features and returns a new dict containing only those that satisfy the predicate.