Containers

Classes for data containers. The aim of these data containers it to wrap the data with useful set of method to access and to manipulate the data, as well as load and store it.

These containers are inherited from standard Python containers (e.g. object, list, and dictionary) to allow them to be used together with other tools and libraries.

Basic containers

ObjectContainer

dcase_util.containers.ObjectContainer

Container class for object inherited from standard object class.

Examples how to inherit class from ObjectContainer:

 1class Multiplier(dcase_util.containers.ObjectContainer):
 2    def __init__(self, multiplier=None, **kwargs):
 3        super(Multiplier, self).__init__(**kwargs)
 4        self.multiplier = multiplier
 5
 6    def __str__(self):
 7        ui = dcase_util.ui.FancyStringifier()
 8        output = super(Multiplier, self).__str__()
 9        output+= ui.data(field='multiplier', value=self.multiplier)
10        return output
11
12    def multiply(self, data):
13        return self.multiplier * data
14
15m = Multiplier(10)
16m.show()
17# Multiplier :: Class
18#   multiplier                        : 10
19
20print(m.multiply(5))
21# 50
22
23# Save object
24m.save('test.cpickle')
25
26# Load object
27m2 = Multiplier().load('test.cpickle')
28
29print(m2.multiply(5))
30# 50
31
32m2.show()
33# Multiplier :: Class
34#   filename                          : test.cpickle
35#   multiplier                        : 10

ObjectContainer(*args, **kwargs)

Container class for object inherited from standard object class.

ObjectContainer.load([filename])

Load file

ObjectContainer.save([filename])

Save file

ObjectContainer.show([mode, indent, visualize])

Print container content

ObjectContainer.log([level])

Log container content

DictContainer

dcase_util.containers.DictContainer

Dictionary container class inherited from standard dict class.

Usage examples:

 1import dcase_util
 2
 3d = dcase_util.containers.DictContainer(
 4    {
 5        'test': {
 6            'field1': 1,
 7            'field2': 2,
 8        },
 9        'test2': 100
10    }
11)
12d.show()
13# DictContainer
14#   test
15#     field1                          : 1
16#     field2                          : 2
17#   test2                             : 100
18
19print(d.get_path('test.field1'))
20# 1
21
22print(d.get_path(['test', 'field1']))
23# 1
24
25print(d.get_path('test2'))
26# 100
27
28d.set_path('test.field2', 200)
29print(d.get_path('test.field2'))
30# 200
31
32print(d.get_leaf_path_list())
33# ['test.field1', 'test.field2', 'test2']
34
35print(d.get_leaf_path_list(target_field_startswith='field'))
36# ['test.field1', 'test.field2']
37
38d.show()
39# DictContainer
40#   test
41#     field1                          : 1
42#     field2                          : 200
43#   test2                             : 100

DictContainer(*args, **kwargs)

Dictionary container class inherited from standard dict class.

DictContainer.load([filename, file_format])

Load file

DictContainer.save([filename, file_format])

Save file

DictContainer.show([mode, indent, visualize])

Print container content

DictContainer.log([level])

Log container content

DictContainer.get_path(path[, default, data])

Get value from nested dict with dotted path

DictContainer.set_path(path, new_value[, data])

Set value in nested dict with dotted path

DictContainer.get_leaf_path_list([...])

Get path list to all leaf node in the nested dict.

DictContainer.merge(override[, target])

Recursive dict merge

DictContainer.get_hash_for_path([dotted_path])

Get unique hash string for the data under given path.

DictContainer.get_hash([data])

Get unique hash string (md5) for given parameter dict.

ListContainer

dcase_util.containers.ListContainer

List container class inherited from standard list class.

ListContainer(*args, **kwargs)

List container class inherited from standard list class.

ListContainer.load([filename, headers, ...])

Load file

ListContainer.save([filename, file_format])

Save file

ListContainer.show([mode, indent, visualize])

Print container content

ListContainer.log([level])

Log container content

ListContainer.update(data)

Replace content with given list

ListDictContainer

dcase_util.containers.ListDictContainer

List of dictionaries container class inherited from standard list class.

Usage examples:

 1import dcase_util
 2ld = dcase_util.containers.ListDictContainer(
 3    [
 4        {
 5            'field1': 1,
 6            'field2': 2,
 7        },
 8        {
 9            'field1': 3,
10            'field2': 4,
11        },
12    ]
13)
14ld.show()
15# ListDictContainer
16# [0] =======================================
17#    DictContainer
18#      field1                            : 1
19#      field2                            : 2
20#
21# [1] =======================================
22#    DictContainer
23#      field1                            : 3
24#      field2                            : 4
25
26print(ld.search(key='field1', value=3))
27# DictContainer
28#   field1                            : 3
29#   field2                            : 4
30
31print(ld.get_field(field_name='field2'))
32# [2, 4]

ListDictContainer(*args, **kwargs)

List of dictionaries container class inherited from standard list class.

ListDictContainer.load([filename, fields, ...])

Load file

ListDictContainer.save([filename, fields, ...])

Save file

ListDictContainer.show([mode, indent, visualize])

Print container content

ListDictContainer.log([level])

Log container content

ListDictContainer.search(key, value)

Search in the list of dictionaries

ListDictContainer.get_field(field_name[, ...])

Get all data from field.

RepositoryContainer

dcase_util.containers.RepositoryContainer

Container class for repository, inherited from dcase_util.containers.DictContainer.

RepositoryContainer(*args, **kwargs)

Container class for repository, inherited from DictContainer.

RepositoryContainer.load([filename, file_format])

Load file

RepositoryContainer.save([filename, file_format])

Save file

RepositoryContainer.show([mode, indent, ...])

Print container content

RepositoryContainer.log([level])

Log container content

TextContainer

dcase_util.containers.TextContainer

Container class for text, inherited from dcase_util.containers.ListContainer.

TextContainer(*args, **kwargs)

Container class for text, inherited from ListContainer.

TextContainer.load([filename, headers, ...])

Load file

TextContainer.save([filename, file_format])

Save file

TextContainer.show([mode, indent, visualize])

Print container content

TextContainer.log([level])

Log container content

Data containers

DataContainer

dcase_util.containers.DataContainer

Container class for data, inherited from dcase_util.containers.ObjectContainer.

DataContainer([data, stats, metadata, ...])

Container class for data, inherited from ObjectContainer.

DataContainer.load([filename])

Load file

DataContainer.save([filename])

Save file

DataContainer.show([mode, indent, visualize])

Print container content

DataContainer.log([level])

Log container content

DataContainer.data

Data matrix

DataContainer.shape

Shape of data matrix

DataContainer.length

Number of data columns

DataContainer.frames

Number of data frames

DataContainer.push_processing_chain_item(...)

Push processing chain item

DataContainer.focus_start

Focus segment start

DataContainer.focus_stop

Focus segment stop

DataContainer.stats

Basic statistics of data matrix.

DataContainer.reset_focus()

Reset focus segment

DataContainer.get_focused()

Get focus segment from data array.

DataContainer.freeze()

Freeze focus segment, copy segment to be container's data.

DataContainer.get_frames([frame_ids, frame_hop])

Get frames from data array.

DataContainer.plot([plot, figsize])

Visualize data array.

DataArrayContainer

dcase_util.containers.DataArrayContainer

Container class for data, inherited from dcase_util.containers.DataContainer.

DataArrayContainer([data, stats, metadata, ...])

Array data container class, inherited from DataContainer.

DataArrayContainer.load([filename])

Load file

DataArrayContainer.save([filename])

Save file

DataArrayContainer.show([mode, indent, ...])

Print container content

DataArrayContainer.log([level])

Log container content

DataArrayContainer.data

Data matrix

DataArrayContainer.shape

Shape of data matrix

DataArrayContainer.length

Number of data columns

DataArrayContainer.frames

Number of data frames

DataArrayContainer.push_processing_chain_item(...)

Push processing chain item

DataArrayContainer.focus_start

Focus segment start

DataArrayContainer.focus_stop

Focus segment stop

DataArrayContainer.stats

Basic statistics of data matrix.

DataArrayContainer.reset_focus()

Reset focus segment

DataArrayContainer.get_focused()

Get focus segment from data array.

DataArrayContainer.freeze()

Freeze focus segment, copy segment to be container's data.

DataArrayContainer.get_frames([frame_ids, ...])

Get frames from data array.

DataArrayContainer.plot([plot, figsize])

Visualize data array.

DataMatrix2DContainer

dcase_util.containers.DataMatrix2DContainer

DataMatrix2DContainer is data container for two-dimensional data matrix (numpy.ndarray).

Basic usage examples:

 1# Initialize container with random matrix 10x100, and set time resolution to 20ms
 2data_container = dcase_util.containers.DataMatrix2DContainer(
 3  data=numpy.random.rand(10,100),
 4  time_resolution=0.02
 5)
 6
 7# When storing, e.g., acoustic features, time resolution corresponds to feature extraction frame hop length.
 8
 9# Access data matrix directly
10print(data_container.data.shape)
11# (10, 100)
12
13# Show container information
14data_container.show()
15# DataMatrix2DContainer :: Class
16#   Data
17#     data                            : matrix (10,100)
18#     Dimensions
19#       time_axis                     : 1
20#       data_axis                     : 0
21#     Timing information
22#       time_resolution               : 0.02 sec
23#   Meta
24#     stats                           : Calculated
25#     metadata                        : -
26#     processing_chain                : -
27#   Duration
28#       Frames                        : 100
29#       Seconds                       : 2.00 sec

The container has focus mechanism to flexibly capture only part of the data matrix. Focusing can be done based on time (in seconds, if time resolution is defined), or based on frame ids.

Examples using focus mechanism, accessing data and visualizing data:

 1# Using focus to get part data between 0.5 sec and 1.0 sec
 2print(data_container.set_focus(start_seconds=0.5, stop_seconds=1.0).get_focused().shape)
 3# (10, 25)
 4
 5# Using focus to get part data between frame 10 and 50
 6print(data_container.set_focus(start=10, stop=50).get_focused().shape)
 7# (10, 40)
 8
 9# Resetting focus and accessing full data matrix
10data_container.reset_focus()
11print(data_container.get_focused().shape)
12# (10, 100)
13
14# Access frames 1, 2, 10, and 30
15data_container.get_frames(frame_ids=[1,2,10,30])
16
17# Access frames 1-5, and only first value per column
18data_container.get_frames(frame_ids=[1,2,3,4,5], vector_ids=[0])
19
20# Transpose matrix
21transposed_data = data_container.T
22print(transposed_data.shape)
23# (100, 10)
24
25# Plot data
26data_container.plot()

DataMatrix2DContainer([data, stats, ...])

Two-dimensional data matrix container class, inherited from DataContainer.

DataMatrix2DContainer.load([filename])

Load file

DataMatrix2DContainer.save([filename])

Save file

DataMatrix2DContainer.show([mode, indent, ...])

Print container content

DataMatrix2DContainer.log([level])

Log container content

DataMatrix2DContainer.data

Data matrix

DataMatrix2DContainer.shape

Shape of data matrix

DataMatrix2DContainer.length

Number of data columns

DataMatrix2DContainer.frames

Number of data frames

DataMatrix2DContainer.vector_length

Data vector length

DataMatrix2DContainer.push_processing_chain_item(...)

Push processing chain item

DataMatrix2DContainer.focus_start

Focus segment start

DataMatrix2DContainer.focus_stop

Focus segment stop

DataMatrix2DContainer.T

Transposed data in a data container

DataMatrix2DContainer.stats

Basic statistics of data matrix.

DataMatrix2DContainer.reset_focus()

Reset focus segment

DataMatrix2DContainer.get_focused()

Get focus segment from data matrix.

DataMatrix2DContainer.freeze()

Freeze focus segment, copy segment to be container's data.

DataMatrix2DContainer.get_frames([...])

Get frames from data matrix.

DataMatrix2DContainer.plot([plot, ...])

Visualize data matrix.

DataMatrix3DContainer

dcase_util.containers.DataMatrix3DContainer

DataMatrix3DContainer([data, stats, ...])

Three-dimensional data matrix container class, inherited from DataMatrix2DContainer.

DataMatrix3DContainer.load([filename])

Load file

DataMatrix3DContainer.save([filename])

Save file

DataMatrix3DContainer.show([mode, indent, ...])

Print container content

DataMatrix3DContainer.log([level])

Log container content

DataMatrix3DContainer.data

Data matrix

DataMatrix3DContainer.length

Number of data columns

DataMatrix3DContainer.frames

Number of data frames

BinaryMatrix2DContainer

dcase_util.containers.BinaryMatrix2DContainer

BinaryMatrix2DContainer([data, ...])

Two-dimensional data matrix container class, inherited from DataContainer.

BinaryMatrix2DContainer.load([filename])

Load file

BinaryMatrix2DContainer.save([filename])

Save file

BinaryMatrix2DContainer.show([mode, indent, ...])

Print container content

BinaryMatrix2DContainer.log([level])

Log container content

BinaryMatrix2DContainer.data

Data matrix

BinaryMatrix2DContainer.length

Number of data columns

BinaryMatrix2DContainer.frames

Number of data frames

BinaryMatrix2DContainer.pad(length[, ...])

Pad binary matrix along time axis

BinaryMatrix2DContainer.plot([plot, ...])

Visualize binary matrix, and optionally synced data matrix.

DataRepository

dcase_util.containers.DataRepository

DataRepository is container which can be used to store multiple other data containers. Repository stores data with two level information: label and stream. The label is higher level key and stream is second level one. Repositories can be used, for example, to store multiple different acoustic features all related to same audio signal. Stream id can be used to store features extracted from different audio channels. Later features can be access using extractor label and stream id.

Usage examples:

 1# Initialize container with data
 2data_repository = dcase_util.containers.DataRepository(
 3    data={
 4        'label1': {
 5            'stream0': {
 6                'data': 100
 7            },
 8            'stream1': {
 9                'data': 200
10            }
11        },
12        'label2': {
13            'stream0': {
14                'data': 300
15            },
16            'stream1': {
17                'data': 400
18            }
19        }
20    }
21)
22# Show container information::
23data_repository. show()
24# DataRepository :: Class
25#     Repository info
26#       Item class                    : DataMatrix2DContainer
27#       Item count                    : 2
28#       Labels                        : ['label1', 'label2']
29#     Content
30#       [label1][stream1]             : {'data': 200}
31#       [label1][stream0]             : {'data': 100}
32#       [label2][stream1]             : {'data': 400}
33#       [label2][stream0]             : {'data': 300}
34
35# Accessing data inside repository
36data_repository.get_container(label='label1',stream_id='stream1')
37# {'data': 200}
38
39# Setting data
40data_repository.set_container(label='label3',stream_id='stream0', container={'data':500})
41data_repository. show()
42# DataRepository :: Class
43#     Repository info
44#       Item class                    : DataMatrix2DContainer
45#       Item count                    : 3
46#       Labels                        : ['label1', 'label2', 'label3']
47#     Content
48#       [label1][stream1]             : {'data': 200}
49#       [label1][stream0]             : {'data': 100}
50#       [label2][stream1]             : {'data': 400}
51#       [label2][stream0]             : {'data': 300}
52#       [label3][stream0]             : {'data': 500}

DataRepository([data, filename, ...])

Data repository container class to store multiple DataContainers together.

DataRepository.load([filename, ...])

Load file list

DataRepository.get_container(label[, stream_id])

Get container from repository

DataRepository.set_container(container, label)

Store container to repository

DataRepository.push_processing_chain_item(...)

Push processing chain item

DataRepository.plot([plot, figsize])

Visualize data stored in the repository.

Audio containers

AudioContainer

dcase_util.containers.AudioContainer

AudioContainer is data container for multi-channel audio. It reads many formats (WAV, FLAC, M4A, WEBM) and writes WAV and FLAC files. Downloading audio content directly from Youtube is also supported.

Basic usage examples:

 1# Generating two-channel audio
 2audio_container = dcase_util.containers.AudioContainer(fs=44100)
 3t = numpy.linspace(0, 2, 2 * audio_container.fs, endpoint=False)
 4x1 = numpy.sin(220 * 2 * numpy.pi * t)
 5x2 = numpy.sin(440 * 2 * numpy.pi * t)
 6audio_container.data = numpy.vstack([x1, x2])
 7
 8audio_container.show()
 9# AudioContainer :: Class
10#  Sampling rate                     : 44100
11#     Channels                        : 2
12#   Duration
13#     Seconds                         : 2.00 sec
14#     Milliseconds                    : 2000.00 ms
15#     Samples                         : 88200 samples
16
17# Loading audio file
18audio_container = dcase_util.containers.AudioContainer().load(
19  filename=dcase_util.utils.Example.audio_filename()
20)
21
22# Loading audio content from Youtube
23audio_container = dcase_util.containers.AudioContainer().load_from_youtube(
24  query_id='2ceUOv8A3FE',
25  start=1,
26  stop=5
27)

The container has focus mechanism to flexibly capture only part of the audio data while keeping full audio signal intact. Focusing can be done based on time (in seconds, if time resolution is defined), or based on sample ids. Focusing can be done to single channel or mixdown (mono) channels. Audio containers content can be replaced with focus segment by freezing it.

Examples using focus segment mechanism:

 1# Using focus to get part data between 0.5 sec and 1.0 sec
 2print(audio_container.set_focus(start_seconds=0.5, stop_seconds=1.0).get_focused().shape)
 3# (2, 22050)
 4
 5# Using focus to get part data starting 5 sec with 2 sec duration
 6print(audio_container.set_focus(start_seconds=5, duration_seconds=2.0).get_focused().shape)
 7# (2, 88200)
 8
 9# Using focus to get part data starting 5 sec with 2 sec duration, mixdown of two stereo channels
10print(audio_container.set_focus(start_seconds=5, duration_seconds=2.0, channel='mixdown').get_focused().shape)
11# (88200,)
12
13# Using focus to get part data starting 5 sec with 2 sec duration, left of two stereo channels
14print(audio_container.set_focus(start_seconds=5, duration_seconds=2.0, channel='left').get_focused().shape)
15# (88200,)
16
17# Using focus to get part data starting 5 sec with 2 sec duration, seconds audio channel (indexing starts from 0)
18print(audio_container.set_focus(start_seconds=5, duration_seconds=2.0, channel=1).get_focused().shape)
19# (88200,)
20
21# Using focus to get part data between samples 44100 and 88200
22print(audio_container.set_focus(start=44100, stop=88200).get_focused().shape)
23# (2, 44100)
24
25# Resetting focus and accessing full data matrix::
26audio_container.reset_focus()
27print(audio_container.get_focused().shape)
28# (2, 441001)
29
30# Using focus to get part data starting 5 sec with 2 sec duration, and freeze this segment ::
31audio_container.set_focus(start_seconds=5, duration_seconds=2.0).freeze()
32print(audio_container.shape)
33# (2, 88200)

Processing examples:

1# Normalizing audio
2audio_container.normalize()
3
4# Resampling audio to target sampling rate
5audio_container.resample(target_fs=16000)

Visualizations examples:

1# Plotting waveform
2audio_container.plot_wave()
3
4# Plotting spectrogram
5audio_container.plot_spec()

(Source code, png, hires.png, pdf)

_images/containers-1.png

(Source code, png, hires.png, pdf)

_images/containers-2.png

AudioContainer([data, fs, ...])

Audio container class.

AudioContainer.load([filename, fs, mono, ...])

Load file

AudioContainer.load_from_youtube(query_id[, ...])

Load audio data from youtube

AudioContainer.save([filename, bit_depth, ...])

Save audio

AudioContainer.show([mode, indent, visualize])

Print container content

AudioContainer.log([level])

Log container content

AudioContainer.data

Audio data

AudioContainer.focus_start_samples

Focus segment start in samples.

AudioContainer.focus_start_seconds

Focus segment start in seconds.

AudioContainer.focus_stop_samples

Focus segment stop in samples.

AudioContainer.focus_stop_seconds

Focus segment stop in seconds.

AudioContainer.focus_channel

Focus channel

AudioContainer.loaded

Audio load status.

AudioContainer.shape

Audio data shape.

AudioContainer.length

Length of audio data in samples.

AudioContainer.duration_samples

Duration of audio data in samples.

AudioContainer.duration_ms

Duration of audio data in milliseconds.

AudioContainer.duration_sec

Duration of audio data in seconds.

AudioContainer.streams

Rename channels for compatibility.

AudioContainer.empty

Check if audio data is empty.

AudioContainer.reset_focus()

Reset focus segment.

AudioContainer.set_focus([start, stop, ...])

Set focus segment

AudioContainer.get_focused()

Get focus segment from audio data.

AudioContainer.freeze()

Freeze focus segment, copy segment to be container's data.

AudioContainer.frames([frame_length, ...])

Slice audio into overlapping frames.

AudioContainer.normalize([headroom])

Normalize audio data.

AudioContainer.resample(target_fs[, scale, ...])

Resample audio data.

AudioContainer.mixdown()

Mix all audio channels into single channel.

AudioContainer.overlay(audio[, ...])

Simple sample overlay method

AudioContainer.plot([plot_type])

Visualize audio data

AudioContainer.plot_wave([x_axis, ...])

Visualize audio data as waveform.

AudioContainer.plot_spec([spec_type, ...])

Visualize audio data as spectrogram.

Feature containers

FeatureContainer

dcase_util.containers.FeatureContainer

FeatureContainer([data, stats, metadata, ...])

Feature container class for a single feature matrix, inherited from DataContainer.

FeatureRepository

dcase_util.containers.FeatureRepository

FeatureRepository([filename, ...])

Feature repository container class to store multiple FeatureContainers together.

Mapping containers

OneToOneMappingContainer

dcase_util.containers.OneToOneMappingContainer

OneToOneMappingContainer(*args, **kwargs)

Mapping container class for 1:1 data mapping, inherited from DictContainer class.

OneToOneMappingContainer.load([filename])

Load file

OneToOneMappingContainer.save([filename])

Save file

OneToOneMappingContainer.show([mode, ...])

Print container content

OneToOneMappingContainer.log([level])

Log container content

OneToOneMappingContainer.map(key[, default])

Map with a key.

OneToOneMappingContainer.flipped

Exchange map key and value pairs.

Metadata containers

MetaDataItem

dcase_util.containers.MetaDataItem

MetaDataItem(*args, **kwargs)

Meta data item class, inherited from standard dict class.

MetaDataItem.show([mode, indent])

Print container content

MetaDataItem.log([level])

Log container content

MetaDataItem.id

Unique item identifier

MetaDataItem.get_list()

Return item values in a list with specified order.

MetaDataItem.filename

Filename

MetaDataItem.filename_original

Filename

MetaDataItem.scene_label

Scene label

MetaDataItem.event_label

Event label

MetaDataItem.onset

Onset

MetaDataItem.offset

Offset

MetaDataItem.identifier

Identifier

MetaDataItem.source_label

Source label

MetaDataItem.set_label

Set label

MetaDataItem.tags

Tags

MetaDataItem.active_within_segment(start, stop)

Item active withing given segment.

MetaDataContainer

dcase_util.containers.MetaDataContainer

MetaDataContainer(*args, **kwargs)

Meta data container class, inherited from ListDictContainer.

MetaDataContainer.log([level, show_data, ...])

Log container content

MetaDataContainer.log_all([level])

Log container content with all meta data items.

MetaDataContainer.show([mode, indent, ...])

Print container content

MetaDataContainer.show_all([mode, indent])

Print container content with all meta data items.

MetaDataContainer.load([filename, fields, ...])

Load event list from delimited text file (csv-formatted)

MetaDataContainer.save([filename, fields, ...])

Save content to csv file

MetaDataContainer.append(item)

Append item to the meta data list

MetaDataContainer.file_count

Number of files

MetaDataContainer.event_count

Number of events

MetaDataContainer.scene_label_count

Number of unique scene labels

MetaDataContainer.event_label_count

Number of unique event labels

MetaDataContainer.identifier_count

Number of unique identifiers

MetaDataContainer.tag_count

Number of unique tags

MetaDataContainer.unique_files

Unique files

MetaDataContainer.unique_event_labels

Unique event labels

MetaDataContainer.unique_scene_labels

Unique scene labels

MetaDataContainer.unique_tags

Unique tags

MetaDataContainer.unique_identifiers

Unique identifiers

MetaDataContainer.unique_source_labels

Unique source labels

MetaDataContainer.max_offset

Find the offset (end-time) of last event

MetaDataContainer.to_string([ui, indent, ...])

Get container information in a string

MetaDataContainer.filter([filename, ...])

Filter content

MetaDataContainer.filter_time_segment([...])

Filter time segment

MetaDataContainer.process_events([...])

Process event content

MetaDataContainer.map_events(target_event_label)

Map events with varying event labels into single target event label

MetaDataContainer.event_inactivity([...])

Get inactivity segments between events as event list

MetaDataContainer.add_time(time)

Add time offset to event onset and offset timestamps

MetaDataContainer.stats([event_label_list, ...])

Statistics of the container content

MetaDataContainer.scene_stat_counts()

Scene count statistics

