mas correciones para correr detrás de apache

parent e0dbe69c
......@@ -4,9 +4,9 @@ import plotly.graph_objects as go
import plotly.express as px
import requests
import numpy as np
+import flask
import flask
+server = flask.Flask(__name__)
server = flask.Flask(__name__)
# algunos parámetros globales
url = 'https://nutricion.c3.unam.mx/nd/'
......@@ -88,7 +88,7 @@ external_stylesheets = [
"rel": "stylesheet",
},
]
app = Dash(__name__, external_stylesheets=external_stylesheets)
app = Dash(__name__, external_stylesheets=external_stylesheets, server=server, url_base_pathname='/nutri/inventario/')
app.title = "NutrINDmex. Inventario de datos"
......
......@@ -5,10 +5,12 @@ import plotly.express as px
import requests
import numpy as np
from plotly.subplots import make_subplots
import socket
from sklearn.cluster import KMeans
from scipy import stats
from ast import literal_eval
import flask
server = flask.Flask(__name__)
def datavis(datos):
medidas = ["imc", "age", "glucose", "hba1c", "ct", "hdl"]
......@@ -49,6 +51,8 @@ def popdist(datos):
)
return fig
def correlaciones(datos, controlado):
# filtramos solo a los que tienen datos del controlado
datos_fil = datos.loc[datos[controlado].notnull()]
......@@ -76,6 +80,36 @@ def correlaciones(datos, controlado):
figura.update_layout(showlegend=False)
return figura
def correlaciones_v2(datos, controlado):
# filtramos solo a los que tienen datos del controlado
datos_fil2 = datos.loc[datos[controlado].notnull()]
metricas = ["imc", "age", "glucose", "hba1c"]
figura = make_subplots(rows=2, cols=2, shared_xaxes=True, vertical_spacing=0.1, subplot_titles=metricas)
lrow = 1
lcol = 1
for metrica in metricas:
datos_sorted = datos_fil2.sort_values(by=metrica, ascending=True)
datos_sorted.reset_index(inplace=True)
datosfil = datos_sorted[np.abs(stats.zscore(datos_sorted[controlado], nan_policy='omit')) < 3]
figura.add_trace(
go.Scatter(x=datosfil.index, y=datosfil[controlado], name=metrica, mode='markers'),
row=lrow, col=lcol
)
figura.add_trace(
go.Scatter(x=datosfil.index, y=datosfil[controlado].rolling(5).mean(), name="PM(5)"),
row=lrow, col=lcol
)
corr = datos_sorted[[metrica]].corrwith(datos_sorted[controlado]).values[0]
figura.add_annotation(row=lrow, col=lcol, text="R = " + "{:.2f}".format(corr))
lcol = lcol + 1 if lcol < 2 else 1
lrow = lrow + (lcol % 2)
figura.update_layout(showlegend=False)
return figura
def controlado_ppgr(datos):
datos_fil = datos.loc[datos["Glucosa"].notnull()]
......@@ -321,7 +355,8 @@ external_stylesheets = [
"rel": "stylesheet",
},
]
app = Dash(__name__, external_stylesheets=external_stylesheets)
app = Dash(__name__, external_stylesheets=external_stylesheets, server=server, url_base_pathname='/nutri/estadisticas/')
app.title = "NutrIndMex. Análisis de datos."
app.layout = html.Div(children=[
......@@ -354,6 +389,11 @@ app.layout = html.Div(children=[
html.Div(children= [
html.Div(children= [html.H1("Relación de iAUC/Controlados con diversos índices", className = "header-title2")]), dcc.Graph(figure=correlaciones(visitas_incluidos, "Glucosa"))
]),
# correlaciones transpuesta
html.Div(children= [
html.Div(children= [html.H1("Relación de iAUC/Controlados con diversos índices (traspuesta)", className = "header-title2")]), dcc.Graph(figure=correlaciones_v2(visitas_incluidos, "Glucosa"))
]),
# areas de tres pacientes
html.Div(children= [
html.Div(children= [html.H1("Ejemplos de iAUC de Glucosa", className = "header-title2")]),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment