Ontology

class labelbox.schema.ontology.FeatureSchema(client, field_values)[source]

Bases: DbObject

class labelbox.schema.ontology.Ontology(*args, **kwargs)[source]

Bases: DbObject

An ontology specifies which tools and classifications are available to a project. This is read only for now. .. attribute:: name

type:

str

description
Type:

str

updated_at
Type:

datetime

created_at
Type:

datetime

normalized
Type:

json

object_schema_count
Type:

int

classification_schema_count
Type:

int

projects

ToMany relationship to Project

Type:

Relationship

created_by

ToOne relationship to User

Type:

Relationship

classifications() List[Classification | PromptResponseClassification][source]

Get list of classifications in an Ontology.

tools() List[Tool][source]

Get list of tools (AKA objects) in an Ontology.

class labelbox.schema.ontology.OntologyBuilder(tools: ~typing.List[~labelbox.schema.ontology.Tool] = <factory>, classifications: ~typing.List[~labelbox.schema.ontology.Classification | ~labelbox.schema.ontology.PromptResponseClassification] = <factory>)[source]

Bases: object

A class to help create an ontology for a Project. This should be used for making Project ontologies from scratch. OntologyBuilder can also pull from an already existing Project’s ontology.

There are no required instantiation arguments.

To create an ontology, use the asdict() method after fully building your ontology within this class, and inserting it into project.setup() as the “labeling_frontend_options” parameter.

Example

builder = OntologyBuilder() … frontend = list(client.get_labeling_frontends())[0] project.setup(frontend, builder.asdict())

tools

(list)

Type:

List[labelbox.schema.ontology.Tool]

classifications

(list)

Type:

List[labelbox.schema.ontology.Classification | labelbox.schema.ontology.PromptResponseClassification]

class labelbox.schema.ontology.PromptResponseClassification(class_type: ~labelbox.schema.ontology.PromptResponseClassification.Type, name: str | None = None, instructions: str | None = None, required: bool = True, options: ~typing.List[~labelbox.schema.ontology.ResponseOption] = <factory>, character_min: int | None = None, character_max: int | None = None, schema_id: str | None = None, feature_schema_id: str | None = None)[source]

Bases: object

A PromptResponseClassification to be added to a Project’s ontology. The classification is dependent on the PromptResponseClassification Type.

To instantiate, the “class_type” and “name” parameters must be passed in.

The “options” parameter holds a list of Response Option objects. This is not necessary for some Classification types, such as RESPONSE_TEXT or PROMPT. To see which types require options, look at the “_REQUIRES_OPTIONS” class variable.

Example(s): >>> classification = PromptResponseClassification( >>> class_type = PromptResponseClassification.Type.Prompt, >>> character_min = 1, >>> character_max = 1 >>> name = “Prompt Classification Example”)

>>>    classification_two = PromptResponseClassification(
>>>        class_type = PromptResponseClassification.Type.RESPONSE_RADIO,
>>>        name = "Second Example")
>>>    classification_two.add_option(ResponseOption(
>>>        value = "Option Example"))
class_type

(Classification.Type)

Type:

labelbox.schema.ontology.PromptResponseClassification.Type

name

(str)

Type:

str | None

instructions

(str)

Type:

str | None

required

(bool)

Type:

bool

options

(list)

Type:

List[labelbox.schema.ontology.ResponseOption]

character_min

(int)

Type:

int | None

character_max

(int)

Type:

int | None

schema_id

(str)

Type:

str | None

feature_schema_id

(str)

Type:

str | None

class Type(value)[source]

Bases: Enum

An enumeration.

class labelbox.schema.ontology.ResponseOption(value: str | int, label: str | int | None = None, schema_id: str | None = None, feature_schema_id: ~pydantic.v1.types.ConstrainedStrValue | None = None, options: ~typing.List[~labelbox.schema.ontology.Classification] | ~typing.List[~labelbox.schema.ontology.PromptResponseClassification] = <factory>)[source]

Bases: Option

An option is a possible answer within a PromptResponseClassification response object in a Project’s ontology.

To instantiate, only the “value” parameter needs to be passed in.

Example(s):

option = ResponseOption(value = “Response Option Example”)

value

(str)

Type:

str | int

schema_id

(str)

Type:

str | None

feature_schema_id

(str)

Type:

pydantic.v1.types.ConstrainedStrValue | None

options

(list)

Type:

List[labelbox.schema.ontology.Classification] | List[labelbox.schema.ontology.PromptResponseClassification]