Я экспериментирую с алгоритмом изменения точки из пакета разрывов. Я ничего не вижу в документах , но мне любопытно узнать, можно ли рассчитать дельту времени между точками изменения ???
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import ruptures as rpt
#read CSV file
df = pd.read_csv('https://raw.githubusercontent.com/bbartling/Building-Demand-Electrical-Load-Profiles/master/School%202013_2014%20KW.csv', index_col='Date', parse_dates=True)
df2 = df.loc['2-11-2014']
points2=np.array(df2.kW)
#Changepoint detection with the Binary Segmentation search method
model = "l2"
algo = rpt.Binseg(model=model).fit(points2)
my_bkps = algo.predict(n_bkps=3)
# show results
rpt.show.display(points2, my_bkps, figsize=(17, 6))
plt.title('Change Point Detection: Binary Segmentation Search Method')
plt.show()
Например, если я запускаю код выше он выведет Matplotlib ниже. Можно ли получить разницу времени в часах между точками изменения? Набор данных - это данные временных рядов по потреблению электроэнергии в зданиях.

РЕДАКТИРОВАТЬ Мне немного помогли от автора разрывов ... Вот код
kWmean = df.mean()
#Changepoint detection with the Binary Segmentation search method
model = "l2"
algo = rpt.Binseg(model=model).fit(points2)
my_bkps = algo.predict(n_bkps=3)
# show results
rpt.show.display(points2, my_bkps, figsize=(17, 6))
# getting the timestamps of the change points
bkps_timestamps = df2.iloc[[0] + my_bkps[:-1] +[-1]].index
# computing the durations between change points
durations = (bkps_timestamps[1:] - bkps_timestamps[:-1])
#ours
d = durations.seconds/60/60
d_f = pd.DataFrame(d)
oneHr = d_f.values[0][0]
twoHr = d_f.values[1][0]
threeHr = d_f.values[2][0]
fourHr = d_f.values[3][0]
one = f'first change point {oneHr} hours'
two = f'second change point {twoHr} hours'
three = f'third change point {threeHr} hours'
four = f'fourth change point {fourHr} hours'
plt.title('Change Point Detection: Binary Segmentation Search Method')
plt.text(0, kWmean+15, one)
plt.text(0, kWmean+10, two)
plt.text(0, kWmean+5, three)
plt.text(0, kWmean, four)
plt.show()
