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
5d5556f7
Commit
5d5556f7
authored
Dec 11, 2024
by
Jose Luis Gordillo Ruiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gráficas de porcentajes y de iaucs por comida
parent
88d6a6b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
6 deletions
+59
-6
estadisticas.py
+59
-6
No files found.
estadisticas.py
View file @
5d5556f7
...
...
@@ -196,10 +196,7 @@ def comidas_porcentajes(datos):
datos
[
"total"
]
=
datos
[
columnas
]
.
sum
(
axis
=
1
)
datos
=
datos
[
datos
[
"total"
]
>
0
]
datos
[
columnas
]
=
datos
[
columnas
]
.
div
(
datos
[
"total"
],
axis
=
0
)
print
(
datos
[
columnas
]
.
head
())
figura
=
go
.
Figure
()
lrow
=
1
lcol
=
1
for
columna
in
columnas
:
datosfil
=
datos
[
np
.
abs
(
stats
.
zscore
(
datos
[
columna
],
nan_policy
=
'omit'
))
<
3
]
figura
.
add_trace
(
...
...
@@ -212,6 +209,50 @@ def comidas_porcentajes(datos):
)
return
figura
def
comidas_principales
(
datos
):
dominantes
=
datos
.
groupby
(
"dominante"
)
categorias
=
datos
.
groupby
(
"dominante_category"
)
figura
=
make_subplots
(
cols
=
1
,
rows
=
1
)
figura
.
add_trace
(
go
.
Scatter
(
x
=
list
(
dominantes
.
groups
.
keys
()),
y
=
dominantes
.
count
()[
"patient"
],
mode
=
'markers'
),
col
=
1
,
row
=
1
)
return
figura
def
comidas_principales_categorias
(
datos
):
categorias
=
datos
.
groupby
(
"dominante_category"
)
figura
=
make_subplots
(
cols
=
1
,
rows
=
1
)
figura
.
add_trace
(
go
.
Scatter
(
x
=
list
(
categorias
.
groups
.
keys
()),
y
=
categorias
.
count
()[
"patient"
],
mode
=
'markers'
),
col
=
1
,
row
=
1
)
return
figura
def
comidas_principales_hists
(
datos
):
dominantes
=
datos
.
groupby
(
"dominante"
)
categorias
=
datos
.
groupby
(
"dominante_category"
)
figura
=
make_subplots
(
cols
=
1
,
rows
=
2
)
figura
.
add_trace
(
go
.
Histogram
(
x
=
dominantes
.
count
()[
"patient"
]),
col
=
1
,
row
=
1
)
figura
.
add_trace
(
go
.
Histogram
(
x
=
categorias
.
count
()[
"patient"
]),
col
=
1
,
row
=
2
)
figura
.
update_layout
(
bargap
=
0.05
,
# gap between bars of adjacent location coordinates
bargroupgap
=
0.05
,
# gap between bars of the same location coordinates
showlegend
=
False
)
return
figura
def
aucs_paciente
(
datos
):
figura
=
px
.
box
(
datos
,
x
=
"patient"
,
y
=
"iAUC"
)
return
figura
def
heatmap
(
datos
):
datosfil
=
datos
.
replace
(
0
,
np
.
nan
)
...
...
@@ -317,7 +358,7 @@ visitas_datos = [ get_visit_data(visita) for visita in range(1, 5)]
comidas
=
pd
.
read_csv
(
"todos-foods.csv"
,
usecols
=
[
"hc_total"
,
"kcal_total"
,
"fiber_total"
,
\
"protein_total"
,
"lipids_total"
,
"fecha_hora"
,
"patient"
,
"visita"
,
\
"glucosa_basal_area"
,
"glucosa_estimulo_area"
,
\
"glucosa_area_efectiva"
,
"glucosa_area_relativa"
,
"foods"
])
"glucosa_area_efectiva"
,
"glucosa_area_relativa"
,
"foods"
,
"dominante"
,
"dominante_category"
])
comidas
[
"foods"
]
=
comidas
[
"foods"
]
.
apply
(
literal_eval
)
comidas
=
comidas
[
comidas
[
"visita"
]
==
"e1"
]
...
...
@@ -439,7 +480,14 @@ app.layout = html.Div(children=[
html
.
Div
(
children
=
[
html
.
H1
(
"Distribución de
%
s de Macronutrientes de comidas"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_porcentajes
(
comidas
))
,]),
# # de comidas por componente dominante
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Distribución de num. de comidas por componente principal"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_principales
(
comidas
)),
dcc
.
Graph
(
figure
=
comidas_principales_categorias
(
comidas
)),
dcc
.
Graph
(
figure
=
comidas_principales_hists
(
comidas
))
,]),
# descripcion de comidas por paciente
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Macronutrientes de comidas por paciente"
,
className
=
"header-title2"
)]),
...
...
@@ -447,9 +495,14 @@ app.layout = html.Div(children=[
,]),
# descripcion de aucs comidas por paciente
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"AUCs de comidas por paciente"
,
className
=
"header-title2"
)]),
html
.
Div
(
children
=
[
html
.
H1
(
"AUCs
promedio
de comidas por paciente"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_auc_paciente
(
comidas
))
,]),
# descripcion de aucs comidas por paciente
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"iAUCs de comidas por paciente"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
aucs_paciente
(
comidas
))
,]),
])
# cierre del layout
...
...
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