__author__ = 'Andrew' import FakePatients as fp import time import matplotlib.pyplot as plt import scipy.stats as stats import math from FakePatients import split_age all_data = fp.load_data_with_sline() # Here are sline which are presented almost every day (at least 360 days in year ) fit_sline = ['276', '070', '090', '390', '274', '135', '129', '250', '050', '255', '280', '283', '145', '065', '085' , '245', '262', '267', '125', '387', '165', '132', '296'] YEAR = 2012 FULL_YEARS = [2011, 2012, 2013] def show_sline_freq(year=YEAR): """Prints sline counts for a year""" sline_freq = {} for tuple in all_data: sline = tuple[14] if sline is None: continue admit_date = tuple[2] if len(admit_date) == 0: continue datetime = time.strptime(admit_date, "%Y-%m-%d") if int(datetime.tm_year) != year: continue
__author__ = 'Andrew' import FakePatients as fp import matplotlib.pyplot as plt from sklearn.neighbors.kde import KernelDensity import numpy as np import random import csv from datetime import timedelta import math training_threshold = 10 alert_count = 50 raw_data, missed_drg = fp.load_data_with_sline() data = fp.change_to_dict(fp.filter_incomplete_data(raw_data)) print "Rows with following DRG were skipped:", print missed_drg print "Filter out %d of %d" % (len(raw_data) - len(data), len(raw_data)) def history(all_data, (sex, age, sline), days=30): """Return historical data for selected combination of (sex, age, sline)""" start_date = None end_date = None hist_data = {} for row in all_data: admit_date = row[2] agef_in_years = int(row[9]) agef = fp.split_age(agef_in_years) sexf = int(row[10]) slinef = row[14] rlos = row[5]