コード例 #1
0
from FakePatients import working_path
import scipy.stats as stats
import matplotlib.pyplot as plt
import math
import numpy as np


# print get_patients_freq()

repo = Repository()

repo.add_age_distr('050', lambda count: [18 if x < 18 else 103 if x > 103 else int(round(x))
                                     for x in stats.norm.rvs(loc=70.0, scale=16, size=count)])

# Cardiology <35
repo.add_patients_count_distr((2, 2, '050'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.1, size=x), 0.7))
repo.add_rlos_distr((2, 2, '050'),
                    lambda size: [int(math.floor(x)) for x in stats.expon.rvs(scale=2.0, size=size)],
                    lambda x: x >= 1)

# Cardiology 35-50
repo.add_patients_count_distr((2, 3, '050'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.17, size=x), 0.14))
repo.add_rlos_distr((2, 3, '050'),
                    lambda size: [int(math.floor(x)) for x in stats.expon.rvs(scale=2.0, size=size)],
                    lambda x: x >= 1)

# Cardiology 50-70
repo.add_patients_count_distr((2, 4, '050'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.46, size=x), 0.45))
repo.add_rlos_distr((2, 4, '050'),
                    lambda size: [int(math.floor(x)) for x in stats.expon.rvs(scale=2.2, size=size)],
                    lambda x: x >= 1)
コード例 #2
0
__author__ = 'Andrew'
from Repository import Repository
from Repository import DistrInfo
from FakePatients import get_patients_freq
import scipy.stats as stats
import matplotlib.pyplot as plt
import math


repo = Repository()
# Cardiology 35-50
repo.add_patients_count_distr((2, 3, '050'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.17, size=x), 0.14))
repo.add_rlos_distr((2, 3, '050'), lambda count: [int(math.floor(x)) for x in stats.expon.rvs(scale=2.0, size=count)])
# Cardiology 50-70
repo.add_patients_count_distr((2, 4, '050'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.46, size=x), 0.45))
# Cardiology 50-70
repo.add_patients_count_distr((3, 4, '050'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.3, size=x), 0.336))
# Urological Surgery 50-70
repo.add_patients_count_distr((2, 4, '387'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.44, size=x), 0.267))
# Urological Surgery 50-70
repo.add_patients_count_distr((3, 4, '387'), DistrInfo(lambda x: stats.poisson.rvs(mu=1.17, size=x), 0.08))
repo.add_rlos_distr((3, 4, '387'), lambda count: [int(math.floor(x)) for x in stats.expon.rvs(scale=2.4, size=count)])


# put selection here
selection = (2, 3, '050')

# build chart generated data versus historical data
predicted = repo.predict(selection, 30)
historical, sd, ed = repo.history(selection, 30)
title_common = " [%4d-%02d-%02d %4d-%02d-%02d]" \