Spaces:
Running
Running
Upload mass_modelos_nlp_db.py
Browse files
src/embeddings/mass_modelos_nlp_db.py
CHANGED
|
@@ -156,7 +156,7 @@ import numpy as np
|
|
| 156 |
def search_mass(path_df_iniciativas, top_ods, top_meta, top_indicador):
|
| 157 |
|
| 158 |
df_iniciativas = pd.read_excel(path_df_iniciativas)
|
| 159 |
-
df_categorias = [categoria for categoria in df_iniciativas.columns if categoria.
|
| 160 |
# patr_tblinput = 'data/raw/Copy of Iniciativas priorizadas PATR 385.xlsx' #"CSV with PATR projects (columns: id, descripcion, ...).")
|
| 161 |
ods_tblinput = Path('data/raw/v2_tabla_odsDescripcion_revLA 03032026.xlsx') #Entrenamiento 3
|
| 162 |
# ods_tblinput = Path('data/raw/v2_tabla_odsDescripcion_revLA.xlsx') #Entrenamiento 2
|
|
@@ -169,6 +169,7 @@ def search_mass(path_df_iniciativas, top_ods, top_meta, top_indicador):
|
|
| 169 |
pilares_tblinput = Path('data/raw/pilares.xlsx' )
|
| 170 |
categorias_tblinput = Path('data/raw/categorias.xlsx')
|
| 171 |
estrategias_tblinput = Path('data/raw/estrategias.xlsx')
|
|
|
|
| 172 |
out_dir = 'data/embeddings' # '/content/drive/MyDrive/Compartida/06_Desarrollo de la herramienta IA/01_MPTF /archivos_trabajo/salidas/modelo_instructor/data/out' #"Output directory.")
|
| 173 |
model_name = "hkunlp/instructor-large" #help="HF model name for embeddings.")
|
| 174 |
instr_proj = "Representa el propósito de desarrollo sostenible del siguiente proyecto territorial" #"Instruction for PATR projects.")
|
|
@@ -198,6 +199,7 @@ def search_mass(path_df_iniciativas, top_ods, top_meta, top_indicador):
|
|
| 198 |
pilares_df = pd.read_excel(pilares_tblinput)
|
| 199 |
estrategias_df = pd.read_excel(estrategias_tblinput)
|
| 200 |
categorias_df = pd.read_excel(categorias_tblinput)
|
|
|
|
| 201 |
|
| 202 |
# nlp = spacy.load("es_core_news_md")
|
| 203 |
# query = limpiar_texto(query, nlp)
|
|
@@ -668,6 +670,10 @@ def search_mass(path_df_iniciativas, top_ods, top_meta, top_indicador):
|
|
| 668 |
# bdl_ods = bdl_ods.merge(res_dfs[9], 'inner', left_on='INICIATIVA_ID', right_on='INICIATIVA_ID')
|
| 669 |
print(f'Tamaño BDL: {len(bdl_ods)}')
|
| 670 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
|
| 672 |
|
| 673 |
# return (querys, res_dfs[0], res_dfs[1], res_dfs[2], res_dfs[3], res_dfs[4], res_dfs[5], res_dfs[6], res_dfs[7], res_dfs[8], bdl_ods)
|
|
|
|
| 156 |
def search_mass(path_df_iniciativas, top_ods, top_meta, top_indicador):
|
| 157 |
|
| 158 |
df_iniciativas = pd.read_excel(path_df_iniciativas)
|
| 159 |
+
df_categorias = [categoria for categoria in df_iniciativas.columns if categoria.isin(['id_unico', 'iniciativa'])==False]
|
| 160 |
# patr_tblinput = 'data/raw/Copy of Iniciativas priorizadas PATR 385.xlsx' #"CSV with PATR projects (columns: id, descripcion, ...).")
|
| 161 |
ods_tblinput = Path('data/raw/v2_tabla_odsDescripcion_revLA 03032026.xlsx') #Entrenamiento 3
|
| 162 |
# ods_tblinput = Path('data/raw/v2_tabla_odsDescripcion_revLA.xlsx') #Entrenamiento 2
|
|
|
|
| 169 |
pilares_tblinput = Path('data/raw/pilares.xlsx' )
|
| 170 |
categorias_tblinput = Path('data/raw/categorias.xlsx')
|
| 171 |
estrategias_tblinput = Path('data/raw/estrategias.xlsx')
|
| 172 |
+
recomendaciones_tblinput = Path('data/raw/ODS_169_metas_recomendaciones_detalladas.xlsx')
|
| 173 |
out_dir = 'data/embeddings' # '/content/drive/MyDrive/Compartida/06_Desarrollo de la herramienta IA/01_MPTF /archivos_trabajo/salidas/modelo_instructor/data/out' #"Output directory.")
|
| 174 |
model_name = "hkunlp/instructor-large" #help="HF model name for embeddings.")
|
| 175 |
instr_proj = "Representa el propósito de desarrollo sostenible del siguiente proyecto territorial" #"Instruction for PATR projects.")
|
|
|
|
| 199 |
pilares_df = pd.read_excel(pilares_tblinput)
|
| 200 |
estrategias_df = pd.read_excel(estrategias_tblinput)
|
| 201 |
categorias_df = pd.read_excel(categorias_tblinput)
|
| 202 |
+
recomendaciones_df = pd.read_excel(recomendaciones_tblinput)
|
| 203 |
|
| 204 |
# nlp = spacy.load("es_core_news_md")
|
| 205 |
# query = limpiar_texto(query, nlp)
|
|
|
|
| 670 |
# bdl_ods = bdl_ods.merge(res_dfs[9], 'inner', left_on='INICIATIVA_ID', right_on='INICIATIVA_ID')
|
| 671 |
print(f'Tamaño BDL: {len(bdl_ods)}')
|
| 672 |
|
| 673 |
+
## Complementando metas con recomendaciones de indicadores
|
| 674 |
+
res_dfs[1] = res_dfs[1].merge(recomendaciones_df[['Meta_ODS', 'Recomendaciones_territoriales']], 'left', left_on='META_ID', right_on='META_ID')
|
| 675 |
+
|
| 676 |
+
|
| 677 |
|
| 678 |
|
| 679 |
# return (querys, res_dfs[0], res_dfs[1], res_dfs[2], res_dfs[3], res_dfs[4], res_dfs[5], res_dfs[6], res_dfs[7], res_dfs[8], bdl_ods)
|