pyEDM, rEDM
  • Home

Getting Started

  • EDM Framework
  • Installation

Documentation

  • API Reference
  • Parameters
  • Simplex
  • SMap
  • CCM
  • Multiview
  • EmbedDimension
  • PredictInterval
  • PredictNonlinear
  • Embed
  • MakeBlock
  • ComputeError

Embedding Parameters

  • Embedding

Examples

  • Basic EDM Examples

EDM Algorithms

  • EDM Algorithms in Depth
  • S-map First Principles
  • S-map Custom Solvers
  • Conditional Embedding
pyEDM, rEDM
  • Examples
  • Basic EDM Examples

pyEDM Examples¶

InĀ [1]:
Copied!
from pyEDM import *
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [6, 3.5]
from pyEDM import * import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [6, 3.5]
InĀ [2]:
Copied!
tentmap      = sampleData['TentMap']
tentmapNoise = sampleData['TentMapNoise']
tentmap = sampleData['TentMap'] tentmapNoise = sampleData['TentMapNoise']
InĀ [3]:
Copied!
plt.plot( tentmap['TentMap'][1:40] );
plt.plot( tentmap['TentMap'][1:40] );
No description has been provided for this image

Evaluate optimal embedding dimension (via Simplex)¶

InĀ [4]:
Copied!
EmbedDimension( dataFrame = tentmap, lib = "1 100", pred = "201 500", 
                columns = "TentMap", target = "TentMap" );
EmbedDimension( dataFrame = tentmap, lib = "1 100", pred = "201 500", columns = "TentMap", target = "TentMap" );
No description has been provided for this image

Optimal embedding dimension is E = 2


Evaluate decay in prediction versus Tp¶

InĀ [5]:
Copied!
PredictInterval( dataFrame = tentmap, lib = "1 100", pred = "251 500",
                 columns = "TentMap", target = "TentMap", E = 2 );
PredictInterval( dataFrame = tentmap, lib = "1 100", pred = "251 500", columns = "TentMap", target = "TentMap", E = 2 );
No description has been provided for this image

Decay in predictability as forecast interval increases is a possible indication of chaotic dynamics and nonlinearity provided there is insignificant serial correlation.


Simplex prediction¶

InĀ [6]:
Copied!
Simplex( dataFrame = tentmapNoise, lib = [1,500], pred = [501, 550], 
         columns = "TentMap", target = "TentMap", E = 2, showPlot = True );
Simplex( dataFrame = tentmapNoise, lib = [1,500], pred = [501, 550], columns = "TentMap", target = "TentMap", E = 2, showPlot = True );
No description has been provided for this image

Simplex Prediction using multivariate embedding¶

The block_3sp data frame is used directly as an embedding: embedded = True

InĀ [7]:
Copied!
block_3sp = sampleData['block_3sp']
block_3sp.head(3)
block_3sp = sampleData['block_3sp'] block_3sp.head(3)
Out[7]:
time x_t x_t-1 x_t-2 y_t y_t-1 y_t-2 z_t z_t-1 z_t-2
0 3 -1.917685 1.244882 -0.741863 -0.113188 1.488887 -1.268104 1.535239 -0.481583 -1.863980
1 4 -0.962318 -1.917685 1.244882 -1.106779 -0.113188 1.488887 -1.492956 1.535239 -0.481583
2 5 1.331875 -0.962318 -1.917685 2.385041 -1.106779 -0.113188 -1.119476 -1.492956 1.535239
InĀ [8]:
Copied!
Simplex( dataFrame = block_3sp, lib = [1,99], pred = [100,195], 
         columns = "x_t y_t z_t", target = "x_t",
         embedded = True, showPlot = True );
Simplex( dataFrame = block_3sp, lib = [1,99], pred = [100,195], columns = "x_t y_t z_t", target = "x_t", embedded = True, showPlot = True );
No description has been provided for this image

Evaluate optimal SMap theta parameter indicating state-dependence and extent of nonlinearity¶

InĀ [9]:
Copied!
PredictNonlinear( dataFrame = tentmapNoise, lib = [1,100], pred = [201,500],
                  columns = "TentMap", target = "TentMap", E = 2 );
PredictNonlinear( dataFrame = tentmapNoise, lib = [1,100], pred = [201,500], columns = "TentMap", target = "TentMap", E = 2 );
No description has been provided for this image

SMap theta parameter in the range of [2-3] provides optimal resolution. The non-zero theta peak of predictability indicates nonlinearity.


SMap Prediction¶

InĀ [10]:
Copied!
SMap( dataFrame = tentmapNoise, lib = [1,500], pred = [501,550], 
      columns = "TentMap", target = "TentMap", E = 2, theta = 3, showPlot = True );
SMap( dataFrame = tentmapNoise, lib = [1,500], pred = [501,550], columns = "TentMap", target = "TentMap", E = 2, theta = 3, showPlot = True );
No description has been provided for this image
No description has been provided for this image

SMap Prediction multivariate embedding¶

Note SMap multivariate prediction requires embedded = True

InĀ [11]:
Copied!
SMap( dataFrame = sampleData[ 'circle' ],
      lib = [1,100], pred = [110,190], theta = 4, E = 2, 
      embedded = True, columns = "x y", target = "x", showPlot = True );
SMap( dataFrame = sampleData[ 'circle' ], lib = [1,100], pred = [110,190], theta = 4, E = 2, embedded = True, columns = "x y", target = "x", showPlot = True );
No description has been provided for this image
No description has been provided for this image

Analytical solution of the SMap coefficients are C0 = 0; āˆ‚x/āˆ‚x = 0.998; āˆ‚x/āˆ‚y = 0.063. Deviations from these values are due to sampling and numerical noise.


Inference of causality via Convergent Cross Mapping (CCM)¶

InĀ [12]:
Copied!
sardine_anchovy_sst = sampleData['sardine_anchovy_sst']
sardine_anchovy_sst[['anchovy','np_sst']].plot(lw=2);
sardine_anchovy_sst = sampleData['sardine_anchovy_sst'] sardine_anchovy_sst[['anchovy','np_sst']].plot(lw=2);
No description has been provided for this image
InĀ [13]:
Copied!
CCM( dataFrame = sardine_anchovy_sst, E = 3, 
     columns = "anchovy", target = "np_sst",
     libSizes = [10,70,10], sample = 30, 
     seed = 12345, showPlot = True );
CCM( dataFrame = sardine_anchovy_sst, E = 3, columns = "anchovy", target = "np_sst", libSizes = [10,70,10], sample = 30, seed = 12345, showPlot = True );
No description has been provided for this image

The CCM result anchovy:np_sst is interpreted as: sea surface temperature (np_sst) influences anchovy population. The reverse influence (np_sst:anchovy) indicates no link consistent with the fact that anchovy population does not influence sea surface temperature.


Multiview Embedding¶

InĀ [14]:
Copied!
MV = Multiview( dataFrame = block_3sp, lib = [1,99], pred = [105,190], E = 3,
                columns = "x_t y_t z_t", target = "x_t", showPlot = True );
MV = Multiview( dataFrame = block_3sp, lib = [1,99], pred = [105,190], E = 3, columns = "x_t y_t z_t", target = "x_t", showPlot = True );
No description has been provided for this image
InĀ [15]:
Copied!
MV['View']
# Col_i are column indices in block_3sp
MV['View'] # Col_i are column indices in block_3sp
Out[15]:
Columns rho MAE CAE RMSE
0 (x_t(t-0), z_t(t-0), x_t(t-1)) 0.920810 0.641525 21.372022 0.316416
1 (x_t(t-0), x_t(t-1), y_t(t-2)) 0.867700 1.301578 28.330831 0.411275
2 (x_t(t-0), x_t(t-1), x_t(t-2)) 0.931867 0.654676 19.581714 0.293402
3 (x_t(t-0), x_t(t-1), z_t(t-1)) 0.918613 0.698145 21.217600 0.319911
4 (x_t(t-0), z_t(t-0), z_t(t-2)) 0.885830 0.886854 26.062664 0.373766
5 (x_t(t-0), x_t(t-1), y_t(t-1)) 0.901727 1.067862 24.110364 0.356719
6 (x_t(t-0), y_t(t-0), z_t(t-2)) 0.777399 1.133895 36.041332 0.511584
7 (x_t(t-0), z_t(t-0), x_t(t-2)) 0.872370 1.325145 27.139119 0.400680
8 (x_t(t-0), y_t(t-0), z_t(t-0)) 0.781226 1.475317 33.309865 0.508688
Previous Next

Built with MkDocs using a theme provided by Read the Docs.
« Previous Next »