Continuous
TimeSeries
- class entrainment_metrics.continuous.continuous_time_series.TimeSeries(feature: str, interpausal_units: List[InterPausalUnit], method: str, k: Optional[int] = None, MAX_DEVIATIONS: Optional[int] = None, **kwargs)
The evolution of an acoustic-prosodic feature value in time.
- Parameters
feature (str) – The feature to get the value from each InterPausalUnit
interpausal_units (List[InterPausalUnit]) – An ordered list of InterPausalUnit’s
method (str) – The method to be used to predict
k (Optional[int]) – The amount of neighbors to use in KNeighborsRegressor
MAX_DEVIATIONS (Optional[int]) – The amount of deviation to define an outlier
- end() float
Returns the ending point in time in which the TimeSeries is defined
- feature: str
The feature to get the value from each InterPausalUnit.
- ipus: List[InterPausalUnit]
The InterPausalUnits of the TimeSeries.
- ipus_feature_values: ndarray
The feature values of each ipu.
- outlier_ipus()
Returns the amount of InterPausalUnits with an outlier feature value.
- plot(start: Optional[float] = None, end: Optional[float] = None, granularity: Optional[float] = None, plot_ipus: Optional[bool] = None, show: Optional[bool] = None, save_fname: Optional[str] = None, **kwargs)
Plot the predictions between the given start and end, and with the given granularity.
- Parameters
start (Optional[float]) – A starting point in time to predict. Default is self.start()
end (Optional[float]) – An ending point in time to predict. Default is self.end()
granularity (Optional[float]) – The step in time in which to predict from the time series. Default is 0.01
plot_ipus (Optional[bool]) – Whether to plot also the InterPausalUnits feature values. Default is True.
show (Optional[bool]) – Whether to show the plot. Default is True.
save_fname (Optional[str]) – The fname to pass to plt.savefig(). If provided the plot will be saved.
- predict(X) ndarray
Given a point or an array of points in time, predict the TimeSeries value for the feature of the TimeSeries.
- Parameters
X (float, list or np.ndarray) – A point or an array/list of points in time.
- Returns
The predicted value/s for the point/s in time given.
- Return type
np.ndarray
- predict_interval(start: Optional[float] = None, end: Optional[float] = None, granularity: Optional[float] = None) ndarray
Predict the values of the times series between the given start and end, and with the given granularity.
- Parameters
start (Optional[float]) – A starting point in time to predict. Default is self.start()
end (Optional[float]) – An ending point in time to predict. Default is self.end()
granularity (Optional[float]) – The step in time in which to predict from the time series. Default is 0.01
- Returns
The array with the values predicted.
- Return type
np.ndarray
- start() float
Returns the starting point in time in which the TimeSeries is defined
Metrics
- entrainment_metrics.continuous.metrics.calculate_common_support(time_series_a: TimeSeries, time_series_b: TimeSeries) Tuple[float, float]
Given two times series return the start and end in which both TimeSeries are simultaneously defined.
- Parameters
time_series_a (TimeSeries) – One of the two TimeSeries to calculate the common support from.
time_series_b (TimeSeries) – The other TimeSeries to calculate the common support from.
- Returns
The start and end of the common support respectively.
- Return type
Tuple[float, float]
- entrainment_metrics.continuous.metrics.calculate_metric(metric: str, time_series_a: TimeSeries, time_series_b: TimeSeries, start: Optional[float] = None, end: Optional[float] = None, granularity: Optional[float] = None, synchrony_deltas: Optional[List[float]] = None, integration_method: Optional[str] = None) float
Calculate entrainment metrics given a times series from each speaker
Metrics avaible: ‘proximity’, ‘convergence’ (AKA ‘pearson’) and ‘synchrony’
- Parameters
metric (str) – The metric to be calculated (“synchrony”, “proximity”, or “convergence”)
time_series_a (TimeSeries) – One of the two TimeSeries to calculate the metric from.
time_series_b (TimeSeries) – The other TimeSeries to calculate the metric from.
start (Optional[float]) – A starting point in time to calculate the metric.
end (Optional[float]) – An ending point in time to calculate the metric.
granularity (Optional[float]) – The step in time in which to predict from the time series.
- Returns
The metric value.
- Return type
float
Visualization
- entrainment_metrics.continuous.utils.plot_time_series(time_series_a: TimeSeries, time_series_b: TimeSeries, start: Optional[float] = None, end: Optional[float] = None, granularity: Optional[float] = None, plot_ipus: Optional[bool] = None, legend: Optional[bool] = None, time_series_a_name: Optional[str] = None, time_series_b_name: Optional[str] = None, save_fname: Optional[str] = None, **kwargs)
Plot the predictions of both TimeSeries between the given start and end, and with the given granularity.
- Parameters
time_series_a (TimeSeries) – One of the two TimeSeries to plot.
time_series_b (TimeSeries) – The other TimeSeries to plot.
start (Optional[float]) – A starting point in time to predict. Default is self.start()
end (Optional[float]) – An ending point in time to predict. Default is self.end()
granularity (Optional[float]) – The step in time in which to predict from the time series. Default is 0.01
plot_ipus (Optional[bool]) – Whether to plot also the InterPausalUnits feature values. Default is True.
legend (Optional[bool]) – Whether to display a legend. Default is True.
time_series_a_name (Optional[str]) – The name for the first TimeSeries passed as argument. Default is ‘time_series_a’.
time_series_b_name (Optional[str]) – The name for the second TimeSeries passed as argument. Default is ‘time_series_b’.
save_fname (Optional[str]) – The fname to pass to plt.savefig(). If provided the plot will be saved.