TrainingData#
A TrainingData instance is a
collection of TrainingDataPart
instances representing a simulation that can be used as input for the training of models.
Directory#
- class TrainingDataDirectory#
Provides a collection of methods related to training data.
This class is accessed through
client.training_data.Example
List all of the training data:
import ansys.simai.core simai = ansys.simai.core.from_config() simai.training_data.list()
- create(name: str, project: Project | str | None = None) TrainingData#
Create a
TrainingDataobject.- Parameters:
name (str) – Name to give the new
TrainingDataobject.project (Project | str | None) –
Projectobject to associate the data with.
- Returns:
Created
TrainingDataobject.- Return type:
- delete(training_data: TrainingData | str) None#
Delete a
TrainingDataobject and its associated parts from the server.- Parameters:
training_data (TrainingData | str) – ID or
modelobject of theTrainingDataobject.
- get(id) TrainingData#
Get a specific
TrainingDataobject from the server.
- iter(filters: dict[str, Any] | list[tuple[str, Literal['EQ', 'LIKE', 'IN', 'GT', 'GTE', 'LT', 'LTE'], Any]] | list[RawSingleFilter] | None = None) SizedIterator[TrainingData]#
Iterate over all
TrainingDataobjects on the server.
- list(filters: dict[str, Any] | list[tuple[str, Literal['EQ', 'LIKE', 'IN', 'GT', 'GTE', 'LT', 'LTE'], Any]] | list[RawSingleFilter] | None = None) List[TrainingData]#
List all
TrainingDataobjects on the server.Warning
This can take a very long time, consider using
iter()instead.
- upload_folder(training_data: TrainingData | str, folder_path: Path | str | PathLike) List[TrainingDataPart]#
Upload all files in a folder to a
TrainingDataobject.This method automatically requests computation of the training data once the upload is complete unless specified otherwise.
- upload_part(training_data: TrainingData | str, file: Path | str | PathLike | Tuple[BinaryIO | RawIOBase | BufferedIOBase | Path | str | PathLike, str], monitor_callback: Callable[[int], None] | None) TrainingDataPart#
Add a part to a
TrainingDataobject.- Parameters:
training_data (TrainingData | str) – ID or
modelobject of the training data to add the part to.file (Path | str | PathLike | Tuple[BinaryIO | RawIOBase | BufferedIOBase | Path | str | PathLike, str]) –
NamedFileto upload.monitor_callback (Callable[[int], None] | None) – Optional callback for monitoring the progress of the upload. For more information, see the
MonitorCallbackobject.
- Returns:
Added
TrainingDataPartobject.- Return type:
Model#
- class TrainingData#
Provides the local representation of a training data object.
- assign_subset(project: Project | str, subset: SubsetEnum | str | None) None#
Assign the training data to a subset in relation to a given project.
- Parameters:
subset (SubsetEnum | str | None) –
SubsetEnum attribute (e.g. SubsetEnum.TRAINING) or string value (e.g. “Training”) or None to unassign. Available options: (Training, Test)
Each new training data added to the project will be set to “None” by default.
None allows for resetting the subset assignment of your training data, which will be automatically allocated in either test or training subsets upon each model building request. As a rule of thumb, 10% of all data should be allocated to the test subset.
When wanting to assign a specific subset to your training data, note that:
Each subset requires at least one data point. The training subset is used to train the model. The test subset is used for the model evaluation report but is not learned by the model. It is recommended to allocate about 10% of your data to the test subset.
- Returns:
None
- Return type:
None
- extract_data() None#
Extract or reextract the data from a training data.
Data should be extracted from a training data once all its parts have been fully uploaded. This is done automatically when using
TrainingDataDirectory.upload_folder()to create training data.Data can only be reextracted from a training data if the extraction previously failed or if new files have been added.
- get_subset(project: Project | str) SubsetEnum | None#
Get the subset that the training data belongs to, in relation to the given project.
- Parameters:
project (Project | str) – ID or
modelof the project to check theProjectobject for, or its ID.- Returns:
The
SubsetEnumof the subset to which theTrainingDatabelongs to if any,Noneotherwise. (e.g. <SubsetEnum.TEST: ‘Test’>)- Return type:
SubsetEnum | None
- remove_from_project(project: Project | str)#
Remove the training data from a
Projectobject.- Parameters:
project (Project | str) – ID or
modelof the project to remove data from.- Raises:
ansys.simai.core.errors.ApiClientError – If the data is the project’s sample.
ansys.simai.core.errors.ApiClientError – If the project is in training.
- upload_folder(folder_path: Path | str | PathLike) List[TrainingDataPart]#
Upload all the parts contained in a folder to a
TrainingDatainstance.Upon upload completion, SimAI will extract data from each part.
- upload_part(file: Path | str | PathLike | Tuple[BinaryIO | RawIOBase | BufferedIOBase | Path | str | PathLike, str], monitor_callback: Callable[[int], None] | None = None) TrainingDataPart#
Add a part to the training data.
- Parameters:
- Returns:
Created
TrainingDataPart.- Return type:
- wait(timeout: float | None = None) bool#
Wait for all jobs concerning the object to either finish or fail.
- property failure_reason#
Optional message giving the causes for why the creation of the object failed.
See also
- property has_failed#
Boolean indicating if the creation of the object failed.
See also
- property is_pending#
Boolean indicating if the object is still in creation. The value becomes
Falseonce object creation is either successful or has failed.See also
- property is_ready#
Boolean indicating if the object has finished creating without error.
See also
- property parts: List[TrainingDataPart]#
List of all
partsobjects in the training data.