Browse Source

aggr model (#161)

* aggr model

new defs for aggregate model

* Update utils

raise exception
pull/1/head
Alexandr Velikiy 6 years ago committed by Alexey Velikiy
parent
commit
f158c5050b
  1. 15
      analytics/utils/__init__.py

15
analytics/utils/__init__.py

@ -206,3 +206,18 @@ def peak_finder(data, size):
if data[i] == max(data[i - size: i + size]) and data[i] > data[i + 1]:
all_max.append(i)
return all_max
def ar_mean(numbers):
return float(sum(numbers)) / max(len(numbers), 1)
def get_av_model(patterns_list):
x = len(patterns_list[0])
if len(patterns_list[1]) != x:
raise NameError('All elements of patterns_list should have same length')
model_pat = []
for i in range(x):
av_val = []
for j in patterns_list:
av_val.append(j.values[i])
model_pat.append(ar_mean(av_val))
return model_pat

Loading…
Cancel
Save