learn_api module#

class edgeimpulse_api.api.learn_api.LearnApi(api_client=None)[source]#

Bases: object

add_keras_files(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
zip: StrictStr,
**kwargs,
) GenericApiResponse[source]#

Add Keras files

Add Keras block files with the contents of a zip. This is an internal API.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • zip (str) – (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GenericApiResponse

anomaly_trained_features(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
feature_ax1: StrictInt[StrictInt],
feature_ax2: StrictInt[StrictInt],
**kwargs,
) AnomalyTrainedFeaturesResponse[source]#

Trained features

Get a sample of trained features, this extracts a number of samples and their features.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • feature_ax1 (int) – Feature axis 1 (required)

  • feature_ax2 (int) – Feature axis 2 (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

AnomalyTrainedFeaturesResponse

anomaly_trained_features_per_sample(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
sample_id: StrictInt[StrictInt],
**kwargs,
) AnomalyTrainedFeaturesResponse[source]#

Trained features for sample

Get trained features for a single sample. This runs both the DSP prerequisites and the anomaly classifier.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • sample_id (int) – Sample ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

AnomalyTrainedFeaturesResponse

download_keras_data(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) str[source]#

Download Keras data export

Download the data of an exported Keras block - needs to be exported via ‘exportKerasBlockData’ first

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

str

download_keras_export(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) str[source]#

Download Keras export

Download an exported Keras block - needs to be exported via ‘exportKerasBlock’ first

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

str

download_learn_model(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
model_download_id: StrictStr[StrictStr],
**kwargs,
) str[source]#

Download trained model

Download a trained model for a learning block. Depending on the block this can be a TensorFlow model, or the cluster centroids.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • model_download_id (str) – Model download ID, which can be obtained from the project information (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

str

download_pretrained_model(
project_id: StrictInt[StrictInt],
pretrained_model_download_type: StrictStr,
**kwargs,
) str[source]#

Download pretrained model

Download a pretrained model file

Parameters:
  • project_id (int) – Project ID (required)

  • pretrained_model_download_type (str) – (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

str

get_anomaly(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) AnomalyResponse[source]#

Anomaly information

Get information about an anomaly block, such as its dependencies. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

AnomalyResponse

get_anomaly_metadata(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) AnomalyModelMetadata[source]#

Anomaly metadata

Get metadata about a trained anomaly block. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

AnomalyModelMetadata

get_gmm_metadata(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) AnomalyGmmMetadata[source]#

Anomaly GMM metadata

Get raw model metadata of the Gaussian mixture model (GMM) for a trained anomaly block. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

AnomalyGmmMetadata

get_keras(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) KerasResponse[source]#

Keras information

Get information about a Keras block, such as its dependencies. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

KerasResponse

get_keras_data_explorer_features(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) GetDataExplorerFeaturesResponse[source]#

Get data explorer features

t-SNE2 output of the raw dataset using embeddings from this Keras block

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GetDataExplorerFeaturesResponse

get_keras_metadata(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) KerasModelMetadata[source]#

Keras metadata

Get metadata about a trained Keras block. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

KerasModelMetadata

get_learn_x_data(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) str[source]#

Download data

Download the processed data for this learning block. This is data already processed by the signal processing blocks.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

str

get_learn_y_data(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
**kwargs,
) str[source]#

Download labels

Download the labels for this learning block. This is data already processed by the signal processing blocks. Not all blocks support this function. If so, a GenericApiResponse is returned with an error message.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

str

get_pretrained_model_info(
project_id: StrictInt[StrictInt],
**kwargs,
) GetPretrainedModelResponse[source]#

Get pretrained model

Receive info back about the earlier uploaded pretrained model (via uploadPretrainedModel) input/output tensors. If you want to deploy a pretrained model from the API, see startDeployPretrainedModelJob.

Parameters:
  • project_id (int) – Project ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GetPretrainedModelResponse

profile_pretrained_model(
project_id: StrictInt[StrictInt],
**kwargs,
) StartJobResponse[source]#

Profile pretrained model

Returns the latency, RAM and ROM used for the pretrained model - upload first via uploadPretrainedModel. This is using the project’s selected latency device. Updates are streamed over the websocket API (or can be retrieved through the /stdout endpoint). Use getProfileTfliteJobResult to get the results when the job is completed.

Parameters:
  • project_id (int) – Project ID (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

StartJobResponse

save_pretrained_model_parameters(
project_id: StrictInt[StrictInt],
save_pretrained_model_request: SavePretrainedModelRequest | None = None,
**kwargs,
) GenericApiResponse[source]#

Save parameters for pretrained model

Save input / model configuration for a pretrained model. This overrides the current impulse. If you want to deploy a pretrained model from the API, see startDeployPretrainedModelJob.

Parameters:
  • project_id (int) – Project ID (required)

  • save_pretrained_model_request (SavePretrainedModelRequest) –

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GenericApiResponse

set_anomaly(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
set_anomaly_parameter_request: SetAnomalyParameterRequest,
**kwargs,
) GenericApiResponse[source]#

Anomaly settings

Configure the anomaly block, such as its minimum confidence score. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • set_anomaly_parameter_request (SetAnomalyParameterRequest) – (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GenericApiResponse

set_keras(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
set_keras_parameter_request: SetKerasParameterRequest,
**kwargs,
) GenericApiResponse[source]#

Keras settings

Configure the Keras block, such as its minimum confidence score. Use the impulse blocks to find the learnId.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • set_keras_parameter_request (SetKerasParameterRequest) – (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GenericApiResponse

test_pretrained_model(
project_id: StrictInt[StrictInt],
test_pretrained_model_request: TestPretrainedModelRequest | None = None,
**kwargs,
) TestPretrainedModelResponse[source]#

Test pretrained model

Test out a pretrained model (using raw features) - upload first via uploadPretrainedModel. If you want to deploy a pretrained model from the API, see startDeployPretrainedModelJob.

Parameters:
  • project_id (int) – Project ID (required)

  • test_pretrained_model_request (TestPretrainedModelRequest) –

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

TestPretrainedModelResponse

upload_keras_files(
project_id: StrictInt[StrictInt],
learn_id: StrictInt[StrictInt],
zip: StrictStr,
**kwargs,
) GenericApiResponse[source]#

Upload Keras files

Replace Keras block files with the contents of a zip. This is an internal API.

Parameters:
  • project_id (int) – Project ID (required)

  • learn_id (int) – Learn Block ID, use the impulse functions to retrieve the ID (required)

  • zip (str) – (required)

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

GenericApiResponse

upload_pretrained_model(
project_id: StrictInt[StrictInt],
model_file: StrictStr,
model_file_name: StrictStr,
model_file_type: StrictStr,
representative_features: StrictStr | None = None,
device: StrictStr | None[StrictStr | None] = None,
**kwargs,
) StartJobResponse[source]#

Upload a pretrained model

Upload a pretrained model and receive info back about the input/output tensors. If you want to deploy a pretrained model from the API, see startDeployPretrainedModelJob.

Parameters:
  • project_id (int) – Project ID (required)

  • model_file (str) – (required)

  • model_file_name (str) – (required)

  • model_file_type (str) – (required)

  • representative_features (str) –

  • device (str) – MCU used for calculating latency, query latencyDevices in listProject for a list of supported devices (and use the "mcu" property here). If this is kept empty then we’ll show an overview of multiple devices.

  • async_req (bool, optional) – Whether to execute the request asynchronously.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _request_timeout – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

Returns:

Returns the result object. If the method is called asynchronously, returns the request thread.

Return type:

StartJobResponse