models package#

Subpackages#

Submodules#

framework_data module#

class models.framework_data.FrameworkData(sampling_frequency_hz: float | None = None, channels: List[str] | None = None)[source]#

Bases: object

This class is used to store data in a format that is compatible with the framework. It is used to store data that is used by the framework, such as the data that is used to train the model, or the data that is used to test the model. It is also used to store the data that is output by the model, such as the predictions that the model makes, or the data that is used to evaluate the model.

Parameters:
  • sampling_frequency_hz (float, optional) – The sampling frequency of the data. Defaults to None.

  • channels (List[str], optional) – The names of the channels that the data is stored on. Defaults to None.

Raises:

NonCompatibleData – Raised when the data that is being input is not compatible with the data that is already stored in the FrameworkData object.

extend(data: FrameworkData)[source]#

This method is used to extend the FrameworkData object with the data that is input. The data that is input is checked to ensure that it is compatible with the data that is already stored in the FrameworkData object. If the data is compatible, then the data is extended. If the data is not compatible, then an exception is raised.

Parameters:

data (FrameworkData) – The data that is to be extended.

Raises:

NonCompatibleData – Raised when the data that is being input is not compatible with the data that is already stored in the FrameworkData object.

Returns:

None

classmethod from_multi_channel(sampling_frequency_hz: float, channels: List[str], data: List[list])[source]#

This method is used to create a FrameworkData object from multiple channels of data.

Parameters:
  • sampling_frequency_hz (float) – The sampling frequency of the data.

  • channels (List[str]) – The names of the channels that the data is stored on.

Returns:

A FrameworkData object that contains the data that was input.

Return type:

FrameworkData

classmethod from_single_channel(sampling_frequency_hz: float, data: list)[source]#

This method is used to create a FrameworkData object from a single channel of data.

Parameters:
  • sampling_frequency_hz (float) – The sampling frequency of the data.

  • data (list) – The data that is to be stored in the FrameworkData object.

Returns:

A FrameworkData object that contains the data that was input.

Return type:

FrameworkData

get_channels_as_set()[source]#

This method is used to get the channels that the data is stored on as a set. If the channels have not been set, then the channels are set to the default channel name, and the channels are returned as a set.

Parameters:

None

Returns:

The channels that the data is stored on as a set.

Return type:

set

get_data() Dict[str, list][source]#

This method is used to get the all data that is stored in the FrameworkData object.

Parameters:

None

Returns:

All the data that is stored in the FrameworkData object.

Return type:

dict

get_data_as_2d_array() List[list][source]#

This method is used to get the data that is stored in the FrameworkData object as a 2D array. The data is returned as a list of lists. Each list in the list of lists is a channel of data.

Parameters:

None

Returns:

The data that is stored in the FrameworkData object as a 2D array.

Return type:

List[list]

get_data_at_index(index: int) Dict[str, list][source]#

This method is used to get the data that is stored in the FrameworkData object at a specific index. It basically returns the data at the specified index for each channel in the FrameworkData object. This is used to get the data at a specific time step.

Parameters:

index (int) – The index that you want the data from.

Returns:

The data that is stored in the FrameworkData object at the specified index.

Return type:

Dict[str, list]

get_data_count()[source]#

This method is used to get the number of data points that are stored in the FrameworkData object. This is normally used to check that the data that is input is compatible with the data that is already stored in the FrameworkData object.

We only return the first channel length because we have already checked that all channels have the same length. When there is no channels, we return 0

Parameters:

None

Returns:

The number of data points that are stored in the FrameworkData object.

Return type:

int

get_data_on_channel(channel: str) list[source]#

This method is used to get the data that is stored on a specific channel in the FrameworkData object.

Parameters:

channel (str) – The channel that the data is to be retrieved from.

Returns:

The data that is stored on the specified channel in the FrameworkData object.

Return type:

list

get_data_single_channel() list[source]#

This method is used to get the data that is stored on the first channel in the FrameworkData object. Since no channel is specified, the first channel is returned.

Parameters:

None

Raises:

NonCompatibleData – Raised when the data that is being input is not compatible with the data that is already stored in the FrameworkData object.

Returns:

The data that is stored on the first channel in the FrameworkData object.

Return type:

list

has_data() bool[source]#

This method is used to check if the FrameworkData object has any data stored in it.

Parameters:

None

Returns:

True if the FrameworkData object has data stored in it, False otherwise.

Return type:

bool

input_2d_data(data: List[list])[source]#

This method is used to input 2D data into the FrameworkData object. A 2D data is a list of lists. Each list in the list of lists is a channel of data. The data is checked to ensure that it is compatible with the data that is already stored in the FrameworkData object. If the data is compatible, then the data is input. If the data is not compatible, then an exception is raised.

Parameters:

data (List[list]) – The data that is to be input.

Raises:

NonCompatibleData – Raised when the data that is being input is not compatible with the data that is already stored in the FrameworkData object.

Returns:

None

input_data_on_channel(data: list = [], channel: str | None = None)[source]#

This method is used to input data onto a specific channel in the FrameworkData object.

Parameters:
  • data (list, optional) – The data that is to be input. Defaults to [].

  • channel (str, optional) – The channel that the data is to be input on. Defaults to None.

Returns:

None

is_1d() bool[source]#

This method is used to check if the FrameworkData object has data stored in it on only one channel.

Parameters:

None

Returns:

True if the FrameworkData object has data stored in it on only one channel, otherwise False.

Return type:

bool

rename_channel(current_name: str, new_name: str)[source]#

This method is used to rename a given channel stored in FrameworkData.

Parameters:
  • current_name – Existing channel key

  • new_name – Key to replace existing channel key

Returns:

None

Return type:

None

splice(start_index: int, count: int) FrameworkData[source]#

This method is used remove a given number of data points from a starting index and returns the removed items.

Parameters:
  • start_index – index of removal start

  • count – number of data points to be removed

Returns:

FrameworkData with all original channels, and removed data.

Return type:

FrameworkData

Module contents#