plaid.problem_definition¶
plaid.problem_definition
¶
Implementation of the ProblemDefinition class.
plaid.problem_definition.ProblemDefinition
¶
Defines the input and output features for a machine learning problem.
plaid.problem_definition.ProblemDefinition.from_path
classmethod
¶
Load and validate one problem definition from a YAML file.
Parameters:
-
path(str | Path) –Path to the problem-definition YAML file. If no suffix is provided,
.yamlis appended.
Returns:
-
ProblemDefinition–Validated problem definition instance.
Raises:
-
FileNotFoundError–If the resolved YAML file does not exist.
-
IsADirectoryError–If
pathpoints to a directory.
Source code in plaid/problem_definition.py
plaid.problem_definition.ProblemDefinition.normalize_input_features
classmethod
¶
Normalize input features identifiers by ensuring they are unique and sorted.
Source code in plaid/problem_definition.py
plaid.problem_definition.ProblemDefinition.normalize_output_features
classmethod
¶
Normalize output features identifiers by ensuring they are unique and sorted.
Source code in plaid/problem_definition.py
plaid.problem_definition.ProblemDefinition.__setattr__
¶
Override attribute setting to log warnings when split fields are replaced.
Source code in plaid/problem_definition.py
plaid.problem_definition.ProblemDefinition.add_input_features
¶
Add input features identifiers to the problem.
Parameters:
-
inputs(Sequence[str] or str) –A list of or a single input feature identifier to add.
Raises:
-
ValueError–If some :code:
inputsare duplicated.
Example
.. code-block:: python
from plaid.problem_definition import ProblemDefinition
problem = ProblemDefinition(
input_features=["angle"],
output_features=["pressure"],
train_split={"train": "all"},
test_split={"test": "all"},
)
input_features = ['omega', 'pressure']
problem.add_input_features(input_features)
# or for a single feature
problem.add_input_features("angle")
Source code in plaid/problem_definition.py
plaid.problem_definition.ProblemDefinition.add_output_features
¶
Add output features identifiers to the problem.
Parameters:
-
outputs(Sequence[str] or str) –A list of or a single input feature identifier to add.
Raises:
-
ValueError–If some :code:
outputsare duplicated.
Example
.. code-block:: python
from plaid.problem_definition import ProblemDefinition
problem = ProblemDefinition(
input_features=["angle"],
output_features=["pressure"],
train_split={"train": "all"},
test_split={"test": "all"},
)
output_features = ['omega', 'pressure']
problem.add_output_features(output_features)
# or for a single feature
problem.add_output_features("angle")
Source code in plaid/problem_definition.py
plaid.problem_definition.ProblemDefinition.save_to_file
¶
Save problem information, inputs, outputs, and split to the specified file in YAML format.
Parameters:
-
path(Union[str, Path]) –The filepath where the problem information will be saved.
Example
.. code-block:: python
from plaid import ProblemDefinition
problem = ProblemDefinition(
input_features=["angle"],
output_features=["pressure"],
train_split={"train": "all"},
test_split={"test": "all"},
)
problem.save_to_file("/path/to/save_file")