Files
master_thesis/src/DoresA/ttl.py
Felix Steghofer cf0536483b splitted db into separate files
added redis
train using csv files instead of sql
2017-11-30 15:51:46 +01:00

46 lines
922 B
Python

import numpy as np
import logging
logger = logging.getLogger('ttl')
logger.setLevel(logging.DEBUG)
def standard_deviation(array):
return np.std(array)
def changes(array):
current = array[0]
changes = 0
for item in array:
if item != current:
changes += 1
current = item
return changes
# specific ranges: [0, 1], [1, 100], [100, 300], [300, 900], [900, inf]
def specific_range(ttl):
specific_ttl_ranges = 4 # default is [900, inf]
try:
ttl = int(ttl)
except ValueError:
logger.error('ttl not a number')
return specific_ttl_ranges
if 0 < ttl <= 1:
specific_ttl_ranges = 0
elif 1 < ttl <= 100:
specific_ttl_ranges = 1
elif 100 < ttl <= 300:
specific_ttl_ranges = 2
elif 300 < ttl <= 900:
specific_ttl_ranges = 3
return specific_ttl_ranges
if __name__ == "__main__":
exit()