Contextualization
Entity Matching
These APIs will return as soon as possible, deferring a blocking wait until the last moment. Nevertheless, they can block for a long time awaiting results.
Fit Entity Matching Model
- EntityMatchingAPI.fit(sources: Sequence[dict | CogniteResource], targets: Sequence[dict | CogniteResource], true_matches: Sequence[dict | tuple[int | str, int | str]] | None = None, match_fields: dict | Sequence[tuple[str, str]] | None = None, feature_type: str | None = None, classifier: str | None = None, ignore_missing_fields: bool = False, name: str | None = None, description: str | None = None, external_id: str | None = None) EntityMatchingModel
Fit entity matching model.
Note
All users on this CDF subscription with assets read-all and entitymatching read-all and write-all capabilities in the project, are able to access the data sent to this endpoint.
- Parameters
sources (Sequence[dict | CogniteResource]) – entities to match from, should have an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). Metadata fields are automatically flattened to “metadata.key” entries, such that they can be used in match_fields.
targets (Sequence[dict | CogniteResource]) – entities to match to, should have an ‘id’ field. Tolerant to passing more than is needed or used.
true_matches (Sequence[dict | tuple[int | str, int | str]] | None) – Known valid matches given as a list of dicts with keys ‘sourceId’, ‘sourceExternalId’, ‘targetId’, ‘targetExternalId’). If omitted, uses an unsupervised model. A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.
match_fields (dict | Sequence[tuple[str, str]] | None) – List of (from,to) keys to use in matching. Default in the API is [(‘name’,’name’)]. Also accepts {“source”: .., “target”: ..}.
feature_type (str | None) – feature type that defines the combination of features used, see API docs for details.
classifier (str | None) – classifier used in training.
ignore_missing_fields (bool) – whether missing data in match_fields should return error or be filled in with an empty string.
name (str | None) – Optional user-defined name of model.
description (str | None) – Optional user-defined description of model.
external_id (str | None) – Optional external id. Must be unique within the project.
- Returns
Resulting queued model.
- Return type
Re-fit Entity Matching Model
- EntityMatchingAPI.refit(true_matches: Sequence[dict | tuple[int | str, int | str]], id: int | None = None, external_id: str | None = None) EntityMatchingModel
Re-fits an entity matching model, using the combination of the old and new true matches.
Note
All users on this CDF subscription with assets read-all and entitymatching read-all and write-all capabilities in the project, are able to access the data sent to this endpoint.
- Parameters
true_matches (Sequence[dict | tuple[int | str, int | str]]) – Updated known valid matches given as a list of dicts with keys ‘fromId’, ‘fromExternalId’, ‘toId’, ‘toExternalId’). A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.
id (int | None) – ids of the model to use.
external_id (str | None) – external ids of the model to use.
- Returns
new model refitted to true_matches.
- Return type
Retrieve Entity Matching Models
- EntityMatchingAPI.retrieve(id: int | None = None, external_id: str | None = None) EntityMatchingModel | None
Retrieve model
- Parameters
id (int | None) – id of the model to retrieve.
external_id (str | None) – external id of the model to retrieve.
- Returns
Model requested.
- Return type
EntityMatchingModel | None
- EntityMatchingAPI.retrieve_multiple(ids: Sequence[int] | None = None, external_ids: Sequence[str] | None = None) EntityMatchingModelList
Retrieve models
- Parameters
ids (Sequence[int] | None) – ids of the model to retrieve.
external_ids (Sequence[str] | None) – external ids of the model to retrieve.
- Returns
Models requested.
- Return type
- EntityMatchingAPI.list(name: str | None = None, description: str | None = None, original_id: int | None = None, feature_type: str | None = None, classifier: str | None = None, limit: int | None = 25) EntityMatchingModelList
List models
- Parameters
name (str | None) – Optional user-defined name of model.
description (str | None) – Optional user-defined description of model.
original_id (int | None) – id of the original model for models that were created with refit.
feature_type (str | None) – feature type that defines the combination of features used.
classifier (str | None) – classifier used in training.
limit (int | None) – Maximum number of items to return. Defaults to 25. Set to -1, float(“inf”) or None to return all items.
- Returns
List of models.
- Return type
Delete Entity Matching Models
- EntityMatchingAPI.delete(id: int | Sequence[int] | None = None, external_id: str | Sequence[str] | None = None) None
Delete models
- Parameters
id (int | Sequence[int] | None) – Id or list of ids
external_id (str | Sequence[str] | None) – External ID or list of external ids
Update Entity Matching Models
- EntityMatchingAPI.update(item: EntityMatchingModel | EntityMatchingModelUpdate | Sequence[EntityMatchingModel | EntityMatchingModelUpdate]) EntityMatchingModelList | EntityMatchingModel
Update model
- Parameters
item (EntityMatchingModel | EntityMatchingModelUpdate | Sequence[EntityMatchingModel | EntityMatchingModelUpdate]) – Model(s) to update
- Returns
No description.
- Return type
Predict Using an Entity Matching Model
- EntityMatchingAPI.predict(sources: Sequence[dict] | None = None, targets: Sequence[dict] | None = None, num_matches: int = 1, score_threshold: float | None = None, id: int | None = None, external_id: str | None = None) ContextualizationJob
Predict entity matching.
Warning
Blocks and waits for the model to be ready if it has been recently created.
Note
All users on this CDF subscription with assets read-all and entitymatching read-all and write-all capabilities in the project, are able to access the data sent to this endpoint.
- Parameters
sources (Sequence[dict] | None) – entities to match from, does not need an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). If omitted, will use data from fit.
targets (Sequence[dict] | None) – entities to match to, does not need an ‘id’ field. Tolerant to passing more than is needed or used. If omitted, will use data from fit.
num_matches (int) – number of matches to return for each item.
score_threshold (float | None) – only return matches with a score above this threshold
id (int | None) – ids of the model to use.
external_id (str | None) – external ids of the model to use.
- Returns
Object which can be used to wait for and retrieve results.
- Return type
Engineering Diagrams
Detect entities in Engineering Diagrams
- DiagramsAPI.detect(entities: Sequence[dict | CogniteResource], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: int | Sequence[int] | None = None, file_external_ids: str | Sequence[str] | None = None, file_references: list[FileReference] | FileReference | None = None, pattern_mode: bool = False, configuration: dict[str, Any] | None = None, *, multiple_jobs: Literal[False]) DiagramDetectResults
- DiagramsAPI.detect(entities: Sequence[dict | CogniteResource], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: int | Sequence[int] | None = None, file_external_ids: str | Sequence[str] | None = None, file_references: list[FileReference] | FileReference | None = None, pattern_mode: bool = False, configuration: dict[str, Any] | None = None, *, multiple_jobs: Literal[True]) tuple[DetectJobBundle | None, list[dict[str, Any]]]
- DiagramsAPI.detect(entities: Sequence[dict | CogniteResource], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: int | Sequence[int] | None = None, file_external_ids: str | Sequence[str] | None = None, file_references: list[FileReference] | FileReference | None = None, pattern_mode: bool = False, configuration: dict[str, Any] | None = None) DiagramDetectResults
Detect entities in a PNID. The results are not written to CDF.
Note
All users on this CDF subscription with assets read-all and files read-all capabilities in the project, are able to access the data sent to this endpoint.
- Parameters
entities (Sequence[dict | CogniteResource]) – List of entities to detect
search_field (str) – If entities is a list of dictionaries, this is the key to the values to detect in the PnId
partial_match (bool) – Allow for a partial match (e.g. missing prefix).
min_tokens (int) – Minimal number of tokens a match must be based on
file_ids (int | Sequence[int] | None) – ID of the files, should already be uploaded in the same tenant.
file_external_ids (str | Sequence[str] | None) – File external ids, alternative to file_ids and file_references.
file_references (list[FileReference] | FileReference | None) – File references (id or external_id), and first_page and last_page to specify page ranges per file. Each reference can specify up to 50 pages. Providing a page range will also make the page count of the document a part of the response.
pattern_mode (bool | None) – Only in beta. If True, entities must be provided with a sample field. This enables detecting tags that are similar to the sample, but not necessarily identical. Defaults to None.
configuration (dict[str, Any] | None) – Only in beta. Additional configuration for the detect algorithm, see https://api-docs.cognite.com/20230101-beta/tag/Engineering-diagrams/operation/diagramDetect.
multiple_jobs (bool) – Enables you to publish multiple jobs. If True the method returns a tuple of DetectJobBundle and list of potentially unposted files. If False it will return a single DiagramDetectResults. Defaults to False.
- Returns
Resulting queued job or a bundle of jobs and a list of unposted files. Note that the .result property of the job or job bundle will block waiting for results.
- Return type
DiagramDetectResults | tuple[DetectJobBundle | None, list[dict[str, Any]]]
Examples
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes.contextualization import FileReference >>> client = CogniteClient() >>> detect_job = client.diagrams.detect( entities=[{"userDefinedField": "21PT1017","ignoredField": "AA11"}, {"userDefinedField": "21PT1018"}], search_field="userDefinedField", partial_match=True, min_tokens=2, file_ids=[101], file_external_ids=["Test1"], file_references=[ FileReference(id=20, first_page=1, last_page=10), FileReference(external_id="ext_20", first_page=11, last_page=20) ], ) >>> result = detect_job.result >>> print(result) <code> { 'items': [ {'fileId': 101, 'annotations': []}, {'fileExternalId': 'Test1', 'fileId: 1, 'annotations': []}, {'fileId': 20, 'fileExternalId': 'ext_20', 'annotations': [], 'pageCount': 17}, { 'fileId': 20, 'fileExternalId': 'ext_20', 'annotations': [ { 'text': '21PT1017', 'entities': [{"userDefinedField": "21PT1017","ignoredField": "AA11"}], 'region': { 'page': 12, 'shape': 'rectangle', 'vertices': [ {'x': 0.01, 'y': 0.01}, {'x': 0.01, 'y': 0.02}, {'x': 0.02, 'y': 0.02}, {'x': 0.02, 'y': 0.01} ] } } ], 'pageCount': 17 } ] } </code>
Convert to an interactive SVG where the provided annotations are highlighted
- DiagramsAPI.convert(detect_job: DiagramDetectResults) DiagramConvertResults
Convert a P&ID to interactive SVGs where the provided annotations are highlighted.
- Parameters
detect_job (DiagramDetectResults) – detect job
- Returns
Resulting queued job. Note that .result property of this job will block waiting for results.
- Return type
Examples
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> detect_job = client.diagrams.detect(...) >>> client.diagrams.convert(detect_job=detect_job)
Vision
The Vision API enable extraction of information from imagery data based on their visual content. For example, you can can extract features such as text, asset tags or industrial objects from images using this service.
Quickstart
Start an asynchronous job to extract information from image files stored in CDF:
from cognite.client import CogniteClient
from cognite.client.data_classes.contextualization import VisionFeature
c = CogniteClient()
extract_job = c.vision.extract(
features=[VisionFeature.ASSET_TAG_DETECTION, VisionFeature.PEOPLE_DETECTION],
file_ids=[1, 2],
)
The returned job object, extract_job
, can be used to retrieve the status of the job and the prediction results once the job is completed.
Wait for job completion and get the parsed results:
extract_job.wait_for_completion()
for item in extract_job.items:
predictions = item.predictions
# do something with the predictions
Save the prediction results in CDF as Annotations:
extract_job.save_predictions()
Note
Prediction results are stored in CDF as Annotations using the images.*
annotation types. In particular, text detections are stored as images.TextRegion
, asset tag detections are stored as images.AssetLink
, while other detections are stored as images.ObjectDetection
.
Tweaking the parameters of a feature extractor:
from cognite.client.data_classes.contextualization import FeatureParameters, TextDetectionParameters
extract_job = c.vision.extract(
features=VisionFeature.TEXT_DETECTION,
file_ids=[1, 2],
parameters=FeatureParameters(text_detection_parameters=TextDetectionParameters(threshold=0.9))
# or
# parameters = {"textDetectionParameters": {"threshold": 0.9}}
)
Extract
- VisionAPI.extract(features: VisionFeature | list[VisionFeature], file_ids: list[int] | None = None, file_external_ids: list[str] | None = None, parameters: FeatureParameters | None = None) VisionExtractJob
Start an asynchronous job to extract features from image files.
- Parameters
features (VisionFeature | list[VisionFeature]) – The feature(s) to extract from the provided image files.
file_ids (list[int] | None) – IDs of the image files to analyze. The images must already be uploaded in the same CDF project.
file_external_ids (list[str] | None) – The external file ids of the image files to analyze.
parameters (FeatureParameters | None) – No description.
- Returns
Resulting queued job, which can be used to retrieve the status of the job or the prediction results if the job is finished. Note that .result property of this job will wait for the job to finish and returns the results.
- Return type
Examples
Start a job, wait for completion and then get the parsed results:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes.contextualization import VisionFeature >>> c = CogniteClient() >>> extract_job = c.vision.extract(features=VisionFeature.ASSET_TAG_DETECTION, file_ids=[1]) >>> extract_job.wait_for_completion() >>> for item in extract_job.items: ... predictions = item.predictions ... # do something with the predictions >>> # Save predictions in CDF using Annotations API: >>> extract_job.save_predictions()
Get vision extract job
- VisionAPI.get_extract_job(job_id: int) VisionExtractJob
Retrieve an existing extract job by ID.
- Parameters
job_id (int) – ID of an existing feature extraction job.
- Returns
Vision extract job, which can be used to retrieve the status of the job or the prediction results if the job is finished. Note that .result property of this job will wait for the job to finish and returns the results.
- Return type
Examples
Retrieve a vision extract job by ID:
>>> from cognite.client import CogniteClient >>> c = CogniteClient() >>> extract_job = c.vision.get_extract_job(job_id=1) >>> extract_job.wait_for_completion() >>> for item in extract_job.items: ... predictions = item.predictions ... # do something with the predictions
Contextualization Data Classes
- class cognite.client.data_classes.contextualization.AssetTagDetectionParameters(threshold: 'float | None' = None, partial_match: 'bool | None' = None, asset_subtree_ids: 'list[int] | None' = None)
Bases:
VisionResource
,ThresholdParameter
- asset_subtree_ids: list[int] | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- partial_match: bool | None = None
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.ContextualizationJob(job_id: int | None = None, model_id: int | None = None, status: str | None = None, error_message: str | None = None, created_time: int | None = None, start_time: int | None = None, status_time: int | None = None, status_path: str | None = None, job_token: str | None = None, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
Data class for the result of a contextualization job.
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- update_status() str
Updates the model status and returns it
- wait_for_completion(timeout: int | None = None, interval: int = 1) None
Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
interval (int) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.ContextualizationJobList(resources: Collection[Any], cognite_client: CogniteClient | None = None)
Bases:
CogniteResourceList
[ContextualizationJob
]- append(item)
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S
- copy()
- count(value) integer -- return number of occurrences of value
- dump(camel_case: bool = False) list[dict[str, Any]]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A list of dicts representing the instance.
- Return type
list[dict[str, Any]]
- extend(other: Collection[Any]) None
S.extend(iterable) – extend sequence by appending elements from the iterable
- get(id: int | None = None, external_id: str | None = None) T_CogniteResource | None
Get an item from this list by id or external_id.
- Parameters
id (int | None) – The id of the item to get.
external_id (str | None) – The external_id of the item to get.
- Returns
The requested item
- Return type
T_CogniteResource | None
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(i, item)
S.insert(index, value) – insert value before index
- pop([index]) item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
- remove(item)
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()
S.reverse() – reverse IN PLACE
- sort(*args, **kwds)
- to_pandas(camel_case: bool = False, expand_metadata: bool = False, metadata_prefix: str = 'metadata.') pandas.DataFrame
Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
expand_metadata (bool) – Expand the metadata column into separate columns.
metadata_prefix (str) – Prefix to use for metadata columns.
- Returns
The Cognite resource as a dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.ContextualizationJobType(value)
Bases:
Enum
An enumeration.
- DIAGRAMS = 'diagrams'
- ENTITY_MATCHING = 'entity_matching'
- VISION = 'vision'
- class cognite.client.data_classes.contextualization.DetectJobBundle(job_ids: list[int], cognite_client: CogniteClient | None = None)
Bases:
object
- fetch_results() list[dict[str, Any]]
- property result: tuple[list[dict[str, Any]], list[dict[str, Any]]]
Waits for the job to finish and returns the results.
- wait_for_completion(timeout: int | None = None) None
Waits for all jobs to complete, generally not needed to call as it is called by result.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
- class cognite.client.data_classes.contextualization.DiagramConvertItem(file_id: int | None = None, file_external_id: str | None = None, results: list | None = None, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property pages: DiagramConvertPageList
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.DiagramConvertPage(page: int | None = None, png_url: str | None = None, svg_url: str | None = None, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.DiagramConvertPageList(resources: Collection[Any], cognite_client: CogniteClient | None = None)
Bases:
CogniteResourceList
[DiagramConvertPage
]- append(item)
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S
- copy()
- count(value) integer -- return number of occurrences of value
- dump(camel_case: bool = False) list[dict[str, Any]]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A list of dicts representing the instance.
- Return type
list[dict[str, Any]]
- extend(other: Collection[Any]) None
S.extend(iterable) – extend sequence by appending elements from the iterable
- get(id: int | None = None, external_id: str | None = None) T_CogniteResource | None
Get an item from this list by id or external_id.
- Parameters
id (int | None) – The id of the item to get.
external_id (str | None) – The external_id of the item to get.
- Returns
The requested item
- Return type
T_CogniteResource | None
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(i, item)
S.insert(index, value) – insert value before index
- pop([index]) item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
- remove(item)
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()
S.reverse() – reverse IN PLACE
- sort(*args, **kwds)
- to_pandas(camel_case: bool = False, expand_metadata: bool = False, metadata_prefix: str = 'metadata.') pandas.DataFrame
Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
expand_metadata (bool) – Expand the metadata column into separate columns.
metadata_prefix (str) – Prefix to use for metadata columns.
- Returns
The Cognite resource as a dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.DiagramConvertResults(**kwargs: Any)
Bases:
ContextualizationJob
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property items: list[DiagramConvertItem] | None
returns a list of all results by file
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- update_status() str
Updates the model status and returns it
- wait_for_completion(timeout: int | None = None, interval: int = 1) None
Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
interval (int) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.DiagramDetectItem(file_id: int | None = None, file_external_id: str | None = None, annotations: list | None = None, error_message: str | None = None, cognite_client: CogniteClient | None = None, page_range: dict[str, int] | None = None, page_count: int | None = None)
Bases:
CogniteResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.DiagramDetectResults(**kwargs: Any)
Bases:
ContextualizationJob
- convert() DiagramConvertResults
Convert a P&ID to an interactive SVG where the provided annotations are highlighted
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property errors: list[str]
Returns a list of all error messages across files
- property items: list[DiagramDetectItem] | None
Returns a list of all results by file
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- update_status() str
Updates the model status and returns it
- wait_for_completion(timeout: int | None = None, interval: int = 1) None
Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
interval (int) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.DialGaugeDetection(threshold: 'float | None' = None, min_level: 'float | None' = None, max_level: 'float | None' = None, dead_angle: 'float | None' = None, non_linear_angle: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dead_angle: float | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- max_level: float | None = None
- min_level: float | None = None
- non_linear_angle: float | None = None
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.DigitalGaugeDetection(threshold: 'float | None' = None, comma_position: 'int | None' = None, min_num_digits: 'int | None' = None, max_num_digits: 'int | None' = None)
Bases:
VisionResource
,ThresholdParameter
- comma_position: int | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- max_num_digits: int | None = None
- min_num_digits: int | None = None
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.EntityMatchingModel(id: int | None = None, status: str | None = None, error_message: str | None = None, created_time: int | None = None, start_time: int | None = None, status_time: int | None = None, classifier: str | None = None, feature_type: str | None = None, match_fields: list[str] | None = None, model_type: str | None = None, name: str | None = None, description: str | None = None, external_id: str | None = None, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
Entity matching model. See the fit method for the meaning of these fields.
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- predict(sources: list[dict] | None = None, targets: list[dict] | None = None, num_matches: int = 1, score_threshold: float | None = None) ContextualizationJob
Predict entity matching. NB. blocks and waits for the model to be ready if it has been recently created.
- Parameters
sources (list[dict] | None) – entities to match from, does not need an ‘id’ field. Tolerant to passing more than is needed or used (e.g. json dump of time series list). If omitted, will use data from fit.
targets (list[dict] | None) – entities to match to, does not need an ‘id’ field. Tolerant to passing more than is needed or used. If omitted, will use data from fit.
num_matches (int) – number of matches to return for each item.
score_threshold (float | None) – only return matches with a score above this threshold
- Returns
object which can be used to wait for and retrieve results.
- Return type
- refit(true_matches: Sequence[dict | tuple[int | str, int | str]]) EntityMatchingModel
Re-fits an entity matching model, using the combination of the old and new true matches.
- Parameters
true_matches (Sequence[dict | tuple[int | str, int | str]]) – Updated known valid matches given as a list of dicts with keys ‘fromId’, ‘fromExternalId’, ‘toId’, ‘toExternalId’). A tuple can be used instead of the dictionary for convenience, interpreted as id/externalId based on type.
- Returns
new model refitted to true_matches.
- Return type
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- update_status() str
Updates the model status and returns it
- wait_for_completion(timeout: int | None = None, interval: int = 1) None
Waits for model completion. This is generally not needed to call directly, as .result will do so automatically.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
interval (int) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.EntityMatchingModelList(resources: Collection[Any], cognite_client: CogniteClient | None = None)
Bases:
CogniteResourceList
[EntityMatchingModel
]- append(item)
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S
- copy()
- count(value) integer -- return number of occurrences of value
- dump(camel_case: bool = False) list[dict[str, Any]]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A list of dicts representing the instance.
- Return type
list[dict[str, Any]]
- extend(other: Collection[Any]) None
S.extend(iterable) – extend sequence by appending elements from the iterable
- get(id: int | None = None, external_id: str | None = None) T_CogniteResource | None
Get an item from this list by id or external_id.
- Parameters
id (int | None) – The id of the item to get.
external_id (str | None) – The external_id of the item to get.
- Returns
The requested item
- Return type
T_CogniteResource | None
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(i, item)
S.insert(index, value) – insert value before index
- pop([index]) item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
- remove(item)
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()
S.reverse() – reverse IN PLACE
- sort(*args, **kwds)
- to_pandas(camel_case: bool = False, expand_metadata: bool = False, metadata_prefix: str = 'metadata.') pandas.DataFrame
Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
expand_metadata (bool) – Expand the metadata column into separate columns.
metadata_prefix (str) – Prefix to use for metadata columns.
- Returns
The Cognite resource as a dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.EntityMatchingModelUpdate(id: int | None = None, external_id: str | None = None)
Bases:
CogniteUpdate
Changes applied to entity matching model
- Parameters
id (int) – A server-generated ID for the object.
external_id (str) – The external ID provided by the client. Must be unique for the resource type.
- property description: _PrimitiveUpdate
- dump(camel_case: bool = True) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – No description.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property name: _PrimitiveUpdate
- class cognite.client.data_classes.contextualization.FeatureParameters(text_detection_parameters: 'TextDetectionParameters | None' = None, asset_tag_detection_parameters: 'AssetTagDetectionParameters | None' = None, people_detection_parameters: 'PeopleDetectionParameters | None' = None, industrial_object_detection_parameters: 'IndustrialObjectDetectionParameters | None' = None, personal_protective_equipment_detection_parameters: 'PersonalProtectiveEquipmentDetectionParameters | None' = None, digital_gauge_detection_parameters: 'DigitalGaugeDetection | None' = None, dial_gauge_detection_parameters: 'DialGaugeDetection | None' = None, level_gauge_detection_parameters: 'LevelGaugeDetection | None' = None, valve_detection_parameters: 'ValveDetection | None' = None)
Bases:
VisionResource
- asset_tag_detection_parameters: AssetTagDetectionParameters | None = None
- dial_gauge_detection_parameters: DialGaugeDetection | None = None
- digital_gauge_detection_parameters: DigitalGaugeDetection | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- industrial_object_detection_parameters: IndustrialObjectDetectionParameters | None = None
- level_gauge_detection_parameters: LevelGaugeDetection | None = None
- people_detection_parameters: PeopleDetectionParameters | None = None
- personal_protective_equipment_detection_parameters: PersonalProtectiveEquipmentDetectionParameters | None = None
- text_detection_parameters: TextDetectionParameters | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- valve_detection_parameters: ValveDetection | None = None
- class cognite.client.data_classes.contextualization.FileReference(file_id: int | None = None, file_external_id: str | None = None, first_page: int | None = None, last_page: int | None = None)
Bases:
object
- to_api_item() dict[str, str | int | dict[str, int]]
- class cognite.client.data_classes.contextualization.IndustrialObjectDetectionParameters(threshold: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.JobStatus(value)
Bases:
Enum
An enumeration.
- COLLECTING = 'Collecting'
- COMPLETED = 'Completed'
- DISTRIBUTED = 'Distributed'
- DISTRIBUTING = 'Distributing'
- FAILED = 'Failed'
- QUEUED = 'Queued'
- RUNNING = 'Running'
- is_finished() bool
- is_not_finished() bool
- class cognite.client.data_classes.contextualization.LevelGaugeDetection(threshold: 'float | None' = None, min_level: 'float | None' = None, max_level: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- max_level: float | None = None
- min_level: float | None = None
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.PeopleDetectionParameters(threshold: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.PersonalProtectiveEquipmentDetectionParameters(threshold: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.ResourceReference(id: int | None = None, external_id: str | None = None, cognite_client: None | CogniteClient = None)
Bases:
CogniteResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.ResourceReferenceList(resources: Collection[Any], cognite_client: CogniteClient | None = None)
Bases:
CogniteResourceList
[ResourceReference
]- append(item)
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S
- copy()
- count(value) integer -- return number of occurrences of value
- dump(camel_case: bool = False) list[dict[str, Any]]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A list of dicts representing the instance.
- Return type
list[dict[str, Any]]
- extend(other: Collection[Any]) None
S.extend(iterable) – extend sequence by appending elements from the iterable
- get(id: int | None = None, external_id: str | None = None) T_CogniteResource | None
Get an item from this list by id or external_id.
- Parameters
id (int | None) – The id of the item to get.
external_id (str | None) – The external_id of the item to get.
- Returns
The requested item
- Return type
T_CogniteResource | None
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(i, item)
S.insert(index, value) – insert value before index
- pop([index]) item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
- remove(item)
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()
S.reverse() – reverse IN PLACE
- sort(*args, **kwds)
- to_pandas(camel_case: bool = False, expand_metadata: bool = False, metadata_prefix: str = 'metadata.') pandas.DataFrame
Convert the instance into a pandas DataFrame. Note that if the metadata column is expanded and there are keys in the metadata that already exist in the DataFrame, then an error will be raised by pd.join.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
expand_metadata (bool) – Expand the metadata column into separate columns.
metadata_prefix (str) – Prefix to use for metadata columns.
- Returns
The Cognite resource as a dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.TextDetectionParameters(threshold: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.ThresholdParameter(threshold: 'float | None' = None)
Bases:
object
- threshold: float | None = None
- class cognite.client.data_classes.contextualization.ValveDetection(threshold: 'float | None' = None)
Bases:
VisionResource
,ThresholdParameter
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- threshold: float | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.VisionExtractItem(file_id: int | None = None, predictions: dict[str, Any] | None = None, file_external_id: str | None = None, error_message: str | None = None, cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
Data class for storing predictions for a single image file
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.contextualization.VisionExtractJob(*args: Any, **kwargs: Any)
Bases:
VisionJob
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property errors: list[str]
Returns a list of all error messages across files
- property items: list[VisionExtractItem] | None
Returns a list of all predictions by file
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- save_predictions(creating_user: str | None = None, creating_app: str | None = None, creating_app_version: str | None = None) Annotation | AnnotationList
Saves all predictions made by the feature extractors in CDF using the Annotations API. See https://docs.cognite.com/api/v1/#operation/annotationsSuggest
- Parameters
creating_user (str | None) – (str, optional): A username, or email, or name. This is not checked nor enforced. If the value is None, it means the annotation was created by a service.
creating_app (str | None) – The name of the app from which this annotation was created. Defaults to ‘cognite-sdk-python’.
creating_app_version (str | None) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string. Defaults to client version.
- Returns
(suggested) annotation(s) stored in CDF.
- Return type
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- update_status() str
Updates the model status and returns it
- wait_for_completion(timeout: int | None = None, interval: int = 1) None
Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
interval (int) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.contextualization.VisionExtractPredictions(text_predictions: 'list[TextRegion] | None' = None, asset_tag_predictions: 'list[AssetLink] | None' = None, industrial_object_predictions: 'list[ObjectDetection] | None' = None, people_predictions: 'list[ObjectDetection] | None' = None, personal_protective_equipment_predictions: 'list[ObjectDetection] | None' = None, digital_gauge_predictions: 'list[ObjectDetection] | None' = None, dial_gauge_predictions: 'list[KeypointCollectionWithObjectDetection] | None' = None, level_gauge_predictions: 'list[KeypointCollectionWithObjectDetection] | None' = None, valve_predictions: 'list[KeypointCollectionWithObjectDetection] | None' = None)
Bases:
VisionResource
- dial_gauge_predictions: list[KeypointCollectionWithObjectDetection] | None = None
- digital_gauge_predictions: list[ObjectDetection] | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- industrial_object_predictions: list[ObjectDetection] | None = None
- level_gauge_predictions: list[KeypointCollectionWithObjectDetection] | None = None
- people_predictions: list[ObjectDetection] | None = None
- personal_protective_equipment_predictions: list[ObjectDetection] | None = None
- text_predictions: list[TextRegion] | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- valve_predictions: list[KeypointCollectionWithObjectDetection] | None = None
- class cognite.client.data_classes.contextualization.VisionFeature(value)
Bases:
str
,Enum
An enumeration.
- ASSET_TAG_DETECTION = 'AssetTagDetection'
- DIAL_GAUGE_DETECTION = 'DialGaugeDetection'
- DIGITAL_GAUGE_DETECTION = 'DigitalGaugeDetection'
- INDUSTRIAL_OBJECT_DETECTION = 'IndustrialObjectDetection'
- LEVEL_GAUGE_DETECTION = 'LevelGaugeDetection'
- PEOPLE_DETECTION = 'PeopleDetection'
- PERSONAL_PROTECTIVE_EQUIPMENT_DETECTION = 'PersonalProtectiveEquipmentDetection'
- TEXT_DETECTION = 'TextDetection'
- VALVE_DETECTION = 'ValveDetection'
- classmethod beta_features() set[VisionFeature]
Returns a set of VisionFeature’s that are currently in beta
- class cognite.client.data_classes.contextualization.VisionJob(job_id: int | None = None, model_id: int | None = None, status: str | None = None, error_message: str | None = None, created_time: int | None = None, start_time: int | None = None, status_time: int | None = None, status_path: str | None = None, job_token: str | None = None, cognite_client: CogniteClient | None = None)
Bases:
ContextualizationJob
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- property result: dict[str, Any]
Waits for the job to finish and returns the results.
- to_pandas(expand: Sequence[str] = ('metadata',), ignore: list[str] | None = None, camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
expand (Sequence[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
ignore (list[str] | None) – List of row keys to not include when converting to a data frame.
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- update_status() str
Updates the model status and returns it
- wait_for_completion(timeout: int | None = None, interval: int = 1) None
Waits for job completion. This is generally not needed to call directly, as .result will do so automatically.
- Parameters
timeout (int | None) – Time out after this many seconds. (None means wait indefinitely)
interval (int) – Poll status every this many seconds.
- Raises
ModelFailedException – The model fit failed.
- class cognite.client.data_classes.annotation_types.images.AssetLink(text: 'str', text_region: 'BoundingBox', asset_ref: 'CdfResourceRef', confidence: 'float | None' = None)
Bases:
VisionResource
- asset_ref: CdfResourceRef
- confidence: float | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- text: str
- text_region: BoundingBox
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.images.KeypointCollection(label: 'str', keypoints: 'dict[str, Keypoint]', attributes: 'dict[str, Attribute] | None' = None, confidence: 'float | None' = None)
Bases:
VisionResource
- confidence: float | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- label: str
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.images.KeypointCollectionWithObjectDetection(object_detection: 'ObjectDetection', keypoint_collection: 'KeypointCollection')
Bases:
VisionResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- keypoint_collection: KeypointCollection
- object_detection: ObjectDetection
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.images.ObjectDetection(label: 'str', confidence: 'float | None' = None, attributes: 'dict[str, Attribute] | None' = None, bounding_box: 'BoundingBox | None' = None, polygon: 'Polygon | None' = None, polyline: 'Polyline | None' = None)
Bases:
VisionResource
- bounding_box: BoundingBox | None = None
- confidence: float | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- label: str
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.images.TextRegion(text: 'str', text_region: 'BoundingBox', confidence: 'float | None' = None)
Bases:
VisionResource
- confidence: float | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- text: str
- text_region: BoundingBox
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.primitives.Attribute(type: "Literal[('boolean', 'numerical')]", value: 'bool | float', description: 'str | None' = None)
Bases:
VisionResource
- description: str | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- type: Literal['boolean', 'numerical']
- value: bool | float
- class cognite.client.data_classes.annotation_types.primitives.BoundingBox(x_min: 'float', x_max: 'float', y_min: 'float', y_max: 'float')
Bases:
VisionResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- x_max: float
- x_min: float
- y_max: float
- y_min: float
- class cognite.client.data_classes.annotation_types.primitives.CdfResourceRef(id: 'int | None' = None, external_id: 'str | None' = None)
Bases:
VisionResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- external_id: str | None = None
- id: int | None = None
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.primitives.Keypoint(point: 'Point', confidence: 'float | None' = None)
Bases:
VisionResource
- confidence: float | None = None
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.primitives.Point(x: 'float', y: 'float')
Bases:
VisionResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- x: float
- y: float
- class cognite.client.data_classes.annotation_types.primitives.Polygon(vertices: 'list[Point]')
Bases:
VisionResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.primitives.Polyline(vertices: 'list[Point]')
Bases:
VisionResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame
- class cognite.client.data_classes.annotation_types.primitives.VisionResource(cognite_client: CogniteClient | None = None)
Bases:
CogniteResource
- dump(camel_case: bool = False) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters
camel_case (bool) – Use camelCase for attribute names. Defaults to False.
- Returns
A dictionary representation of the instance.
- Return type
dict[str, Any]
- to_pandas(camel_case: bool = False) pandas.DataFrame
Convert the instance into a pandas DataFrame.
- Parameters
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns
The dataframe.
- Return type
pandas.DataFrame