Barrel class

This file contains the class which computes statistics from numpy arrays to turn components into features.

class surfboard.statistics.Barrel(component)

This class is used to instantiate components computed in the surfboard package. It helps us compute statistics on these components.

compute_statistics(statistic_list)

Compute statistics on self.component using a list of strings which identify which statistics to compute.

Parameters:statistic_list (list of str) – list of strings representing Barrel methods to be called.
Returns:Dictionary mapping str to float.
Return type:dict
get_first_derivative()

Compute the “first derivative” of self.component. Remember that self.component is of the shape [n_feats, T].

Returns:First empirical derivative.
Return type:np.array, [n_feats, T - 1]
get_second_derivative()

Compute the “second derivative” of self.component. Remember that self.component is of the shape [n_feats, T].

Returns:second empirical derivative.
Return type:np.array, [n_feats, T - 2]
max()

Compute the max of self.component on the last dimensions.

Returns:
The maximum of each individual dimension
in self.component
Return type:np.array, [n_feats, ]
min()

Compute the min of self.component on the last dimension.

Returns:
The minimum of each individual dimension
in self.component
Return type:np.array, [n_feats, ]
mean()

Compute the mean of self.component on the last dimension (time).

Returns:
The mean of each individual dimension
in self.component
Return type:np.array, [n_feats, ]
first_derivative_mean()

Compute the mean of the first empirical derivative (delta coefficient) on the last dimension (time).

Returns:
The mean of the first delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
second_derivative_mean()

Compute the mean of the second empirical derivative (2nd delta coefficient) on the last dimension (time).

Returns:
The mean of the second delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
std()

Compute the standard deviation of self.component on the last dimension (time).

Returns:
The standard deviation of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
first_derivative_std()

Compute the std of the first empirical derivative (delta coefficient) on the last dimension (time).

Returns:
The std of the first delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
second_derivative_std()

Compute the std of the second empirical derivative (2nd delta coefficient) on the last dimension (time).

Returns:
The std of the second delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
skewness()

Compute the skewness of self.component on the last dimension (time)

Returns:
The skewness of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
first_derivative_skewness()

Compute the skewness of the first empirical derivative (delta coefficient) on the last dimension (time).

Returns:
The skewness of the first delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
second_derivative_skewness()

Compute the skewness of the second empirical derivative (2nd delta coefficient) on the last dimension (time).

Returns:
The skewness of the second delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
kurtosis()

Compute the kurtosis of self.component on the last dimension (time)

Returns:
The kurtosis of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
first_derivative_kurtosis()

Compute the kurtosis of the first empirical derivative (delta coefficient) on the last dimension (time).

Returns:
The kurtosis of the first delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
second_derivative_kurtosis()

Compute the kurtosis of the second empirical derivative (2nd delta coefficient) on the last dimension (time).

Returns:
The kurtosis of the second delta coefficient
of each individual dimension in self.component
Return type:np.array, [n_feats, ]
first_quartile()

Compute the first quartile on the last dimension (time).

Returns:
The first quartile of each individual dimension
in self.component
Return type:np.array, [n_feats, ]
second_quartile()

Compute the second quartile on the last dimension (time). Same as the median.

Returns:
The second quartile of each individual
dimension in self.component (same as the median)
Return type:np.array, [n_feats, ]
third_quartile()

Compute the third quartile on the last dimension (time)

Returns:
The third quartile of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
q2_q1_range()

Compute second and first quartiles. Return q2 - q1

Returns:
The q2 - q1 range of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
q3_q2_range()

Compute third and second quartiles. Return q3 - q2

Returns:
The q3 - q2 range of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
q3_q1_range()

Compute third and first quartiles. Return q3 - q1

Returns:
The q3 - q1 range of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
percentile_1()

Compute the 1% percentile.

Returns:
The 1st percentile of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
percentile_99()

Compute the 99% percentile.

Returns:
The 99th percentile of each individual
dimension in self.component
Return type:np.array, [n_feats, ]
percentile_1_99_range()

Compute 99% percentile and 1% percentile. Return the range.

Returns:
The 99th - 1st percentile range of each
individual dimension in self.component
Return type:np.array, [n_feats, ]
linear_regression_offset()

Consider each row of self.component as a time series over which we fit a line. Return the offset of that fitted line.

Returns:
The linear regression offset of each
individual dimension in self.component
Return type:np.array, [n_feats, ]
linear_regression_slope()

Consider each row of self.component as a time series over which we fit a line. Return the slope of that fitted line.

Returns:
The linear regression slope of each
individual dimension in self.component
Return type:np.array, [n_feats, ]
linear_regression_mse()

Fit a line to the data. Compute the MSE.

Returns:
The linear regression MSE of each
individual dimension in self.component
Return type:np.array, [n_feats, ]