Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
inventario
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jose Luis Gordillo Ruiz
inventario
Commits
37ce89d2
Commit
37ce89d2
authored
Jan 23, 2025
by
Jose Luis Gordillo Ruiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adicion de gráficas de grupos de IMC
parent
de9df8cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
10 deletions
+43
-10
estadisticas.py
+43
-10
No files found.
estadisticas.py
View file @
37ce89d2
...
...
@@ -2,12 +2,14 @@ import pandas as pd
from
dash
import
Dash
,
Input
,
Output
,
dcc
,
html
import
plotly.graph_objects
as
go
import
plotly.express
as
px
import
plotly.figure_factory
as
ff
import
requests
import
numpy
as
np
from
plotly.subplots
import
make_subplots
from
sklearn.cluster
import
KMeans
from
scipy
import
stats
from
ast
import
literal_eval
import
flask
server
=
flask
.
Flask
(
__name__
)
...
...
@@ -76,6 +78,30 @@ def popcorr(datos):
def
imc_cat
(
datos
):
medidas
=
[
"glucose"
,
"hba1c"
,
"ct"
,
"hdl"
,
"insuline"
]
grupos
=
[
"LW"
,
"NW"
,
"OW"
,
"O-CI"
,
"O-CII"
,
"O-CIII"
]
datos
[
"imc_cat"
]
=
pd
.
cut
(
datos
[
"imc"
],
bins
=
[
0
,
18
,
25
,
30
,
35
,
40
,
100
],
labels
=
grupos
)
fig
=
make_subplots
(
rows
=
2
,
cols
=
3
,
shared_yaxes
=
False
,
subplot_titles
=
medidas
)
lcol
=
1
lrow
=
1
for
medida
in
medidas
:
datosfil
=
datos
.
groupby
(
"imc_cat"
)[
medida
]
.
mean
()
fig
.
add_trace
(
go
.
Scatter
(
x
=
grupos
,
y
=
datosfil
,
name
=
medida
),
row
=
lrow
,
col
=
lcol
)
lrow
=
lrow
+
(
lcol
//
3
)
lcol
=
lcol
+
1
if
lcol
<
3
else
1
fig
.
update_layout
(
showlegend
=
False
)
return
fig
def
correlaciones
(
datos
,
controlado
):
# filtramos solo a los que tienen datos del controlado
datos_fil
=
datos
.
loc
[
datos
[
controlado
]
.
notnull
()]
...
...
@@ -137,17 +163,13 @@ def correlaciones_v2(datos, controlado):
def
controlado_ppgr
(
datos
):
datos_fil
=
datos
.
loc
[
datos
[
"Glucosa"
]
.
notnull
()]
controlados
=
[
"Glucosa"
,
"Gelatina"
,
"Pan"
]
figura
=
make_subplots
(
rows
=
2
,
cols
=
3
,
subplot_titles
=
controlados
)
figura
=
make_subplots
(
rows
=
1
,
cols
=
3
,
subplot_titles
=
controlados
)
lcol
=
1
for
controlado
in
controlados
:
figura
.
add_trace
(
go
.
Scatter
(
y
=
datos
[
controlado
],
name
=
controlado
,
mode
=
"markers"
),
go
.
Scatter
(
x
=
datos
[
"id"
],
y
=
datos
[
controlado
],
name
=
controlado
,
mode
=
"markers"
),
row
=
1
,
col
=
lcol
)
figura
.
add_trace
(
go
.
Histogram
(
x
=
datos
[
controlado
],
name
=
controlado
,
histnorm
=
"probability"
),
row
=
2
,
col
=
lcol
)
lcol
=
lcol
+
1
figura
.
update_layout
(
showlegend
=
False
,
...
...
@@ -156,6 +178,14 @@ def controlado_ppgr(datos):
)
return
figura
def
controlado_ppgr2
(
datos
):
controlados
=
[
"Glucosa"
,
"Gelatina"
,
"Pan"
]
datos_fil
=
datos
[
controlados
]
datos_fil
=
datos_fil
[
~
datos_fil
.
isnull
()
.
any
(
axis
=
1
)]
figura
=
ff
.
create_distplot
([
datos_fil
[
controlado
]
for
controlado
in
controlados
],
controlados
,
show_hist
=
False
,
show_rug
=
False
)
return
figura
def
triareas
(
pacientes
):
figura
=
make_subplots
(
rows
=
1
,
cols
=
1
)
for
paciente
in
pacientes
:
...
...
@@ -466,18 +496,21 @@ app.layout = html.Div(children=[
# descripción por diferentes indices
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Distribuciones de la población"
,
className
=
"header-title2"
),],
),
dcc
.
Graph
(
figure
=
popdist
(
visitas_incluidos
))
dcc
.
Graph
(
figure
=
popdist
(
visitas_incluidos
)),
]),
# correlaciones entre indices de la poblacion
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Correlaciones entre medidas"
,
className
=
"header-title2"
),],
),
dcc
.
Graph
(
figure
=
popcorr
(
visitas_incluidos
))
html
.
Div
(
children
=
[
html
.
H1
(
"Relaciones entre IMC y QS"
,
className
=
"header-title2"
),],
),
dcc
.
Graph
(
figure
=
popcorr
(
visitas_incluidos
)),
dcc
.
Graph
(
figure
=
imc_cat
(
visitas_incluidos
))
]),
# ppgr a controlados
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"iAUC/Controlados "
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
controlado_ppgr
(
visitas_incluidos
))
dcc
.
Graph
(
figure
=
controlado_ppgr
(
visitas_incluidos
)),
dcc
.
Graph
(
figure
=
controlado_ppgr2
(
visitas_incluidos
))
]),
# correlaciones
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment