eval package

Submodules

eval.data module

data evaluation and visualization functions

eval.data.ADF_test(x)

Augmented Dickey-Fuller test for stationarity

Parameters:

x (array) – The data.

eval.data.get_amp_snr(sig, noise)

Get the signal-to-noise ratio (SNR) of a signal given the noise.

Parameters:
  • sig (array) – The signal.

  • noise (array) – The noise.

Returns:

The SNR.

Return type:

float

eval.data.get_mf_snr(data, T_obs, fs, fmin, psd)

computes the snr of a signal given a PSD starting from a particular frequency index

Parameters:
  • data (array) – The data.

  • T_obs (float) – The observation time.

  • fs (float) – The sampling frequency.

  • fmin (float) – The minimum frequency.

  • psd (array) – The psd.

eval.data.plot_fd_data(f, data, psd)

Plot frequency domain data psd

Parameters:
  • f (array) – The frequency.

  • data (array) – The data.

  • psd (array) – The psd.

eval.data.plot_spectrogram(data, fs)

Plot spectrogram

Parameters:
  • data (array) – The data.

  • fs (float) – The sampling frequency.

eval.data.plot_td_data(t, data)

Plot time domain data

Parameters:
  • t (array) – The time.

  • data (array) – The data.

eval.data.shapiro_wilks_test(x)

Shapiro-Wilks test for normality

Parameters:

x (array) – The data.

eval.data.tukey(M, alpha=0.5)

Tukey window code copied from scipy

Parameters:
  • M (int) – The window length.

  • alpha (float, optional) – The alpha parameter. Defaults to 0.5.

eval.model module

model evaluation and visualization functions

eval.model.bce_loss(inputs, targets, length=None, weight=None, pos_weight=None, reduction='mean', allowed_len_diff=3, label_smoothing=0.0)

Computes binary cross-entropy (BCE) loss. It also applies the sigmoid function directly (this improves the numerical stability).

Args: inputs : torch.Tensor

The output before applying the final softmax Format is [batch[, 1]?] or [batch, frames[, 1]?]. (Works with or without a singleton dimension at the end).

targetstorch.Tensor

The targets, of shape [batch] or [batch, frames].

lengthtorch.Tensor

Length of each utterance, if frame-level loss is desired.

weighttorch.Tensor

A manual rescaling weight if provided it’s repeated to match input tensor shape.

pos_weighttorch.Tensor

A weight of positive examples. Must be a vector with length equal to the number of classes.

allowed_len_diffint

Length difference that will be tolerated before raising an exception.

reduction: str

Options are ‘mean’, ‘batch’, ‘batchmean’, ‘sum’. See pytorch for ‘mean’, ‘sum’. The ‘batch’ option returns one loss per item in the batch, ‘batchmean’ returns sum / batch size.

eval.model.classification_error(probabilities, targets, length=None, allowed_len_diff=3, reduction='mean')

Computes the classification error

Parameters:
  • probabilities (torch.Tensor) – The posterior probabilities

  • targets (torch.Tensor) – The targets

  • length (torch.Tensor) – The length tensor

  • allowed_len_diff (int) – The allowed length difference

  • reduction (str) – The reduction method

eval.model.compute_masked_loss(loss_fn, predictions, targets, length=None, label_smoothing=0.0, reduction='mean')

Compute the average loss

Parameters:
  • loss_fn – The loss function

  • predictions – The predictions tensor

  • targets – The targets tensor

  • length – The length tensor

  • label_smoothing – The label smoothing value

  • reduction – The reduction method

eval.model.get_mask(source, source_lengths)

Get the mask for the source tensor

Parameters:
  • source – The source tensor

  • source_lengths – The source lengths

eval.model.kldiv_loss(log_probabilities, targets, length=None, label_smoothing=0.0, allowed_len_diff=3, pad_idx=0, reduction='mean')

Computes the KL-divergence error at the batch level. This loss applies label smoothing directly to the targets

Args: probabilities : torch.Tensor

The posterior probabilities of shape [batch, prob] or [batch, frames, prob].

targetstorch.Tensor

The targets, of shape [batch] or [batch, frames].

lengthtorch.Tensor

Length of each utterance, if frame-level loss is desired.

allowed_len_diffint

Length difference that will be tolerated before raising an exception.

reductionstr

Options are ‘mean’, ‘batch’, ‘batchmean’, ‘sum’. See pytorch for ‘mean’, ‘sum’. The ‘batch’ option returns one loss per item in the batch, ‘batchmean’ returns sum / batch size.

eval.model.l1_loss(predictions, targets, length=None, allowed_len_diff=3, reduction='mean')

Compute the l1 loss

Parameters:
  • predictions (torch.Tensor) – The predictions tensor

  • targets (torch.Tensor) – The targets tensor

  • length (torch.Tensor) – The length tensor

  • allowed_len_diff (int) – The allowed length difference

  • reduction (str) – The reduction method

eval.model.mse_loss(predictions, targets, length=None, allowed_len_diff=3, reduction='mean')

Compute the mean squared error

Parameters:
  • predictions (torch.Tensor) – The predictions tensor

  • targets (torch.Tensor) – The targets tensor

  • length (torch.Tensor) – The length tensor

  • allowed_len_diff (int) – The allowed length difference

  • reduction (str) – The reduction method

eval.model.nll_loss(log_probabilities, targets, length=None, label_smoothing=0.0, allowed_len_diff=3, reduction='mean')

Computes negative log likelihood loss.

Parameters:
  • log_probabilities (torch.Tensor) – The log probabilities

  • targets (torch.Tensor) – The targets

  • length (torch.Tensor) – The length tensor

  • label_smoothing (float) – The label smoothing value

  • allowed_len_diff (int) – The allowed length difference

  • reduction (str) – The reduction method

eval.model.truncate(predictions, targets, allowed_len_diff=3)

Ensure that predictions and targets are the same length.

Args: predictions : torch.Tensor

First tensor for checking length.

targetstorch.Tensor

Second tensor for checking length.

allowed_len_diffint

Length difference that will be tolerated before raising an exception.

eval.task module

Down stream task evaluation.

eval.task.corner_plot(data, true_value=None)

corner contour plot of the data

Parameters:
  • data – shape (n_samples, n_dims)

  • true_value – shape (n_dims)

eval.task.pp_plot(label, pred)

pp plot of the posterior probabilities

Parameters:
  • label – true label shape (n_events, n_dims)

  • pred – predicted label shape (n_events, n_samples, n_dims)

eval.task.roc_plot(label, pred)

ROC plot of the classifier

Parameters:
  • label – true label shape (n_events, n_dims)

  • pred – predicted label shape (n_events, n_dims)

eval.utils module

class eval.utils.Constant

Bases: object

AU_SI = 149597870700.0
C_SI = 299792458.0
EPS = 1e-08
F0 = 3.168753578687779e-08
GAMMA = 0.5772156649015329
GMSUN = 1.3271244210789466e+20
G_SI = 6.67408e-11
H0 = 67.1
H0_SI = 2.1745629032171688e-18
INVSQRT2 = 0.7071067811865476
INVSQRT3 = 0.5773502691896257
INVSQRT6 = 0.408248290463863
INVSQRTPI = 0.5641895835477563
INVSQRTTWOPI = 0.3989422804014327
MRSUN_SI = 1476.6250615036158
MSUN_SI = 1.98848e+30
MTSUN_SI = 4.925491025873693e-06
Omega0 = 1.9909865927683788e-07
Omegalam = 0.6825
Omegam = 0.3175
PC_SI = 3.085677581491367e+16
PI = 3.141592653589793
PI_2 = 1.5707963267948966
PI_3 = 1.0471975511965979
PI_4 = 0.7853981633974483
SQRT2 = 1.4142135623730951
SQRT3 = 1.7320508075688772
SQRT6 = 2.449489742783178
SQRTPI = 1.772453850905516
SQRTTWOPI = 2.5066282746310007
YRSID_SI = 31558149.763545603

Module contents

Detect EMRI signal using DNN

eval.get_version() str