-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcriteria.py
71 lines (65 loc) · 1.86 KB
/
criteria.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
import numpy as np
import re
from statistics import mean
from get_data import *
#Criteria: devuelve 1 si existe la matriz P
def check_if_P(path,n):
input=read_data_P_n(path,n)
variables_n=[]
for i in input:
if bool(i):
variables_n.append(1)
else:
variables_n.append(0)
return variables_n
def check_if_P_variation(path,start, end):
input=read_data_P_variation(path,start,end)
variables_n=[]
for i in input:
if bool(i):
variables_n.append(1)
else:
variables_n.append(0)
return variables_n
#Crea un promedio de el % de cambio de los intervalos, en un nodo
def makeAverage(path,n):
input=read_data_width_n(path,n)
avg=[]
for i in input:
aux=mean(i)
avg.append(aux)
return avg
def makeAverage_variation(path,start,end):
input=read_data_width_n_variation(path,start,end)
avg=[]
for i in input:
aux=mean(i)
avg.append(aux)
return avg
#Criteria: devuelve bool=1 si un % de cambio promedio de los intervalos, es mayor o igual un threshold:
def bool_by_avg(path,n,threshold):
list=makeAverage(path,n)
for i in range(len(list)):
if list[i] >= threshold:
list[i]=1
else:
list[i]=0
return list
def bool_by_avg_variation(path,inicio,fin,threshold):
list=makeAverage_variation(path,inicio,fin)
for i in range(len(list)):
if list[i] >= threshold:
list[i]=1
else:
list[i]=0
return list
#Criteria: devuelve bool=1 si un % de cambio de UN intervalo es mayor o igual un threshold
def one_Interval_with_more_percentage(path,n,threshold):
list=read_data_width_n(path,n)
for i in range(len(list)):
if max(list[i]) >= threshold:
list[i]=1
else:
list[i]=0
return list