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[Union[Dict[KT, VT], cognite.client.data_classes._base.CogniteResource]], targets: Sequence[Union[Dict[KT, VT], cognite.client.data_classes._base.CogniteResource]], true_matches: Optional[Sequence[Union[Dict[KT, VT], Tuple[Union[int, str], Union[int, str]]]]] = None, match_fields: Union[Dict[KT, VT], Sequence[Tuple[str, str]], None] = None, feature_type: Optional[str] = None, classifier: Optional[str] = None, ignore_missing_fields: bool = False, name: Optional[str] = None, description: Optional[str] = None, external_id: Optional[str] = None) → cognite.client.data_classes.contextualization.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 – 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 – entities to match to, should have an ‘id’ field. Tolerant to passing more than is needed or used.
  • true_matches – 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 – List of (from,to) keys to use in matching. Default in the API is [(‘name’,’name’)]. Also accepts {“source”: .., “target”: ..}.
  • feature_type (str) – feature type that defines the combination of features used, see API docs for details.
  • classifier (str) – 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) – Optional user-defined name of model.
  • description (str) – Optional user-defined description of model.
  • external_id (str) – Optional external id. Must be unique within the project.
Returns:

Resulting queued model.

Return type:

EntityMatchingModel

Re-fit Entity Matching Model

