anml.data#
anml.data.prototype#
- class anml.data.prototype.DataPrototype(components)[source]#
Bases:
object
A set of components for easy validation and accessing the data frame. The class will automatically render the values in the components as the attributes of the class with the keys as the names of the attributes. For an example please check the class
anml.data.example.DataExample
.- Parameters
components (Dict[str, anml.data.component.Component]) – Components to validate and access data in a data frame.
- property components#
Components to validate and access data in a data frame.
anml.data.component#
- class anml.data.component.Component(key, validators=None, default_value=None)[source]#
Bases:
object
Component class validates, accesses and stores data from a data frame.
- Parameters
key (str) – Key to access the column in a data frame.
validators (Optional[List[anml.data.validator.Validator]]) – A list of validators to check the corresponding column value in a data frame. Default to None.
default_value (Optional[Any]) – A default value used to create the column when the key doesn’t exist in the data frame. If default_value=None and the data frame doesn’t contain the key, a KeyError will be raised. Default to None.
- property value#
Stored value from a data frame. This property can only be modified through class functions.
- property key#
Key to access the column in a data frame.
- property validators#
A list of validators to check the corresponding column value in a data frame.
anml.data.validator#
- class anml.data.validator.Validator[source]#
Bases:
abc.ABC
Validator class validates the data satisfy the condition. The instance is callable. And if the condition is not met, the call will raise value error.
- class anml.data.validator.NoNans[source]#
Bases:
anml.data.validator.Validator
Validate there is no ‘nan’s in the array.
- class anml.data.validator.Positive[source]#
Bases:
anml.data.validator.Validator
Validate there is no non-poisitive value in the array.
- class anml.data.validator.Unique[source]#
Bases:
anml.data.validator.Validator
Validate all the values in the array are unique.
anml.data.example#
- class anml.data.example.DataExample(obs, obs_se)[source]#
Bases:
anml.data.prototype.DataPrototype
An example class for simple least-square problem. And for that purpose we only need observations and their standard deviations.
- Parameters
obs (str) – The observation column name in the data frame.
obs_se (str) – The observation standard deviation column name in the data frame.