<jupyter_start><jupyter_text>SetupThis notebook explains how to to access the dataset models from django.The datasets are loaded from the Postgres database into pandas dataframes.To start the notebook server:``` Start a bash shell inside the api containerdocker-compose exec api /bin/bash Start the jupyter notebookpython manage.py shell_plus --notebook Take note of the token provided and access the notebook through::7777/?http://127.0.0.1:7777/?token=<KEY>```This step has only to be made once as long as the jupyter-notebook keeps executing.Considering that the the notebook continues to run, you can access the notebook using:``` :7777/?```<jupyter_code># Required to access the database
import os
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"

import sys
import numpy
numpy.set_printoptions(threshold=sys.maxsize)

# Data analysis tools
import pandas as pd
import numpy as np
import seaborn as sns

# Models available in our application
from datasets.models import RawFlower, RawUNM, RawDAR
from django.contrib.auth.models import User
from api import adapters
from api import analysis


df1 = adapters.neu.get_dataframe()
df2 = adapters.unm.get_dataframe()
df3 = adapters.dar.get_dataframe()
analysis.cohortdescriptive(df1,df2,df3)
df = pd.DataFrame.from_records(
    RawUNM.objects.values()
)
df.columns
to_corr_cols = ['TimePeriod', 'Member_c', 'Outcome', 'Outcome_weeks', 'age',
                'ethnicity', 'race', 'BMI', 'smoking', 'parity', 'preg_complications',
                'folic_acid_supp', 'fish', 'babySex', 'birthWt', 'birthLen','UTAS','UHG']

analysis.getCorrelationHeatmap(df1, to_corr_cols)
x_cols = ['fish','folic_acid_supp']
y_cols = ['UHG','UTAS']

analysis.getSpearmans(df1, x_cols, y_cols).round(3)
to_corr_cols = ['TimePeriod', 'Member_c', 'Outcome', 'Outcome_weeks', 'age',
       'ethnicity', 'race', 'education', 'BMI', 'income', 'smoking', 'parity',
       'preg_complications', 'folic_acid_supp', 'fish', 'babySex', 'birthWt',
       'birthLen', 'UTAS', 'CohortType']

analysis.getCorrelationHeatmap(df2, to_corr_cols)
x_cols = ['fish','folic_acid_supp']
y_cols = ['UHG','UTAS']

analysis.getSpearmans(df2, x_cols, y_cols).round(3)
to_corr_cols_dar = ['Member_c', 'TimePeriod', 
                   'sample_gestage_days', 'Outcome', 
                   'age','ethnicity','race','education','BMI',
                   'smoking','parity', 'preg_complications',
                   'folic_acid_supp','babySex',
                   'birthWt','birthLen','headCirc','ponderal','PNFFQTUNA',
                   'PNFFQFR_FISH_KIDS','PNFFQSHRIMP_CKD','PNFFQDK_FISH','PNFFQOTH_FISH',
                   'mfsp_6','fish','TOTALFISH_SERV','UIAS', 'UASB', 'UAS3', 'UAS5','UHG','UAS']

analysis.getCorrelationHeatmap(df3, to_corr_cols_dar)
x_cols = ['PNFFQFR_FISH_KIDS','PNFFQSHRIMP_CKD','PNFFQDK_FISH','PNFFQOTH_FISH','mfsp_6','fish','TOTALFISH_SERV']
y_cols = ['UIAS', 'UASB', 'UAS3', 'UAS5','UHG','UAS']

analysis.getSpearmans(df3, x_cols, y_cols).round(3)[0:20]<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup