vak.datasets.frame_classification.frames_dataset.FramesDataset#

class vak.datasets.frame_classification.frames_dataset.FramesDataset(dataset_path: str | Path, dataset_df: DataFrame, input_type: str, split: str, sample_ids: ndarray[Any, dtype[_ScalarType_co]], inds_in_sample: ndarray[Any, dtype[_ScalarType_co]], frame_dur: float, subset: str | None = None, item_transform: Callable | None = None)[source]#

Bases: object

A dataset class used for neural network models with the frame classification task, where the source data consists of audio signals or spectrograms of varying lengths.

dataset_path#

Path to directory that represents a frame classification dataset, as created by vak.prep.prep_frame_classification_dataset().

Type:

pathlib.Path

split#

The name of a split from the dataset, one of {‘train’, ‘val’, ‘test’}.

Type:

str

subset#

Name of subset to use. If specified, this takes precedence over split. Subsets are typically taken from the training data for use when generating a learning curve.

Type:

str, optional

dataset_df#

A frame classification dataset, represented as a pandas.DataFrame. This will be only the rows that correspond to either subset or split from the dataset_df that was passed in when instantiating the class.

Type:

pandas.DataFrame

frames_paths#

Paths to npy files containing frames, either spectrograms or audio signals that are input to the model.

Type:

numpy.ndarray

frame_labels_paths#

Paths to npy files containing vectors with a label for each frame. The targets for the outputs of the model.

Type:

numpy.ndarray

input_type#

The type of input to the neural network model. One of {‘audio’, ‘spect’}.

Type:

str

sample_ids#

Indexing vector representing which sample from the dataset every frame belongs to.

Type:

numpy.ndarray

inds_in_sample#

Indexing vector representing which index within each sample from the dataset that every frame belongs to.

Type:

numpy.ndarray

frame_dur#

Duration of a frame, i.e., a single sample in audio or a single timebin in a spectrogram.

Type:

float

item_transform#

Transform applied to each item \((x, y)\) returned by FramesDataset.__getitem__().

Type:

callable, optional

__init__(dataset_path: str | Path, dataset_df: DataFrame, input_type: str, split: str, sample_ids: ndarray[Any, dtype[_ScalarType_co]], inds_in_sample: ndarray[Any, dtype[_ScalarType_co]], frame_dur: float, subset: str | None = None, item_transform: Callable | None = None)[source]#

Initialize a new instance of a FramesDataset.

Parameters:
  • dataset_path (pathlib.Path) – Path to directory that represents a frame classification dataset, as created by vak.prep.prep_frame_classification_dataset().

  • dataset_df (pandas.DataFrame) – A frame classification dataset, represented as a pandas.DataFrame.

  • input_type (str) – The type of input to the neural network model. One of {‘audio’, ‘spect’}.

  • split (str) – The name of a split from the dataset, one of {‘train’, ‘val’, ‘test’}.

  • sample_ids (numpy.ndarray) – Indexing vector representing which sample from the dataset every frame belongs to.

  • inds_in_sample (numpy.ndarray) – Indexing vector representing which index within each sample from the dataset that every frame belongs to.

  • frame_dur (float) – Duration of a frame, i.e., a single sample in audio or a single timebin in a spectrogram.

  • subset (str, optional) – Name of subset to use. If specified, this takes precedence over split. Subsets are typically taken from the training data for use when generating a learning curve.

  • item_transform (callable, optional) – Transform applied to each item \((x, y)\) returned by FramesDataset.__getitem__().

Methods

__init__(dataset_path, dataset_df, ...[, ...])

Initialize a new instance of a FramesDataset.

from_dataset_path(dataset_path[, split, ...])

Make a FramesDataset instance, given the path to a frame classification dataset.

Attributes

duration

shape

classmethod from_dataset_path(dataset_path: str | Path, split: str = 'val', subset: str | None = None, item_transform: Callable | None = None)[source]#

Make a FramesDataset instance, given the path to a frame classification dataset.

Parameters:
  • dataset_path (pathlib.Path) – Path to directory that represents a frame classification dataset, as created by vak.prep.prep_frame_classification_dataset().

  • split (str) – The name of a split from the dataset, one of {‘train’, ‘val’, ‘test’}.

  • subset (str, optional) – Name of subset to use. If specified, this takes precedence over split. Subsets are typically taken from the training data for use when generating a learning curve.

  • item_transform (callable, optional) – Transform applied to each item \((x, y)\) returned by FramesDataset.__getitem__().

Returns:

frames_dataset

Return type:

FramesDataset