Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
medtrajectory_datagen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
GUYET Thomas
medtrajectory_datagen
Commits
0dc49a2e
Commit
0dc49a2e
authored
2 months ago
by
GUYET Thomas
Browse files
Options
Downloads
Patches
Plain Diff
add graphs on DB
parent
7df01b7c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Models/VICAN/test_ages.py
+16
-10
16 additions, 10 deletions
Models/VICAN/test_ages.py
with
16 additions
and
10 deletions
Models/VICAN/test_ages.py
+
16
−
10
View file @
0dc49a2e
import
sqlite3
import
numpy.random
as
rd
import
numpy
as
np
import
pandas
as
pd
from
scipy.stats
import
truncnorm
,
bernoulli
import
matplotlib
from
scipy.stats
import
truncnorm
,
gaussian_kde
import
matplotlib.pyplot
as
plt
from
scipy.stats
import
gaussian_kde
from
SNDSGenerator.simuExternal
import
simuExternal
from
SNDSGenerator.simulationDB
import
simDB
...
...
@@ -25,8 +27,6 @@ from SNDSGenerator.pathway_factory import pathwayInjector
from
SNDSGenerator.database_model
import
(
Patient
,
ShortHospStay
,
DrugDelivery
,
MedicalAct
,
)
from
SNDSGenerator.simulation
import
simulation
...
...
@@ -157,18 +157,24 @@ for patient in simulator.patients:
first_event_ages
.
append
(
(
patient
.
hospitalStays
[
0
].
start_date
-
patient
.
BD
).
days
/
365.25
)
first_event_ages_internal
.
append
(
patient
.
age
(
patient
.
hospitalStays
[
0
].
start_date
)
)
print
(
dates
[
-
1
],
patient
.
hospitalStays
[
0
].
start_date
,
first_event_ages
[
-
1
])
#print(dates[-1], patient.hospitalStays[0].start_date, first_event_ages[-1])
dbgen
=
simDB
()
dbgen
.
output_db_name
=
"
Models/VICAN/snds_testage.db
"
dbgen
.
generate
(
simulator
,
rootschemas
=
"
schema-snds/schemas
"
)
#dbgen = simDB()
#dbgen.output_db_name = "Models/VICAN/snds_testage.db"
#dbgen.generate(simulator, rootschemas="schema-snds/schemas")
conn
=
sqlite3
.
connect
(
dbgen
.
output_db_name
)
final_ages
=
pd
.
read_sql_query
(
"
SELECT AGE_ANN FROM T_MCOaaB;
"
,
conn
)[
'
AGE_ANN
'
].
to_numpy
()
density
=
gaussian_kde
(
samples1
)
density_first_event
=
gaussian_kde
(
first_event_ages
)
density_first_event_internal
=
gaussian_kde
(
first_event_ages_internal
)
density_final
=
gaussian_kde
(
final_ages
)
xs
=
np
.
linspace
(
0
,
100
,
200
)
fig
=
plt
.
figure
(
figsize
=
(
14
,
8
))
plt
.
plot
(
xs
,
density
(
xs
),
c
=
'
r
'
)
plt
.
plot
(
xs
,
density_first_event
(
xs
),
c
=
'
b
'
)
plt
.
plot
(
xs
,
density_first_event_internal
(
xs
),
c
=
'
g
'
)
fig
.
savefig
(
'
testage.pdf
'
)
\ No newline at end of file
plt
.
scatter
(
xs
,
density_final
(
xs
),
c
=
'
k
'
,
marker
=
"
x
"
)
fig
.
savefig
(
'
testage.pdf
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment