learn_api

edgeimpulse_api v1.0.0

edgeimpulse_api.api.learn_api module

class edgeimpulse_api.api.learn_api.LearnApi(api_client=None)

Bases: object

anomaly_trained_features(project_id: StrictInt, learn_id: StrictInt, feature_ax1: StrictInt, feature_ax2: StrictInt, **kwargs)

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.

anomaly_trained_features_per_sample(project_id: StrictInt, learn_id: StrictInt, sample_id: StrictInt, **kwargs)

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.

download_keras_data(project_id: StrictInt, learn_id: StrictInt, **kwargs)

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, learn_id: StrictInt, **kwargs)

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, learn_id: StrictInt, model_download_id: StrictStr, **kwargs)

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

get_anomaly(project_id: StrictInt, learn_id: StrictInt, **kwargs)

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, learn_id: StrictInt, **kwargs)

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.

get_keras(project_id: StrictInt, learn_id: StrictInt, **kwargs)

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, learn_id: StrictInt, **kwargs)

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.

get_keras_metadata(project_id: StrictInt, learn_id: StrictInt, **kwargs)

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.

get_learn_x_data(project_id: StrictInt, learn_id: StrictInt, **kwargs)

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, learn_id: StrictInt, **kwargs)

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, **kwargs)

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.

profile_pretrained_model(project_id: StrictInt, **kwargs)

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, save_pretrained_model_request: Optional[SavePretrainedModelRequest] = None, **kwargs)

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.

set_anomaly(project_id: StrictInt, learn_id: StrictInt, set_anomaly_parameter_request: SetAnomalyParameterRequest, **kwargs)

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.

set_keras(project_id: StrictInt, learn_id: StrictInt, set_keras_parameter_request: SetKerasParameterRequest, **kwargs)

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.

test_pretrained_model(project_id: StrictInt, test_pretrained_model_request: Optional[TestPretrainedModelRequest] = None, **kwargs)

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.

upload_keras_files(project_id: StrictInt, learn_id: StrictInt, zip: StrictStr, **kwargs)

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.

upload_pretrained_model(project_id: StrictInt, model_file: StrictStr, model_file_name: StrictStr, model_file_type: StrictStr, representative_features: Optional[StrictStr] = None, device: Optional[StrictStr] = None, **kwargs)

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

Last updated

Was this helpful?