Module Reference

class skccm.skccm.CCM(weights='exp', verbose=False)

Convergent cross mapping for two embedded time series.

Parameters:
  • weights (str) –

    Weighting scheme for predictions. Options:

    • ’exp’ : exponential weighting
  • score (str) –

    How to score the predictions. Options:

    • ’score’
    • ’corrcoef’
  • verbose (bool) – Prints out calculation status.
fit(X1_train, X2_train)

Fit the training data for ccm. Can be thought of as reconstructing the shadow manifolds of each time series.

Amount of near neighbors is set to be embedding dimension plus one. Creates seperate near neighbor regressors for X1 and X2 independently.

Parameters:
  • X1_train (2d array) – Embed time series of shape (num_samps,embed_dim).
  • X2_train (2d array) – Embed time series of shape (num_samps,embed_dim).
predict(X1_test, X2_test, lib_lengths)

Make a prediction.

Parameters:
  • X1_test (2d array) – Embed time series of shape (num_samps,embed_dim).
  • X2_test (2d array) – Embed time series of shape (num_samps,embed_dim).
  • lib_lengths (1d array of ints) – Library lengths to test.
Returns:

  • X1_pred (list of 2d arrays) – Predictions for each library length.
  • X2_pred (list of 2d arrays) – Predictions for each library length.

score(score_metric='corrcoef')

Evalulate the predictions.

Parameters:how (string) – How to score the predictions. Options: - ‘score’ - ‘corrcoef’
Returns:
  • score_1 (2d array) – Scores for the first time series using the weights from the second time series.
  • score_2 (2d array) – Scores for the second time series using the weights from the first time series.
class skccm.skccm.Embed(X)

Embed a time series.

Parameters:X (1D array) – Time series to be embed.
df_mutual_information(max_lag)

Calculates the mutual information along each column of a dataframe.

Ensure that the time series is continuous in time and sampled regularly. You can resample it hourly, daily, minutely etc. if needed.

Parameters:max_lag (int) – maximum amount to shift the time series
Returns:mi – columns are the columns of the original dataframe with rows being the mutual information. shape(max_lag,num_cols)
Return type:dataframe
embed_vectors_1d(lag, embed)

Embeds vectors from a one dimensional time series in m-dimensional space.

Parameters:
  • X (1d array) – Training or testing set.
  • lag (int) – Lag value as calculated from the first minimum of the mutual info.
  • embed (int) – Embedding dimension. How many lag values to take.
  • predict (int) – Distance to forecast (see example).
Returns:

features – Contains all of the embedded vectors. Shape (num_vectors,embed).

Return type:

2d array

Example

>>> X = [0,1,2,3,4,5,6,7,8,9,10]
em = 3
lag = 2
predict=3
>>> embed_vectors_1d
features = [[0,2,4], [1,3,5], [2,4,6], [3,5,7]]
mutual_information(max_lag)

Calculates the mutual information between the an unshifted time series and a shifted time series.

Utilizes scikit-learn’s implementation of the mutual information found in sklearn.metrics.

Parameters:max_lag (integer) – Maximum amount to shift the time series.
Returns:m_score – Mutual information at between the unshifted time series and the shifted time series,
Return type:1-D array