EntityMatchingAPI.refit(true_matches: Sequence[Union[Dict[KT, VT], Tuple[Union[int, str], Union[int, str]]]], id: Optional[int] = None, external_id: Optional[str] = None) → cognite.client.data_classes.contextualization.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[Union[Dict, Tuple[Union[int, str], Union[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 – ids of the model to use.
  • external_id – external ids of the model to use.
Returns:

new model refitted to true_matches.

Return type:

EntityMatchingModel

Retrieve Entity Matching Models

EntityMatchingAPI.retrieve(id: Optional[int] = None, external_id: Optional[str] = None) → Optional[cognite.client.data_classes.contextualization.EntityMatchingModel]

Retrieve model

Parameters:
  • id (int) – id of the model to retrieve.
  • external_id (str) – external id of the model to retrieve.
Returns:

Model requested.

Return type:

EntityMatchingModel

EntityMatchingAPI.retrieve_multiple(ids: Optional[Sequence[int]] = None, external_ids: Optional[Sequence[str]] = None) → cognite.client.data_classes.contextualization.EntityMatchingModelList

Retrieve models

Parameters:
  • ids (Sequence[int]) – ids of the model to retrieve.
  • external_ids (Sequence[str]) – external ids of the model to retrieve.
Returns:

Models requested.

Return type:

EntityMatchingModelList

EntityMatchingAPI.list(name: Optional[str] = None, description: Optional[str] = None, original_id: Optional[int] = None, feature_type: Optional[str] = None, classifier: Optional[str] = None, limit: int = 100) → cognite.client.data_classes.contextualization.EntityMatchingModelList

List models

Parameters:
  • name (str) – Optional user-defined name of model.
  • description (str) – Optional user-defined description of model.
  • feature_type (str) – feature type that defines the combination of features used.
  • classifier (str) – classifier used in training.
  • original_id (int) – id of the original model for models that were created with refit.
  • limit (int, optional) – Maximum number of items to return. Defaults to 100. Set to -1, float(“inf”) or None to return all items.
Returns:

List of models.

Return type:

EntityMatchingModelList

Delete Entity Matching Models

EntityMatchingAPI.delete(id: Union[int, Sequence[int], None] = None, external_id: Union[str, Sequence[str], None] = None) → None

Delete models

Parameters:
  • id (Union[int, Sequence[int]) – Id or list of ids
  • external_id (Union[str, Sequence[str]]) – External ID or list of external ids

Update Entity Matching Models

EntityMatchingAPI.update(item: Union[cognite.client.data_classes.contextualization.EntityMatchingModel, cognite.client.data_classes.contextualization.EntityMatchingModelUpdate, Sequence[Union[cognite.client.data_classes.contextualization.EntityMatchingModel, cognite.client.data_classes.contextualization.EntityMatchingModelUpdate]]]) → Union[cognite.client.data_classes.contextualization.EntityMatchingModelList, cognite.client.data_classes.contextualization.EntityMatchingModel]

Update model

Parameters:item (Union[EntityMatchingModel,EntityMatchingModelUpdate, Sequence[Union[EntityMatchingModel,EntityMatchingModelUpdate]]) – Model(s) to update

Predict Using an Entity Matching Model

EntityMatchingAPI.predict(sources: Optional[Sequence[Dict[KT, VT]]] = None, targets: Optional[Sequence[Dict[KT, VT]]] = None, num_matches: int = 1, score_threshold: Optional[float] = None, id: Optional[int] = None, external_id: Optional[str] = None) → cognite.client.data_classes.contextualization.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 (Optional[Sequence[Dict]]) – 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 (Optional[Sequence[Dict]]) – 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) – only return matches with a score above this threshold
  • ignore_missing_fields (bool) – whether missing data in match_fields should be filled in with an empty string.
  • id – ids of the model to use.
  • external_id – external ids of the model to use.
Returns:

Object which can be used to wait for and retrieve results.

Return type:

ContextualizationJob

Engineering Diagrams

Detect entities in Engineering Diagrams

DiagramsAPI.detect(entities: Sequence[Union[dict, cognite.client.data_classes._base.CogniteResource]], search_field: str = 'name', partial_match: bool = False, min_tokens: int = 2, file_ids: Union[int, Sequence[int], None] = None, file_external_ids: Union[str, Sequence[str], None] = None, file_references: Union[List[cognite.client.data_classes.contextualization.FileReference], cognite.client.data_classes.contextualization.FileReference, None] = None, *, multiple_jobs: bool = False) → Union[cognite.client.data_classes.contextualization.DiagramDetectResults, Tuple[Optional[cognite.client.data_classes.contextualization.DetectJobBundle], List[Dict[str, Any]]]]

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[Union[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 (Sequence[int]) – ID of the files, should already be uploaded in the same tenant.
  • file_external_ids (Sequence[str]) – File external ids.
  • file_references (Sequence[FileReference]) – File references (id or external id) with page ranges.
Keyword Arguments:
 

multiple_jobs (bool) – Enables you to publish multiple jobs. If True the method will return 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:

Union[DiagramDetectResults, Tuple[DetectJobBundle, List[Dict[str, Any]]]

Examples

>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> retrieved_model = client.diagrams.detect(
    entities=[{"userDefinedField": "21PT1017","ignoredField": "AA11"}],
    search_field="userDefinedField",
    partial_match=True,
    min_tokens=2,
    file_ids=[101],
    file_external_ids=["Test1"],
)

Convert to an interactive SVG where the provided annotations are highlighted

DiagramsAPI.convert(detect_job: cognite.client.data_classes.contextualization.DiagramDetectResults) → cognite.client.data_classes.contextualization.DiagramConvertResults

Convert a P&ID to interactive SVGs where the provided annotations are highlighted.

Parameters:detect_job (DiagramConvertResults) – detect job
Returns:Resulting queued job. Note that .result property of this job will block waiting for results.
Return type:DiagramConvertResults

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))
)

Extract

VisionAPI.extract(features: Union[cognite.client.data_classes.contextualization.VisionFeature, List[cognite.client.data_classes.contextualization.VisionFeature]], file_ids: Optional[List[int]] = None, file_external_ids: Optional[List[str]] = None, parameters: Optional[cognite.client.data_classes.contextualization.FeatureParameters] = None) → cognite.client.data_classes.contextualization.VisionExtractJob

Start an asynchronous job to extract features from image files.

Parameters:
  • features (Union[VisionFeature, List[VisionFeature]]) – The feature(s) to extract from the provided image files.
  • file_ids (List[int]) – IDs of the image files to analyze. The images must already be uploaded in the same CDF project.
  • file_external_ids (List[str]) – The external file ids of the image files to analyze.
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:

VisionExtractJob

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) → cognite.client.data_classes.contextualization.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:VisionExtractJob

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(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource, cognite.client.data_classes.contextualization.ThresholdParameter

asset_subtree_ids = 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 = None
threshold = 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, model_id: int = None, status: str = None, error_message: str = None, created_time: int = None, start_time: int = None, status_time: int = None, status_path: str = None, job_token: str = None, cognite_client: CogniteClient = None)

Bases: cognite.client.data_classes._base.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]
result

Waits for the job to finish and returns the results.

to_pandas(expand: Sequence[str] = ('metadata', ), ignore: List[str] = None, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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: Optional[int] = 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) – 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)

Bases: cognite.client.data_classes._base.CogniteResourceList

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: Optional[int] = None, external_id: Optional[str] = None) → Optional[cognite.client.data_classes._base.CogniteResource]

Get an item from this list by id or exernal_id.

Parameters:
  • id (int) – The id of the item to get.
  • external_id (str) – The external_id of the item to get.
Returns:

The requested item

Return type:

Optional[CogniteResource]

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) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Returns:The dataframe.
Return type:pandas.DataFrame
class cognite.client.data_classes.contextualization.ContextualizationJobType

Bases: enum.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)

Bases: object

fetch_results() → List[Dict[str, Any]]
result

Waits for the job to finish and returns the results.

wait_for_completion(timeout: Optional[int] = None) → None

Waits for all jobs to complete, generally not needed to call as it is called by result.

Parameters:
  • timeout (int) – Time out after this many seconds. (None means wait indefinitely)
  • interval (int) – Poll status every this many seconds.
class cognite.client.data_classes.contextualization.DiagramConvertItem(file_id: int = None, file_external_id: str = None, results: list = None, cognite_client: CogniteClient = None)

Bases: cognite.client.data_classes._base.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]
pages
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, png_url: str = None, svg_url: str = None, cognite_client: CogniteClient = None)

Bases: cognite.client.data_classes._base.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, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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)

Bases: cognite.client.data_classes._base.CogniteResourceList

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: Optional[int] = None, external_id: Optional[str] = None) → Optional[cognite.client.data_classes._base.CogniteResource]

Get an item from this list by id or exernal_id.

Parameters:
  • id (int) – The id of the item to get.
  • external_id (str) – The external_id of the item to get.
Returns:

The requested item

Return type:

Optional[CogniteResource]

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) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Returns:The dataframe.
Return type:pandas.DataFrame
class cognite.client.data_classes.contextualization.DiagramConvertResults(**kwargs)

Bases: cognite.client.data_classes.contextualization.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]
items

returns a list of all results by file

result

Waits for the job to finish and returns the results.

to_pandas(expand: Sequence[str] = ('metadata', ), ignore: List[str] = None, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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: Optional[int] = 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) – 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, file_external_id: str = None, annotations: list = None, error_message: str = None, cognite_client: CogniteClient = None, page_range: Optional[Dict[str, int]] = None)

Bases: cognite.client.data_classes._base.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)

Bases: cognite.client.data_classes.contextualization.ContextualizationJob

convert() → cognite.client.data_classes.contextualization.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]
errors

Returns a list of all error messages across files

items

Returns a list of all results by file

result

Waits for the job to finish and returns the results.

to_pandas(expand: Sequence[str] = ('metadata', ), ignore: List[str] = None, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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: Optional[int] = 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) – 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.EntityMatchingModel(id: int = None, status: str = None, error_message: str = None, created_time: int = None, start_time: int = None, status_time: int = None, classifier: str = None, feature_type: str = None, match_fields: List[str] = None, model_type: str = None, name: str = None, description: str = None, external_id: str = None, cognite_client: CogniteClient = None)

Bases: cognite.client.data_classes._base.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]
predict(sources: Optional[List[Dict[KT, VT]]] = None, targets: Optional[List[Dict[KT, VT]]] = None, num_matches: int = 1, score_threshold: Optional[float] = None) → cognite.client.data_classes.contextualization.ContextualizationJob

Predict entity matching. NB. blocks and waits for the model to be ready if it has been recently created.

Parameters:
  • sources – 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 – 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) – only return matches with a score above this threshold
  • ignore_missing_fields (bool) – whether missing data in match_fields should be filled in with an empty string.
Returns:

object which can be used to wait for and retrieve results.

Return type:

ContextualizationJob

refit(true_matches: Sequence[Union[Dict[KT, VT], Tuple[Union[int, str], Union[int, str]]]]) → cognite.client.data_classes.contextualization.EntityMatchingModel

Re-fits an entity matching model, using the combination of the old and new true matches.

Parameters:true_matches – 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:EntityMatchingModel
to_pandas(expand: Sequence[str] = ('metadata', ), ignore: List[str] = None, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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: Optional[int] = 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 – Time out after this many seconds. (None means wait indefinitely)
  • interval – 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)

Bases: cognite.client.data_classes._base.CogniteResourceList

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: Optional[int] = None, external_id: Optional[str] = None) → Optional[cognite.client.data_classes._base.CogniteResource]

Get an item from this list by id or exernal_id.

Parameters:
  • id (int) – The id of the item to get.
  • external_id (str) – The external_id of the item to get.
Returns:

The requested item

Return type:

Optional[CogniteResource]

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) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Returns:The dataframe.
Return type:pandas.DataFrame
class cognite.client.data_classes.contextualization.EntityMatchingModelUpdate(id: Optional[int] = None, external_id: Optional[str] = None)

Bases: cognite.client.data_classes._base.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.
description
dump(camel_case: bool = True) → Dict[str, Any]

Dump the instance into a json serializable Python data type.

Returns:A dictionary representation of the instance.
Return type:Dict[str, Any]
name
class cognite.client.data_classes.contextualization.FeatureParameters(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource

asset_tag_detection_parameters = 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 = None
people_detection_parameters = None
personal_protective_equipment_detection_parameters = None
text_detection_parameters = 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.FileReference(file_id: Optional[int] = None, file_external_id: Optional[str] = None, first_page: Optional[int] = None, last_page: Optional[int] = None)

Bases: object

to_api_item() → Dict[str, Union[str, int, Dict[str, int]]]
class cognite.client.data_classes.contextualization.IndustrialObjectDetectionParameters(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource, cognite.client.data_classes.contextualization.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 = 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

Bases: enum.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.PeopleDetectionParameters(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource, cognite.client.data_classes.contextualization.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 = 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(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource, cognite.client.data_classes.contextualization.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 = 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.TextDetectionParameters(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource, cognite.client.data_classes.contextualization.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 = 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: 'Optional[float]' = None)

Bases: object

threshold = None
class cognite.client.data_classes.contextualization.VisionExtractItem(file_id: int = None, predictions: Dict[str, Any] = None, file_external_id: str = None, error_message: str = None, cognite_client: CogniteClient = None)

Bases: cognite.client.data_classes._base.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, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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, **kwargs)

Bases: cognite.client.data_classes.contextualization.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]
errors

Returns a list of all error messages across files

items

Returns a list of all predictions by file

result

Waits for the job to finish and returns the results.

save_predictions(creating_user: Optional[str] = None, creating_app: Optional[str] = None, creating_app_version: Optional[str] = None) → Union[cognite.client.data_classes.annotations.Annotation, cognite.client.data_classes.annotations.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_app (str, optional) – The name of the app from which this annotation was created. Defaults to ‘cognite-sdk-python’.
  • creating_app_version (str, optional) – The version of the app that created this annotation. Must be a valid semantic versioning (SemVer) string. Defaults to client version.
  • creating_user – (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.
Returns:

(suggested) annotation(s) stored in CDF.

Return type:

Union[Annotation, AnnotationList]

to_pandas(expand: Sequence[str] = ('metadata', ), ignore: List[str] = None, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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: Optional[int] = 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) – 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(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource

asset_tag_predictions = 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 = None
people_predictions = None
personal_protective_equipment_predictions = None
text_predictions = 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.VisionFeature

Bases: str, enum.Enum

An enumeration.

ASSET_TAG_DETECTION = 'AssetTagDetection'
INDUSTRIAL_OBJECT_DETECTION = 'IndustrialObjectDetection'
PEOPLE_DETECTION = 'PeopleDetection'
PERSONAL_PROTECTIVE_EQUIPMENT_DETECTION = 'PersonalProtectiveEquipmentDetection'
TEXT_DETECTION = 'TextDetection'
beta_features = <bound method VisionFeature.beta_features of <enum 'VisionFeature'>>
class cognite.client.data_classes.contextualization.VisionJob(job_id: int = None, model_id: int = None, status: str = None, error_message: str = None, created_time: int = None, start_time: int = None, status_time: int = None, status_path: str = None, job_token: str = None, cognite_client: CogniteClient = None)

Bases: cognite.client.data_classes.contextualization.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]
result

Waits for the job to finish and returns the results.

to_pandas(expand: Sequence[str] = ('metadata', ), ignore: List[str] = None, camel_case: bool = False) → pandas.DataFrame

Convert the instance into a pandas DataFrame.

Parameters:
  • expand (List[str]) – List of row keys to expand, only works if the value is a Dict. Will expand metadata by default.
  • ignore (List[str]) – 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: Optional[int] = 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) – Time out after this many seconds. (None means wait indefinitely)
  • interval (int) – Poll status every this many seconds.
Raises:

ModelFailedException – The model fit failed.

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource

confidence = 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.images.ObjectDetection(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource

bounding_box = 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]
polygon = None
polyline = 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.images.TextRegion(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.VisionResource

confidence = 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.BoundingBox(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.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.CdfResourceRef(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.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 = None
id = 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.Point(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.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(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.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.Polygon(*args: 'Any', **kwargs: 'Any') → 'CogniteResource'

Bases: cognite.client.data_classes.annotation_types.primitives.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

Bases: cognite.client.data_classes._base.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