Commit 1b68c820 authored by Joaquin Torres's avatar Joaquin Torres

Printing comparison of PRE-POST corr matrices in corresponding colors

parent 4474be13
...@@ -72,13 +72,13 @@ ...@@ -72,13 +72,13 @@
"name": "stderr", "name": "stderr",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"C:\\Users\\Joaquín Torres\\AppData\\Local\\Temp\\ipykernel_15848\\2495984927.py:18: SettingWithCopyWarning: \n", "C:\\Users\\Joaquín Torres\\AppData\\Local\\Temp\\ipykernel_15568\\2495984927.py:18: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n", "A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n", "Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n", "\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" conj_post['Group'] = 'Post'\n", " conj_post['Group'] = 'Post'\n",
"C:\\Users\\Joaquín Torres\\AppData\\Local\\Temp\\ipykernel_15848\\2495984927.py:19: SettingWithCopyWarning: \n", "C:\\Users\\Joaquín Torres\\AppData\\Local\\Temp\\ipykernel_15568\\2495984927.py:19: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n", "A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n", "Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n", "\n",
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
"name": "stderr", "name": "stderr",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"C:\\Users\\Joaquín Torres\\AppData\\Local\\Temp\\ipykernel_15848\\1073322024.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.\n", "C:\\Users\\Joaquín Torres\\AppData\\Local\\Temp\\ipykernel_15568\\1073322024.py:3: FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. In a future version, replace will only be used for cases that preserve the categories. To change the categories, use ser.cat.rename_categories instead.\n",
" bd['Risk_stigma'] = bd['Risk_stigma'].replace(99.0, mode_stigma)\n" " bd['Risk_stigma'] = bd['Risk_stigma'].replace(99.0, mode_stigma)\n"
] ]
} }
...@@ -854,7 +854,7 @@ ...@@ -854,7 +854,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -942,7 +942,7 @@ ...@@ -942,7 +942,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -991,7 +991,7 @@ ...@@ -991,7 +991,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 63, "execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1005,13 +1005,56 @@ ...@@ -1005,13 +1005,56 @@
" for j, var_j in enumerate(cols):\n", " for j, var_j in enumerate(cols):\n",
" # If difference greater than certain threshold, print variables \n", " # If difference greater than certain threshold, print variables \n",
" diff = abs(m_pre[i][j] - m_post[i][j])\n", " diff = abs(m_pre[i][j] - m_post[i][j])\n",
" # Skip unknown vars and desc for now\n",
" if diff > 0.4 and 'ledge' not in (var_i+var_j) and 'Desc' not in (var_i+var_j):\n", " if diff > 0.4 and 'ledge' not in (var_i+var_j) and 'Desc' not in (var_i+var_j):\n",
" print(f\"{var_i}---{var_j}: {diff:.2f}\")" " # Give ind vs soc vars their corresponding color\n",
" if var_i in ind_vars_enc:\n",
" print(colors.GREEN + var_i + colors.RESET, end = ' ')\n",
" else:\n",
" print(colors.PURPLE + var_i + colors.PURPLE, end = ' ')\n",
" print(\"--- \", end = '')\n",
" if var_j in ind_vars_enc:\n",
" print(colors.GREEN + var_j + colors.RESET, end = ' ')\n",
" else:\n",
" print(colors.PURPLE + var_j + colors.RESET, end = ' ')\n",
" print(f\"--> Diff: {diff:.2f}\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[91mThis is red text.\u001b[0m\n",
"\u001b[92mThis is green text.\u001b[0m\n",
"\u001b[94mThis is blue text.\u001b[0m\n"
]
}
],
"source": [
"class colors:\n",
" RED = '\\033[91m'\n",
" GREEN = '\\033[92m'\n",
" YELLOW = '\\033[93m'\n",
" BLUE = '\\033[94m'\n",
" PURPLE = '\\033[95m'\n",
" CYAN = '\\033[96m'\n",
" WHITE = '\\033[97m'\n",
" RESET = '\\033[0m'\n",
"\n",
"# Print colored text\n",
"print(colors.RED + \"This is red text.\" + colors.RESET)\n",
"print(colors.GREEN + \"This is green text.\" + colors.RESET)\n",
"print(colors.BLUE + \"This is blue text.\" + colors.RESET)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 64, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1019,48 +1062,48 @@ ...@@ -1019,48 +1062,48 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"------SIT_TTO 1: NO FILTERING------\n", "------SIT_TTO 1: NO FILTERING------\n",
"Alucinogenos_DXCIE_REDEF---Ed_Secondary Education: 0.42\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mEd_Secondary Education\u001b[0m --> Diff: 0.42\n",
"Alucinogenos_DXCIE_REDEF---Ed_Secondary more technical education: 0.55\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mEd_Secondary more technical education\u001b[0m --> Diff: 0.55\n",
"Alucinogenos_DXCIE_REDEF---JobIn_Stable: 0.64\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mJobIn_Stable\u001b[0m --> Diff: 0.64\n",
"Alucinogenos_DXCIE_REDEF---SocInc_Live with families or friends: 0.50\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mSocInc_Live with families or friends\u001b[0m --> Diff: 0.50\n",
"Alucinogenos_DXCIE_REDEF---SocInc_live alone: 0.53\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mSocInc_live alone\u001b[0m --> Diff: 0.53\n",
"Alucinogenos_DXCIE_REDEF---Sex_REDEF: 0.40\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[92mSex_REDEF\u001b[0m --> Diff: 0.40\n",
"Alucinogenos_DXCIE_REDEF---Opiaceos_DxCIE_REDEF: 0.45\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[92mOpiaceos_DxCIE_REDEF\u001b[0m --> Diff: 0.45\n",
"Frec30_2-3 días‎/semana---Alucinogenos_DXCIE_REDEF: 0.54\n", "\u001b[92mFrec30_2-3 días‎/semana\u001b[0m --- \u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --> Diff: 0.54\n",
"Tx_previos_REDEF---Alucinogenos_DXCIE_REDEF: 0.48\n", "\u001b[92mTx_previos_REDEF\u001b[0m --- \u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --> Diff: 0.48\n",
"\n", "\n",
"\n", "\n",
"\n", "\n",
"\n", "\n",
"------SIT_TTO 2: ABANDONO-----\n", "------SIT_TTO 2: ABANDONO-----\n",
"Alucinogenos_DXCIE_REDEF---Ed_Secondary more technical education: 0.51\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mEd_Secondary more technical education\u001b[0m --> Diff: 0.51\n",
"Alucinogenos_DXCIE_REDEF---JobIn_Stable: 0.58\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mJobIn_Stable\u001b[0m --> Diff: 0.58\n",
"Alucinogenos_DXCIE_REDEF---JobIn_Unemployed: 0.44\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mJobIn_Unemployed\u001b[0m --> Diff: 0.44\n",
"Alucinogenos_DXCIE_REDEF---SocInc_Live with families or friends: 0.48\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mSocInc_Live with families or friends\u001b[0m --> Diff: 0.48\n",
"Alucinogenos_DXCIE_REDEF---SocInc_live alone: 0.50\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mSocInc_live alone\u001b[0m --> Diff: 0.50\n",
"Alucinogenos_DXCIE_REDEF---Risk_stigma_REDEF: 0.46\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mRisk_stigma_REDEF\u001b[0m --> Diff: 0.46\n",
"Alucinogenos_DXCIE_REDEF---Opiaceos_DxCIE_REDEF: 0.49\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[92mOpiaceos_DxCIE_REDEF\u001b[0m --> Diff: 0.49\n",
"Frec30_2-3 días‎/semana---Alucinogenos_DXCIE_REDEF: 0.44\n", "\u001b[92mFrec30_2-3 días‎/semana\u001b[0m --- \u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --> Diff: 0.44\n",
"Frec30_Menos de 1 día‎/semana---Hous_Unstable: 0.41\n", "\u001b[92mFrec30_Menos de 1 día‎/semana\u001b[0m --- \u001b[95mHous_Unstable\u001b[0m --> Diff: 0.41\n",
"Tx_previos_REDEF---Alucinogenos_DXCIE_REDEF: 0.44\n", "\u001b[92mTx_previos_REDEF\u001b[0m --- \u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --> Diff: 0.44\n",
"\n", "\n",
"\n", "\n",
"\n", "\n",
"\n", "\n",
"------SIT_TTO 3: ALTA-----\n", "------SIT_TTO 3: ALTA-----\n",
"Hous_Stable---Ed_Secondary Education: 0.42\n", "\u001b[95mHous_Stable\u001b[95m --- \u001b[95mEd_Secondary Education\u001b[0m --> Diff: 0.42\n",
"Hous_Unstable---Ed_Secondary Education: 0.62\n", "\u001b[95mHous_Unstable\u001b[95m --- \u001b[95mEd_Secondary Education\u001b[0m --> Diff: 0.62\n",
"Hous_Unstable---Hous_Institutional: 0.42\n", "\u001b[95mHous_Unstable\u001b[95m --- \u001b[95mHous_Institutional\u001b[0m --> Diff: 0.42\n",
"SocInc_live alone---Alterations_early_childhood_develop_REDEF: 0.47\n", "\u001b[95mSocInc_live alone\u001b[95m --- \u001b[95mAlterations_early_childhood_develop_REDEF\u001b[0m --> Diff: 0.47\n",
"Opiaceos_DxCIE_REDEF---Hous_Unstable: 0.53\n", "\u001b[92mOpiaceos_DxCIE_REDEF\u001b[0m --- \u001b[95mHous_Unstable\u001b[0m --> Diff: 0.53\n",
"BZD_DxCIE_REDEF---Ed_Tertiary: 0.60\n", "\u001b[92mBZD_DxCIE_REDEF\u001b[0m --- \u001b[95mEd_Tertiary\u001b[0m --> Diff: 0.60\n",
"Alucinogenos_DXCIE_REDEF---Ed_Primary education: 0.61\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mEd_Primary education\u001b[0m --> Diff: 0.61\n",
"Alucinogenos_DXCIE_REDEF---JobIn_Non-stable: 0.54\n", "\u001b[92mAlucinogenos_DXCIE_REDEF\u001b[0m --- \u001b[95mJobIn_Non-stable\u001b[0m --> Diff: 0.54\n",
"Frec30_Menos de 1 día‎/semana---BZD_DxCIE_REDEF: 0.49\n", "\u001b[92mFrec30_Menos de 1 día‎/semana\u001b[0m --- \u001b[92mBZD_DxCIE_REDEF\u001b[0m --> Diff: 0.49\n",
"Frec30_No consumio---Hous_Unstable: 0.45\n", "\u001b[92mFrec30_No consumio\u001b[0m --- \u001b[95mHous_Unstable\u001b[0m --> Diff: 0.45\n",
"Frec30_No consumio---BZD_DxCIE_REDEF: 0.55\n", "\u001b[92mFrec30_No consumio\u001b[0m --- \u001b[92mBZD_DxCIE_REDEF\u001b[0m --> Diff: 0.55\n",
"OtrosDx_Psiquiatrico_REDEF---Hous_Unstable: 0.42\n", "\u001b[92mOtrosDx_Psiquiatrico_REDEF\u001b[0m --- \u001b[95mHous_Unstable\u001b[0m --> Diff: 0.42\n",
"Tx_previos_REDEF---BZD_DxCIE_REDEF: 0.41\n" "\u001b[92mTx_previos_REDEF\u001b[0m --- \u001b[92mBZD_DxCIE_REDEF\u001b[0m --> Diff: 0.41\n"
] ]
} }
], ],
This source diff could not be displayed because it is too large. You can view the blob instead.
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