A Python package for performing Convergent Cross Mapping (CCM) analysis on time series data.
Note: This package is optimized for Jupyter Notebooks (
.ipynb
). If you need to perform CCM analysis in a Python script (.py
), please use CCM_analysis_Python.
You can install the package via pip:
pip install ccm_analysis_pynb
To use this package in a Jupyter Notebook, import the function and run the analysis:
from ccm_analysis_pynb import run_ccm_analysis_jupyter
df = pd.DataFrame(data)
# Run CCM analysis
result_holder = run_ccm_analysis_jupyter(df, L=100, E=2, tau=1, THRESHOLD=0.8, save_output=False)
# Access the final DataFrame of significant relationships
final_results = result_holder.result
print(final_results)
-
data_input
: Either a filepath (str) to tab-separated data or a pandas DataFrame. -
L
: Length of time series to consider. -
E
: Embedding dimension. -
tau
: Time delay. -
THRESHOLD
: Significance threshold for cross-map scores. -
save_output
: Whether to save plots and protocol (default: True). -
output_dir
: Directory to save outputs (default: current working directory).
The function returns an interactive widget for manual evaluation of relationships. Once the evaluation is completed, it generates a final heatmap and saves the results if save_output=True
.
You can test the ccm_analysis
package using the sample dataset provided in this repository. You can download the test dataset from the following link:
The dataset is structured as follows:
- Columns represent the variables you want to analyze.
- Rows represent the time points for each variable.
Parts of this project are based on the Convergent Cross Mapping (CCM) implementation from the following repository from Prince Javier :
I have utilized parts of the CCM algorithm from this repository to help analyze causality in time series data in my own project.