Proximity network graph¶
Mappings based on the concept of proximity use measures of distance or similarity to calculate the distance between the points of the time series incorporated in the multidimensional phase space. These methods map states of the time series into nodes of the network and create edges between those nodes based on some measure of distance or similarity.
(Silva, Vanessa Freitas, et al. "Time series analysis via network science: Concepts and algorithms." Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery 11.3 (2021): e1404.)
In [1]:
Copied!
import os
import sys
nb_dir = os.path.split(os.getcwd())[0]
if nb_dir not in sys.path:
sys.path.append(nb_dir)
from core.model import Timeseries, TimeseriesPreprocessing, TimeseriesPreprocessingSegmentation, TimeseriesPreprocessingComposite, TimeseriesView, TimeGraph
from tsg_io.input import CsvFile
from to_graph.strategy_to_graph import BuildTimeseriesToGraphProximityNetwork
from to_graph.strategy_linking_multi_graphs import LinkGraphs
import warnings
warnings.filterwarnings('ignore')
amazon_path = os.path.join(os.getcwd(), "amazon", "AMZN.csv")
import os
import sys
nb_dir = os.path.split(os.getcwd())[0]
if nb_dir not in sys.path:
sys.path.append(nb_dir)
from core.model import Timeseries, TimeseriesPreprocessing, TimeseriesPreprocessingSegmentation, TimeseriesPreprocessingComposite, TimeseriesView, TimeGraph
from tsg_io.input import CsvFile
from to_graph.strategy_to_graph import BuildTimeseriesToGraphProximityNetwork
from to_graph.strategy_linking_multi_graphs import LinkGraphs
import warnings
warnings.filterwarnings('ignore')
amazon_path = os.path.join(os.getcwd(), "amazon", "AMZN.csv")
Cycle networks¶
In [2]:
Copied!
timegraph_cycle_network = Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(60, 90))\
.add(Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(120, 150)))\
.to_graph(BuildTimeseriesToGraphProximityNetwork(method="cycle").get_strategy())\
.link(LinkGraphs().time_cooccurrence())\
.draw()
timegraph_cycle_network = Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(60, 90))\
.add(Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(120, 150)))\
.to_graph(BuildTimeseriesToGraphProximityNetwork(method="cycle").get_strategy())\
.link(LinkGraphs().time_cooccurrence())\
.draw()
Correlation networks¶
In [3]:
Copied!
timegraph_correlation_network = Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(90, 150))\
.to_graph(BuildTimeseriesToGraphProximityNetwork(method="correlation").get_strategy())\
.draw()
timegraph_correlation_network = Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(90, 150))\
.to_graph(BuildTimeseriesToGraphProximityNetwork(method="correlation").get_strategy())\
.draw()
Recurrence networks¶
In [4]:
Copied!
timegraph_recurrence_network = Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(90, 120))\
.to_graph(BuildTimeseriesToGraphProximityNetwork(method="recurrence").get_strategy())\
.draw()
timegraph_recurrence_network = Timeseries(CsvFile(amazon_path, "Close").from_csv())\
.with_preprocessing(TimeseriesPreprocessingSegmentation(90, 120))\
.to_graph(BuildTimeseriesToGraphProximityNetwork(method="recurrence").get_strategy())\
.draw()
Checking edge (0, 1): distance = 0.25, epsilon = 0.5 Checking edge (0, 3): distance = 0.45833299999999966, epsilon = 0.5 Checking edge (0, 5): distance = 0.28645799999999966, epsilon = 0.5 Checking edge (0, 9): distance = 0.5, epsilon = 0.5 Checking edge (0, 20): distance = 0.19791700000000034, epsilon = 0.5 Checking edge (0, 21): distance = 0.10416700000000034, epsilon = 0.5 Checking edge (0, 22): distance = 0.125, epsilon = 0.5 Checking edge (0, 23): distance = 0.40104200000000034, epsilon = 0.5 Checking edge (0, 24): distance = 0.35416700000000034, epsilon = 0.5 Checking edge (0, 25): distance = 0.32291700000000034, epsilon = 0.5 Checking edge (0, 27): distance = 0.5, epsilon = 0.5 Checking edge (0, 28): distance = 0.45833299999999966, epsilon = 0.5 Checking edge (0, 29): distance = 0.44791700000000034, epsilon = 0.5 Checking edge (1, 2): distance = 0.296875, epsilon = 0.5 Checking edge (1, 3): distance = 0.20833299999999966, epsilon = 0.5 Checking edge (1, 4): distance = 0.33333299999999966, epsilon = 0.5 Checking edge (1, 5): distance = 0.03645799999999966, epsilon = 0.5 Checking edge (1, 6): distance = 0.35416700000000034, epsilon = 0.5 Checking edge (1, 7): distance = 0.36458299999999966, epsilon = 0.5 Checking edge (1, 8): distance = 0.359375, epsilon = 0.5 Checking edge (1, 9): distance = 0.25, epsilon = 0.5 Checking edge (1, 10): distance = 0.31770799999999966, epsilon = 0.5 Checking edge (1, 11): distance = 0.36979200000000034, epsilon = 0.5 Checking edge (1, 13): distance = 0.4739580000000001, epsilon = 0.5 Checking edge (1, 14): distance = 0.375, epsilon = 0.5 Checking edge (1, 15): distance = 0.3958330000000001, epsilon = 0.5 Checking edge (1, 16): distance = 0.453125, epsilon = 0.5 Checking edge (1, 20): distance = 0.05208299999999966, epsilon = 0.5 Checking edge (1, 21): distance = 0.14583299999999966, epsilon = 0.5 Checking edge (1, 22): distance = 0.125, epsilon = 0.5 Checking edge (1, 24): distance = 0.10416700000000034, epsilon = 0.5 Checking edge (2, 3): distance = 0.08854200000000034, epsilon = 0.5 Checking edge (2, 4): distance = 0.03645799999999966, epsilon = 0.5 Checking edge (2, 5): distance = 0.26041700000000034, epsilon = 0.5 Checking edge (2, 6): distance = 0.05729200000000034, epsilon = 0.5 Checking edge (2, 7): distance = 0.06770799999999966, epsilon = 0.5 Checking edge (2, 8): distance = 0.0625, epsilon = 0.5 Checking edge (2, 9): distance = 0.046875, epsilon = 0.5 Checking edge (2, 10): distance = 0.020832999999999657, epsilon = 0.5 Checking edge (2, 11): distance = 0.07291700000000034, epsilon = 0.5 Checking edge (2, 12): distance = 0.328125, epsilon = 0.5 Checking edge (2, 13): distance = 0.1770830000000001, epsilon = 0.5 Checking edge (2, 14): distance = 0.078125, epsilon = 0.5 Checking edge (2, 15): distance = 0.0989580000000001, epsilon = 0.5 Checking edge (2, 16): distance = 0.15625, epsilon = 0.5 Checking edge (2, 17): distance = 0.453125, epsilon = 0.5 Checking edge (2, 18): distance = 0.453125, epsilon = 0.5 Checking edge (2, 19): distance = 0.2552080000000001, epsilon = 0.5 Checking edge (2, 20): distance = 0.34895799999999966, epsilon = 0.5 Checking edge (2, 21): distance = 0.44270799999999966, epsilon = 0.5 Checking edge (2, 22): distance = 0.421875, epsilon = 0.5 Checking edge (2, 24): distance = 0.19270799999999966, epsilon = 0.5 Checking edge (3, 4): distance = 0.125, epsilon = 0.5 Checking edge (3, 5): distance = 0.171875, epsilon = 0.5 Checking edge (3, 6): distance = 0.14583400000000069, epsilon = 0.5 Checking edge (3, 7): distance = 0.15625, epsilon = 0.5 Checking edge (3, 8): distance = 0.15104200000000034, epsilon = 0.5 Checking edge (3, 9): distance = 0.04166700000000034, epsilon = 0.5 Checking edge (3, 10): distance = 0.109375, epsilon = 0.5 Checking edge (3, 11): distance = 0.16145900000000069, epsilon = 0.5 Checking edge (3, 12): distance = 0.41666700000000034, epsilon = 0.5 Checking edge (3, 13): distance = 0.26562500000000044, epsilon = 0.5 Checking edge (3, 14): distance = 0.16666700000000034, epsilon = 0.5 Checking edge (3, 15): distance = 0.18750000000000044, epsilon = 0.5 Checking edge (3, 16): distance = 0.24479200000000034, epsilon = 0.5 Checking edge (3, 19): distance = 0.34375000000000044, epsilon = 0.5 Checking edge (3, 20): distance = 0.2604159999999993, epsilon = 0.5 Checking edge (3, 21): distance = 0.3541659999999993, epsilon = 0.5 Checking edge (3, 22): distance = 0.33333299999999966, epsilon = 0.5 Checking edge (3, 24): distance = 0.10416599999999931, epsilon = 0.5 Checking edge (4, 5): distance = 0.296875, epsilon = 0.5 Checking edge (4, 6): distance = 0.020834000000000685, epsilon = 0.5 Checking edge (4, 7): distance = 0.03125, epsilon = 0.5 Checking edge (4, 8): distance = 0.026042000000000343, epsilon = 0.5 Checking edge (4, 9): distance = 0.08333299999999966, epsilon = 0.5 Checking edge (4, 10): distance = 0.015625, epsilon = 0.5 Checking edge (4, 11): distance = 0.036459000000000685, epsilon = 0.5 Checking edge (4, 12): distance = 0.29166700000000034, epsilon = 0.5 Checking edge (4, 13): distance = 0.14062500000000044, epsilon = 0.5 Checking edge (4, 14): distance = 0.04166700000000034, epsilon = 0.5 Checking edge (4, 15): distance = 0.06250000000000044, epsilon = 0.5 Checking edge (4, 16): distance = 0.11979200000000034, epsilon = 0.5 Checking edge (4, 17): distance = 0.41666700000000034, epsilon = 0.5 Checking edge (4, 18): distance = 0.41666700000000034, epsilon = 0.5 Checking edge (4, 19): distance = 0.21875000000000044, epsilon = 0.5 Checking edge (4, 20): distance = 0.3854159999999993, epsilon = 0.5 Checking edge (4, 21): distance = 0.4791659999999993, epsilon = 0.5 Checking edge (4, 22): distance = 0.45833299999999966, epsilon = 0.5 Checking edge (4, 24): distance = 0.22916599999999931, epsilon = 0.5 Checking edge (5, 6): distance = 0.3177090000000007, epsilon = 0.5 Checking edge (5, 7): distance = 0.328125, epsilon = 0.5 Checking edge (5, 8): distance = 0.32291700000000034, epsilon = 0.5 Checking edge (5, 9): distance = 0.21354200000000034, epsilon = 0.5 Checking edge (5, 10): distance = 0.28125, epsilon = 0.5 Checking edge (5, 11): distance = 0.3333340000000007, epsilon = 0.5 Checking edge (5, 13): distance = 0.43750000000000044, epsilon = 0.5 Checking edge (5, 14): distance = 0.33854200000000034, epsilon = 0.5 Checking edge (5, 15): distance = 0.35937500000000044, epsilon = 0.5 Checking edge (5, 16): distance = 0.41666700000000034, epsilon = 0.5 Checking edge (5, 20): distance = 0.08854099999999931, epsilon = 0.5 Checking edge (5, 21): distance = 0.18229099999999931, epsilon = 0.5 Checking edge (5, 22): distance = 0.16145799999999966, epsilon = 0.5 Checking edge (5, 24): distance = 0.06770900000000069, epsilon = 0.5 Checking edge (6, 7): distance = 0.010415999999999315, epsilon = 0.5 Checking edge (6, 8): distance = 0.005207999999999657, epsilon = 0.5 Checking edge (6, 9): distance = 0.10416700000000034, epsilon = 0.5 Checking edge (6, 10): distance = 0.036459000000000685, epsilon = 0.5 Checking edge (6, 11): distance = 0.015625, epsilon = 0.5 Checking edge (6, 12): distance = 0.27083299999999966, epsilon = 0.5 Checking edge (6, 13): distance = 0.11979099999999976, epsilon = 0.5 Checking edge (6, 14): distance = 0.020832999999999657, epsilon = 0.5 Checking edge (6, 15): distance = 0.04166599999999976, epsilon = 0.5 Checking edge (6, 16): distance = 0.09895799999999966, epsilon = 0.5 Checking edge (6, 17): distance = 0.39583299999999966, epsilon = 0.5 Checking edge (6, 18): distance = 0.39583299999999966, epsilon = 0.5 Checking edge (6, 19): distance = 0.19791599999999976, epsilon = 0.5 Checking edge (6, 20): distance = 0.40625, epsilon = 0.5 Checking edge (6, 21): distance = 0.5, epsilon = 0.5 Checking edge (6, 22): distance = 0.47916700000000034, epsilon = 0.5 Checking edge (6, 24): distance = 0.25, epsilon = 0.5 Checking edge (7, 8): distance = 0.005207999999999657, epsilon = 0.5 Checking edge (7, 9): distance = 0.11458299999999966, epsilon = 0.5 Checking edge (7, 10): distance = 0.046875, epsilon = 0.5 Checking edge (7, 11): distance = 0.005209000000000685, epsilon = 0.5 Checking edge (7, 12): distance = 0.26041700000000034, epsilon = 0.5 Checking edge (7, 13): distance = 0.10937500000000044, epsilon = 0.5 Checking edge (7, 14): distance = 0.010417000000000343, epsilon = 0.5 Checking edge (7, 15): distance = 0.031250000000000444, epsilon = 0.5 Checking edge (7, 16): distance = 0.08854200000000034, epsilon = 0.5 Checking edge (7, 17): distance = 0.38541700000000034, epsilon = 0.5 Checking edge (7, 18): distance = 0.38541700000000034, epsilon = 0.5 Checking edge (7, 19): distance = 0.18750000000000044, epsilon = 0.5 Checking edge (7, 20): distance = 0.4166659999999993, epsilon = 0.5 Checking edge (7, 22): distance = 0.48958299999999966, epsilon = 0.5 Checking edge (7, 24): distance = 0.2604159999999993, epsilon = 0.5 Checking edge (8, 9): distance = 0.109375, epsilon = 0.5 Checking edge (8, 10): distance = 0.04166700000000034, epsilon = 0.5 Checking edge (8, 11): distance = 0.010417000000000343, epsilon = 0.5 Checking edge (8, 12): distance = 0.265625, epsilon = 0.5 Checking edge (8, 13): distance = 0.1145830000000001, epsilon = 0.5 Checking edge (8, 14): distance = 0.015625, epsilon = 0.5 Checking edge (8, 15): distance = 0.0364580000000001, epsilon = 0.5 Checking edge (8, 16): distance = 0.09375, epsilon = 0.5 Checking edge (8, 17): distance = 0.390625, epsilon = 0.5 Checking edge (8, 18): distance = 0.390625, epsilon = 0.5 Checking edge (8, 19): distance = 0.1927080000000001, epsilon = 0.5 Checking edge (8, 20): distance = 0.41145799999999966, epsilon = 0.5 Checking edge (8, 22): distance = 0.484375, epsilon = 0.5 Checking edge (8, 24): distance = 0.25520799999999966, epsilon = 0.5 Checking edge (9, 10): distance = 0.06770799999999966, epsilon = 0.5 Checking edge (9, 11): distance = 0.11979200000000034, epsilon = 0.5 Checking edge (9, 12): distance = 0.375, epsilon = 0.5 Checking edge (9, 13): distance = 0.2239580000000001, epsilon = 0.5 Checking edge (9, 14): distance = 0.125, epsilon = 0.5 Checking edge (9, 15): distance = 0.1458330000000001, epsilon = 0.5 Checking edge (9, 16): distance = 0.203125, epsilon = 0.5 Checking edge (9, 17): distance = 0.5, epsilon = 0.5 Checking edge (9, 18): distance = 0.5, epsilon = 0.5 Checking edge (9, 19): distance = 0.3020830000000001, epsilon = 0.5 Checking edge (9, 20): distance = 0.30208299999999966, epsilon = 0.5 Checking edge (9, 21): distance = 0.39583299999999966, epsilon = 0.5 Checking edge (9, 22): distance = 0.375, epsilon = 0.5 Checking edge (9, 24): distance = 0.14583299999999966, epsilon = 0.5 Checking edge (10, 11): distance = 0.052084000000000685, epsilon = 0.5 Checking edge (10, 12): distance = 0.30729200000000034, epsilon = 0.5 Checking edge (10, 13): distance = 0.15625000000000044, epsilon = 0.5 Checking edge (10, 14): distance = 0.05729200000000034, epsilon = 0.5 Checking edge (10, 15): distance = 0.07812500000000044, epsilon = 0.5 Checking edge (10, 16): distance = 0.13541700000000034, epsilon = 0.5 Checking edge (10, 17): distance = 0.43229200000000034, epsilon = 0.5 Checking edge (10, 18): distance = 0.43229200000000034, epsilon = 0.5 Checking edge (10, 19): distance = 0.23437500000000044, epsilon = 0.5 Checking edge (10, 20): distance = 0.3697909999999993, epsilon = 0.5 Checking edge (10, 21): distance = 0.4635409999999993, epsilon = 0.5 Checking edge (10, 22): distance = 0.44270799999999966, epsilon = 0.5 Checking edge (10, 24): distance = 0.21354099999999931, epsilon = 0.5 Checking edge (11, 12): distance = 0.25520799999999966, epsilon = 0.5 Checking edge (11, 13): distance = 0.10416599999999976, epsilon = 0.5 Checking edge (11, 14): distance = 0.005207999999999657, epsilon = 0.5 Checking edge (11, 15): distance = 0.02604099999999976, epsilon = 0.5 Checking edge (11, 16): distance = 0.08333299999999966, epsilon = 0.5 Checking edge (11, 17): distance = 0.38020799999999966, epsilon = 0.5 Checking edge (11, 18): distance = 0.38020799999999966, epsilon = 0.5 Checking edge (11, 19): distance = 0.18229099999999976, epsilon = 0.5 Checking edge (11, 20): distance = 0.421875, epsilon = 0.5 Checking edge (11, 22): distance = 0.49479200000000034, epsilon = 0.5 Checking edge (11, 24): distance = 0.265625, epsilon = 0.5 Checking edge (12, 13): distance = 0.1510419999999999, epsilon = 0.5 Checking edge (12, 14): distance = 0.25, epsilon = 0.5 Checking edge (12, 15): distance = 0.2291669999999999, epsilon = 0.5 Checking edge (12, 16): distance = 0.171875, epsilon = 0.5 Checking edge (12, 17): distance = 0.125, epsilon = 0.5 Checking edge (12, 18): distance = 0.125, epsilon = 0.5 Checking edge (12, 19): distance = 0.0729169999999999, epsilon = 0.5 Checking edge (13, 14): distance = 0.0989580000000001, epsilon = 0.5 Checking edge (13, 15): distance = 0.078125, epsilon = 0.5 Checking edge (13, 16): distance = 0.0208330000000001, epsilon = 0.5 Checking edge (13, 17): distance = 0.2760419999999999, epsilon = 0.5 Checking edge (13, 18): distance = 0.2760419999999999, epsilon = 0.5 Checking edge (13, 19): distance = 0.078125, epsilon = 0.5 Checking edge (13, 24): distance = 0.36979099999999976, epsilon = 0.5 Checking edge (14, 15): distance = 0.0208330000000001, epsilon = 0.5 Checking edge (14, 16): distance = 0.078125, epsilon = 0.5 Checking edge (14, 17): distance = 0.375, epsilon = 0.5 Checking edge (14, 18): distance = 0.375, epsilon = 0.5 Checking edge (14, 19): distance = 0.1770830000000001, epsilon = 0.5 Checking edge (14, 20): distance = 0.42708299999999966, epsilon = 0.5 Checking edge (14, 22): distance = 0.5, epsilon = 0.5 Checking edge (14, 24): distance = 0.27083299999999966, epsilon = 0.5 Checking edge (15, 16): distance = 0.0572919999999999, epsilon = 0.5 Checking edge (15, 17): distance = 0.3541669999999999, epsilon = 0.5 Checking edge (15, 18): distance = 0.3541669999999999, epsilon = 0.5 Checking edge (15, 19): distance = 0.15625, epsilon = 0.5 Checking edge (15, 20): distance = 0.44791599999999976, epsilon = 0.5 Checking edge (15, 24): distance = 0.29166599999999976, epsilon = 0.5 Checking edge (16, 17): distance = 0.296875, epsilon = 0.5 Checking edge (16, 18): distance = 0.296875, epsilon = 0.5 Checking edge (16, 19): distance = 0.0989580000000001, epsilon = 0.5 Checking edge (16, 24): distance = 0.34895799999999966, epsilon = 0.5 Checking edge (17, 18): distance = 0.0, epsilon = 0.5 Checking edge (17, 19): distance = 0.1979169999999999, epsilon = 0.5 Checking edge (18, 19): distance = 0.1979169999999999, epsilon = 0.5 Checking edge (19, 24): distance = 0.44791599999999976, epsilon = 0.5 Checking edge (20, 21): distance = 0.09375, epsilon = 0.5 Checking edge (20, 22): distance = 0.07291700000000034, epsilon = 0.5 Checking edge (20, 24): distance = 0.15625, epsilon = 0.5 Checking edge (21, 22): distance = 0.020832999999999657, epsilon = 0.5 Checking edge (21, 24): distance = 0.25, epsilon = 0.5 Checking edge (21, 25): distance = 0.4270840000000007, epsilon = 0.5 Checking edge (22, 24): distance = 0.22916700000000034, epsilon = 0.5 Checking edge (22, 25): distance = 0.44791700000000034, epsilon = 0.5 Checking edge (23, 25): distance = 0.078125, epsilon = 0.5 Checking edge (23, 26): distance = 0.36458299999999966, epsilon = 0.5 Checking edge (23, 27): distance = 0.09895799999999966, epsilon = 0.5 Checking edge (23, 28): distance = 0.057290999999999315, epsilon = 0.5 Checking edge (23, 29): distance = 0.046875, epsilon = 0.5 Checking edge (25, 26): distance = 0.44270799999999966, epsilon = 0.5 Checking edge (25, 27): distance = 0.17708299999999966, epsilon = 0.5 Checking edge (25, 28): distance = 0.13541599999999931, epsilon = 0.5 Checking edge (25, 29): distance = 0.125, epsilon = 0.5 Checking edge (26, 27): distance = 0.265625, epsilon = 0.5 Checking edge (26, 28): distance = 0.30729200000000034, epsilon = 0.5 Checking edge (26, 29): distance = 0.31770799999999966, epsilon = 0.5 Checking edge (27, 28): distance = 0.04166700000000034, epsilon = 0.5 Checking edge (27, 29): distance = 0.05208299999999966, epsilon = 0.5 Checking edge (28, 29): distance = 0.010415999999999315, epsilon = 0.5