aPriori.NN.TrainingBuilder¶
- class aPriori.NN.TrainingBuilder(*args, **kwargs)¶
Bases:
dictDescription:¶
A dictionary-like class that builds and manages a collection of VectorScaler instances for training purposes.
This class includes methods to add, configure, and save/load multiple VectorScaler objects, and allows batch scaling of data based on a specified Field3D input.
Attributes:¶
state_dict (dict): A dictionary containing the state of all scalers in the TrainingBuilder.
Methods:¶
- get_subset(keys):
Return a subset of the TrainingBuilder based on the specified keys.
- __setitem__(key, value):
Set an item in the TrainingBuilder with key and value type validation.
- build_x(field):
Construct a feature matrix by transforming data from a Field3D instance.
- fit(field):
Fit each VectorScaler in the TrainingBuilder to the corresponding data in the Field3D.
- load(file_path):
Load the state of each scaler from a JSON file and reinitialize the TrainingBuilder.
- save(file_path):
Save the current state of the TrainingBuilder to a JSON file.
- state_dict:
Return the current state of the TrainingBuilder, including all scaler states.
- __str__():
Return a string representation of the TrainingBuilder.
- get_subset(keys)¶
Return a subset of the TrainingBuilder based on the specified keys.
Parameters:¶
- keys (list):
The keys to include in the subset.
Returns:¶
- :
- TrainingBuilder:
A new TrainingBuilder containing only the specified keys.
- add(variable, *args, **kwargs)¶
Add a new VectorScaler to the TrainingBuilder.
Parameters:¶
Raises:¶
- KeyError:
If the specified variable already exists in the TrainingBuilder.
- build_x(field)¶
Construct a feature matrix by transforming data from a Field3D instance.
Parameters:¶
field (Field3D): The input field containing data to scale.
Returns:¶
- :
np.ndarray: A 2D array containing the scaled data for all variables in the TrainingBuilder.
Raises:¶
KeyError: If the field is not an instance of Field3D.
- fit(field)¶
Fit each VectorScaler in the TrainingBuilder to the corresponding data in the Field3D or list of Field3D objects.
Parameters:¶
field (Field3D or list of Field3D): The field(s) with data to fit each scaler.
- load(file_path)¶
Load the state of a previously saved object from a JSON file and reinitialize the TrainingBuilder.
Parameters:¶
file_path (str): The path to the JSON file to load.
Raises:¶
ValueError: If the file is not a valid JSON file.