loaders ¶
Loaders serve as interfaces between the CSV master class and custom methods.
Mainly, three types of custom methods are supported: - Encoders: methods for encoding data before it is fed into the model - Data transformers: methods for transforming data (i.e. augmenting, noising...) - Splitters: methods for splitting data into train, validation and test sets
Loaders are built from an input config YAML file which format is described in the documentation, you can find an example here: tests/test_data/dna_experiment/dna_experiment_config_template.yaml
Classes:
-
EncoderLoader
–Class for loading encoders from a config file.
-
SplitLoader
–Class for loading splitters from a config file.
-
TransformLoader
–Class for loading transformations from a config file.
EncoderLoader ¶
Class for loading encoders from a config file.
Parameters:
Methods:
-
get_encoder
–Gets an encoder object from the encoders module and initializes it with the given parameters.
-
get_function_encode_all
–Gets the encoding function for a specific field.
-
initialize_column_encoders_from_config
–Build the loader from a config dictionary.
-
set_encoder_as_attribute
–Sets the encoder as an attribute of the loader.
Source code in src/stimulus/data/loaders.py
24 25 26 27 28 29 30 |
|
get_encoder ¶
Gets an encoder object from the encoders module and initializes it with the given parameters.
Parameters:
-
encoder_name
(str
) –The name of the encoder to get
-
encoder_params
(dict
, default:None
) –The parameters for the encoder
Returns:
-
Any
(Any
) –The encoder function for the specified field and parameters
Source code in src/stimulus/data/loaders.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
get_function_encode_all ¶
Gets the encoding function for a specific field.
Parameters:
-
field_name
(str
) –The field name to get the encoder for
Returns:
-
Any
(Any
) –The encode_all function for the specified field
Source code in src/stimulus/data/loaders.py
42 43 44 45 46 47 48 49 50 51 |
|
initialize_column_encoders_from_config ¶
initialize_column_encoders_from_config(
column_config: YamlColumns,
) -> None
Build the loader from a config dictionary.
Parameters:
-
column_config
(YamlColumns
) –Configuration dictionary containing field names (column_name) and their encoder specifications.
Source code in src/stimulus/data/loaders.py
32 33 34 35 36 37 38 39 40 |
|
set_encoder_as_attribute ¶
set_encoder_as_attribute(
field_name: str, encoder: AbstractEncoder
) -> None
Sets the encoder as an attribute of the loader.
Parameters:
-
field_name
(str
) –The name of the field to set the encoder for
-
encoder
(AbstractEncoder
) –The encoder to set
Source code in src/stimulus/data/loaders.py
81 82 83 84 85 86 87 88 |
|
SplitLoader ¶
Class for loading splitters from a config file.
Parameters:
Methods:
-
get_function_split
–Gets the function for splitting the data.
-
get_splitter
–Gets a splitter object from the splitters module.
-
initialize_splitter_from_config
–Build the loader from a config dictionary.
-
set_splitter_as_attribute
–Sets the splitter as an attribute of the loader.
Source code in src/stimulus/data/loaders.py
184 185 186 187 188 189 190 |
|
get_function_split ¶
get_function_split() -> Any
Gets the function for splitting the data.
Returns:
-
Any
(Any
) –The split function for the specified method
Raises:
-
AttributeError
–If splitter hasn't been initialized using initialize_splitter_from_config()
Source code in src/stimulus/data/loaders.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
get_splitter ¶
Gets a splitter object from the splitters module.
Parameters:
-
splitter_name
(str
) –The name of the splitter to get
-
splitter_params
(Optional[dict]
, default:None
) –Parameters for the splitter
Returns:
-
Any
(Any
) –The splitter function for the specified splitter
Source code in src/stimulus/data/loaders.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
initialize_splitter_from_config ¶
initialize_splitter_from_config(
split_config: YamlSplit,
) -> None
Build the loader from a config dictionary.
Parameters:
-
split_config
(YamlSplit
) –Configuration dictionary containing split configurations.
Source code in src/stimulus/data/loaders.py
238 239 240 241 242 243 244 245 |
|
set_splitter_as_attribute ¶
set_splitter_as_attribute(splitter: Any) -> None
Sets the splitter as an attribute of the loader.
Parameters:
-
splitter
(Any
) –The splitter to set
Source code in src/stimulus/data/loaders.py
230 231 232 233 234 235 236 |
|
TransformLoader ¶
Class for loading transformations from a config file.
Parameters:
Methods:
-
get_data_transformer
–Gets a transformer object from the transformers module.
-
initialize_column_data_transformers_from_config
–Build the loader from a config dictionary.
-
set_data_transformer_as_attribute
–Sets the data transformer as an attribute of the loader.
Source code in src/stimulus/data/loaders.py
94 95 96 97 98 99 100 |
|
get_data_transformer ¶
get_data_transformer(
transformation_name: str,
transformation_params: Optional[dict] = None,
) -> Any
Gets a transformer object from the transformers module.
Parameters:
-
transformation_name
(str
) –The name of the transformer to get
-
transformation_params
(Optional[dict]
, default:None
) –Parameters for the transformer
Returns:
-
Any
(Any
) –The transformer function for the specified transformation
Source code in src/stimulus/data/loaders.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
initialize_column_data_transformers_from_config ¶
initialize_column_data_transformers_from_config(
transform_config: YamlTransform,
) -> None
Build the loader from a config dictionary.
Parameters:
-
transform_config
(YamlTransform
) –Configuration dictionary containing transforms configurations.
Example
Given a YAML config like:
transforms:
transformation_name: noise
columns:
- column_name: age
transformations:
- name: GaussianNoise
params:
std: 0.1
- column_name: fare
transformations:
- name: GaussianNoise
params:
std: 0.1
The loader will: 1. Iterate through each column (age, fare) 2. For each transformation in the column: - Get the transformer (GaussianNoise) with its params (std=0.1) - Set it as an attribute on the loader using the column name as key
Source code in src/stimulus/data/loaders.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
set_data_transformer_as_attribute ¶
Sets the data transformer as an attribute of the loader.
Parameters:
-
field_name
(str
) –The name of the field to set the data transformer for
-
data_transformer
(Any
) –The data transformer to set
Source code in src/stimulus/data/loaders.py
130 131 132 133 134 135 136 137 138 139 140 141 142 |
|