citrine.resources.design_space module

Resources that represent collections of design spaces.

class citrine.resources.design_space.DefaultDesignSpaceMode(value)

Bases: BaseEnumeration

The type of default design space to create.

  • ATTRIBUTE results in a product design space containing dimensions required by the predictor

  • HIERARCHICAL results in a hierarchical design space resembling the shape of training data

ATTRIBUTE = 'ATTRIBUTE'
HIERARCHICAL = 'HIERARCHICAL'
class citrine.resources.design_space.DesignSpaceCollection(project_id: UUID, session: Session)

Bases: Collection[DesignSpace]

Represents the collection of design spaces as well as the resources belonging to it.

Parameters:

project_id (UUID) – the UUID of the project

archive(uid: UUID | str) DesignSpace

Archiving a design space removes it from view, but is not a hard delete.

Parameters:

uid (Union[UUID, str]) – Unique identifier of the design space to archive

build(data: dict) DesignSpace

Build an individual design space.

convert_to_hierarchical(uid: UUID | str, *, predictor_id: UUID | str, predictor_version: int | str | None = None) HierarchicalDesignSpace

Convert an existing ProductDesignSpace into an equivalent HierarchicalDesignSpace.

A ProductDesignSpace can be mapped to a HierarchicalDesignSpace by using the associated predictor and its training data to infer the shape of the hierarchical design space. Constraints are then transferred from the product design space to the appropriate node in the hierarchical design space.

Parameters:
  • uid (Union[str, UUID]) – UUID of the existing product design space to convert to a hierarchical version

  • predictor_id (Union[UUID, str]) – UUID of a predictor associated with the design space.

  • predictor_version (Optional[Union[int, str]]) – Version of the predictor to use. Defaults to the most recent version.

Returns:

  • A HierarchicalDesignSpace modeled on the

  • existing ProductDesignSpace.

create_default(*, predictor_id: UUID, predictor_version: int | str | None = None, mode: DefaultDesignSpaceMode = DefaultDesignSpaceMode.ATTRIBUTE, include_ingredient_fraction_constraints: bool = False, include_label_fraction_constraints: bool = False, include_label_count_constraints: bool = False, include_parameter_constraints: bool = False) DesignSpace

Create a default design space for a predictor.

This method will return an unregistered design space for all inputs that are not responses of the predictor. The design space will contain a FormulationDesignSpace for each formulation input. Dimensions are constructed for all other inputs. A ContinuousDimension is constructed for each input that corresponds to a RealDescriptor. An EnumeratedDimension is constructed for all other inputs. Enumerated values taken from the allowed categories of a CategoricalDescriptor or from the unique values from the training data for all other descriptors.

Parameters:
  • predictor_id (UUID) – UUID of the predictor used to construct the design space

  • predictor_version (Optional[Union[int, str]]) – Version of the predictor used to construct the design space

  • mode (DefaultDesignSpaceMode) – The type of default design space to produce. Defaults to DefaultDesignSpaceMode.ATTRIBUTE.

  • include_ingredient_fraction_constraints (bool) – Whether to include constraints on ingredient fractions based on the training data. Defaults to False.

  • include_label_fraction_constraints (bool) – Whether to include constraints on label fractions based on the training data. Defaults to False.

  • include_label_count_constraints (bool) – Whether to include constraints on labeled ingredient counts based on the training data. Defaults to False.

  • include_parameter_constraints (bool) – Whether to include constraints on all other inputs based on the training data. Defaults to False.

Returns:

Default design space

Return type:

DesignSpace

delete(uid: UUID | str)

Design Spaces cannot be deleted at this time.

get(uid: UUID | str) ResourceType

Get a particular element of the collection.

list(*, per_page: int = 100) Iterator[ResourceType]

Paginate over the elements of the collection.

Leaving page and per_page as default values will yield all elements in the collection, paginating over all available pages.

Parameters:

per_page (int, optional) – Max number of results to return per page. Default is 100. This parameter is used when making requests to the backend service. If the page parameter is specified it limits the maximum number of elements in the response.

Returns:

An iterator that can be used to loop over all the resources in this collection. Use list() to force evaluation of all results into an in-memory list.

Return type:

Iterator[ResourceType]

register(design_space: DesignSpace) DesignSpace

Create a new design space.

restore(uid: UUID | str) DesignSpace

Restore an archived design space.

Parameters:

uid (Union[UUID, str]) – Unique identifier of the design space to restore

update(design_space: DesignSpace) DesignSpace

Update and validate an existing DesignSpace.