Ordinal Partition Network
- class driada.recurrence.opn.OrdinalPartitionNetwork(data, d, tau, create_nx_graph=False)[source]
Bases:
NetworkOrdinal partition network from 1D time series.
Embeds with Takens delay embedding, ranks elements to get ordinal patterns. Nodes = unique patterns, directed weighted edges = transition probabilities between consecutive patterns.
- Parameters:
Notes
Tied values in the time series are ranked by position (stable argsort), so equal values receive deterministic but position-dependent ordinal patterns. This is standard practice (Bandt & Pompe, 2002).
- __init__(data, d, tau, create_nx_graph=False)[source]
Initialize a Network object from adjacency matrix or NetworkX graph.
Creates a network representation with automatic detection of directed/weighted properties if not specified. Supports preprocessing to extract connected components.
- Parameters:
adj (scipy.sparse matrix or None) – Adjacency matrix. Mutually exclusive with graph parameter.
graph (networkx.Graph/DiGraph or None) – NetworkX graph object. Mutually exclusive with adj parameter.
preprocessing (str or None, default="giant_cc") –
Preprocessing method:
None: No preprocessing
”remove_isolates”: Remove isolated nodes
”giant_cc”: Extract giant connected component
”giant_scc”: Extract giant strongly connected component (directed only)
name (str, default="") – Name identifier for the network.
pos (dict or None) – Node positions as {node: (x, y)} dictionary.
verbose (bool, default=False) – Whether to print progress messages.
create_nx_graph (bool, default=True) – Whether to create NetworkX graph from adjacency matrix.
node_attrs (dict or None) – Node attributes as {node: {attr: value}} nested dictionary.
logger (logging.Logger or None) – Logger instance for logging messages.
**network_args –
Additional network parameters:
directed : bool or None (auto-detected if None)
weighted : bool or None (auto-detected if None)
real_world : bool (affects directionality validation)
- adj
Adjacency matrix in sparse format.
- Type:
scipy.sparse matrix
- graph
NetworkX graph representation.
- Type:
networkx.Graph/DiGraph or None
- outdeg
Out-degree sequence (set by get_node_degrees()).
- Type:
np.ndarray
- indeg
In-degree sequence (set by get_node_degrees()).
- Type:
np.ndarray
- _init_to_final_node_mapping
Mapping from initial to final node indices after preprocessing.
- Type:
- lem_emb
Placeholder for Laplacian eigenmaps embedding.
- Type:
None
- trans, lap, nlap, rwlap, lap_out, lap_in
Various matrix representations (initialized to None).
- Type:
None or array
- Raises:
ValueError – If both adj and graph are provided or neither is provided.
Notes
The constructor automatically computes node degrees after initialization. For large sparse matrices, auto-detection of directed/weighted properties uses efficient sparse operations to avoid memory issues.
- property permutation_entropy
Permutation entropy normalized to [0, 1].
Shannon entropy of pattern visit frequencies divided by log2(d!). High (~1) = complex/random. Low (~0) = regular/periodic.
- property missing_patterns
Number of d! ordinal patterns never visited.
- property timeseries_data
Original time series data.