MetaDataContainer.event_stat_counts()

Event count statistics

MetaDataContainer.tag_stat_counts()

Tag count statistics

MetaDataContainer.to_event_roll([...])

Event roll

MetaDataContainer.intersection(second_metadata)

Intersection of two meta containers

MetaDataContainer.intersection_report(...)

Intersection report for two meta containers

MetaDataContainer.difference(second_metadata)

Difference of two meta containers

Parameter containers

ParameterContainer

dcase_util.containers.ParameterContainer

ParameterContainer(*args, **kwargs)

Parameter container class for parameters, inherited from DictContainer class.

AppParameterContainer

dcase_util.containers.AppParameterContainer

AppParameterContainer([data, app_base, ...])

Parameter container class for application parameters, inherited from ParameterContainer.

AppParameterContainer.reset([field_labels, ...])

AppParameterContainer.process([...])

Process parameters

AppParameterContainer.process_set(parameters)

Process parameter set

AppParameterContainer.override(override)

Override container content recursively.

AppParameterContainer.get_path_translated(path)

Get data with path, path can contain string constants which will be translated.

AppParameterContainer.set_path_translated(...)

Set data with path, path can contain string constants which will be translated.

AppParameterContainer.update_parameter_set(set_id)

Update active parameter set

AppParameterContainer.set_ids()

Get set ids

AppParameterContainer.set_id_exists(set_id)

Set id exists

AppParameterContainer.active_set()

Get active set id

AppParameterContainer.get_set(set_id)

Get parameter set

DCASEAppParameterContainer

dcase_util.containers.DCASEAppParameterContainer

DCASEAppParameterContainer(*args, **kwargs)

Parameter container class for DCASE application parameter files, inherited from AppParameterContainer.

ParameterListContainer

dcase_util.containers.ParameterListContainer

ParameterListContainer(*args, **kwargs)

Parameter list container, inherited from ListDictContainer.

Probability containers

ProbabilityItem

dcase_util.containers.ProbabilityItem

ProbabilityItem(*args, **kwargs)

Probability data item class, inherited from standard dict class.

ProbabilityItem.show([mode, indent])

Print container content

ProbabilityItem.log([level])

Log container content

ProbabilityItem.filename

Filename

ProbabilityItem.label

Label

ProbabilityItem.probability

Returns

ProbabilityItem.id

Unique item identifier

ProbabilityItem.get_list()

Return item values in a list with specified order.

ProbabilityContainer

dcase_util.containers.ProbabilityContainer

ProbabilityContainer(*args, **kwargs)

Probability data container class, inherited from ListDictContainer.

ProbabilityContainer.show([mode, indent, ...])

Print container content

ProbabilityContainer.log([level])

Log container content

ProbabilityContainer.load([filename, ...])

Load probability list from file

ProbabilityContainer.save([filename, ...])

Save content to csv file

ProbabilityContainer.append(item)

Append item to the meta data list

ProbabilityContainer.unique_files

Unique files

ProbabilityContainer.unique_labels

Unique labels

ProbabilityContainer.unique_indices

Unique indices

ProbabilityContainer.filter([filename, ...])

Filter content

ProbabilityContainer.as_matrix([label_list, ...])

Get probabilities as data matrix.

Mixins

ContainerMixin

dcase_util.containers.ContainerMixin

ContainerMixin(*args, **kwargs)

Container mixin to give class basic container methods.

ContainerMixin.show([mode, indent, visualize])

Print container content

ContainerMixin.log([level])

Log container content

FileMixin

dcase_util.containers.FileMixin

FileMixin(*args, **kwargs)

File mixin to give class methods to load and store content.

FileMixin.get_file_information()

Get file information, filename

FileMixin.detect_file_format([filename])

Detect file format from extension

FileMixin.validate_format()

Validate file format

FileMixin.exists()

Checks that file exists

FileMixin.empty()

Check if file is empty

FileMixin.delimiter([exclude_delimiters])

Use csv.sniffer to guess delimiter for CSV file

FileMixin.is_package([filename])

Determine if the file is compressed package.

PackageMixin

dcase_util.containers.PackageMixin

PackageMixin(*args, **kwargs)

Package mixin to give class basic methods to handle compressed file packages.

PackageMixin.package_password

Package password

PackageMixin.extract([target_path, ...])

Extract the package.