Skip to content

plot_ccf


method plot_ccf(columns=0, target=0, nlags=None, plot_interval=False, title=None, legend="upper right", figsize=None, filename=None, display=True)[source]
Plot the cross-correlation between two time series.

The Cross-Correlation Function (CCF) plot measures the similarity between features and the target column as a function of the displacement of one series relative to the other. It's similar to the acf plot, where the correlation is plotted against lagged versions of itself. The transparent band represents the 95% confidence interval. This plot is only available for forecast tasks.

Parameterscolumns: int, str, segment, sequence or dataframe, default=0
Columns to plot the periodogram from. If None, it selects all numerical features.

target: int or str, default=0
Target column against which to calculate the correlations. Only for multivariate tasks.

nlags: int or None, default=None
Number of lags to return autocorrelation for. If None, it uses min(10 * np.log10(len(y)), len(y) // 2 - 1). The returned value includes lag 0 (i.e., 1), so the size of the vector is (nlags + 1,).

plot_interval: bool, default=False
Whether to plot the 95% confidence interval.

title: str, dict or None, default=None
Title for the plot.

legend: str, dict or None, default="upper right"
Legend for the plot. See the user guide for an extended description of the choices.

  • If None: No legend is shown.
  • If str: Position to display the legend.
  • If dict: Legend configuration.

figsize: tuple or None, default=None
Figure's size in pixels, format as (x, y). If None, it adapts the size to the number of lags shown.

filename: str, Path or None, default=None
Save the plot using this name. Use "auto" for automatic naming. The type of the file depends on the provided name (.html, .png, .pdf, etc...). If filename has no file type, the plot is saved as html. If None, the plot is not saved.

display: bool or None, default=True
Whether to render the plot. If None, it returns the figure.

Returnsgo.Figure or None
Plot object. Only returned if display=None.


See Also

plot_series

Plot a data series.

plot_decomposition

Plot the trend, seasonality and residuals of a time series.

plot_periodogram

Plot the spectral density of a time series.


Example

>>> from atom import ATOMForecaster
>>> from sktime.datasets import load_macroeconomic

>>> X = load_macroeconomic()

>>> atom = ATOMForecaster(X, random_state=1)
>>> atom.plot_ccf()