TrainingData#
A TrainingData
instance is a
collection of TrainingDataPart
instances representing a prediction 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
TrainingData
object.- Parameters:
name (str) – Name to give the new
TrainingData
object.project (Project | str | None) –
Project
object to associate the data with.
- Returns:
Created
TrainingData
object.- Return type:
- delete(training_data: TrainingData | str) None #
Delete a
TrainingData
object and its associated parts from the server.- Parameters:
training_data (TrainingData | str) – ID or
model
object of theTrainingData
object.
- get(id) TrainingData #
Get a specific
TrainingData
object from the server.
- list() List[TrainingData] #
List all
TrainingData
objects on the server.- Returns:
List of all
TrainingData
objects on the server.- Return type:
- upload_folder(training_data: TrainingData | str, folder_path: Path | str | PathLike) List[TrainingDataPart] #
Upload all files in a folder to a
TrainingData
object.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
TrainingData
object.- Parameters:
training_data (TrainingData | str) – ID or
model
object of the training data to add the part to.file (Path | str | PathLike | Tuple[BinaryIO | RawIOBase | BufferedIOBase | Path | str | PathLike, str]) –
NamedFile
to upload.monitor_callback (Callable[[int], None] | None) – Optional callback for monitoring the progress of the upload. For more information, see the
MonitorCallback
object.
- Returns:
Added
TrainingDataPart
object.- 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
model
of the project to check theProject
object for, or its ID.- Returns:
The
SubsetEnum
of the subset to which theTrainingData
belongs to if any,None
otherwise. (e.g. <SubsetEnum.TEST: ‘Test’>)- Return type:
SubsetEnum | None
- remove_from_project(project: Project | str)#
Remove the training data from a
Project
object.- Parameters:
project (Project | str) – ID or
model
of 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
TrainingData
instance.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
False
once 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
parts
objects in the training data.