Jan Mühlnikel
commited on
Commit
·
5d7d815
1
Parent(s):
9dce01e
added selected project df
Browse files- functions/single_similar.py +1 -2
- modules/singlematch_result_table.py +83 -2
- similarity_page.py +1 -7
functions/single_similar.py
CHANGED
|
@@ -16,8 +16,7 @@ def find_similar(p_index, similarity_matrix, filtered_df, top_x):
|
|
| 16 |
project_row = filtered_column_sim_matrix[p_index]
|
| 17 |
sorted_indices = np.argsort(project_row)
|
| 18 |
top_10_indices_descending = sorted_indices[-10:][::-1]
|
| 19 |
-
top_10_original_indices = [index_position_mapping[position] for position in top_10_indices_descending]
|
| 20 |
-
|
| 21 |
top_10_values_descending = project_row[top_10_indices_descending]
|
| 22 |
|
| 23 |
result_df = filtered_df.iloc[top_10_indices_descending]
|
|
|
|
| 16 |
project_row = filtered_column_sim_matrix[p_index]
|
| 17 |
sorted_indices = np.argsort(project_row)
|
| 18 |
top_10_indices_descending = sorted_indices[-10:][::-1]
|
| 19 |
+
#top_10_original_indices = [index_position_mapping[position] for position in top_10_indices_descending]
|
|
|
|
| 20 |
top_10_values_descending = project_row[top_10_indices_descending]
|
| 21 |
|
| 22 |
result_df = filtered_df.iloc[top_10_indices_descending]
|
modules/singlematch_result_table.py
CHANGED
|
@@ -1,10 +1,91 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
-
def show_single_table(result_df):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
if len(result_df) == 0:
|
| 7 |
-
st.write("No
|
| 8 |
else:
|
| 9 |
result_df = result_df.reset_index(drop=True)
|
| 10 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
+
def show_single_table(selected_project_index, projects_df, result_df):
|
| 5 |
+
|
| 6 |
+
st.write("------------------")
|
| 7 |
+
sel_p_row = projects_df.iloc[selected_project_index]
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
sel_p_row["crs_3_code_list"] = [sel_p_row['crs_3_code'].item().split(";")[:-1]]
|
| 11 |
+
except:
|
| 12 |
+
sel_p_row["crs_3_code_list"] = [""]
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
sel_p_row["crs_5_code_list"] = [sel_p_row['crs_5_code'].item().split(";")[:-1]]
|
| 16 |
+
except:
|
| 17 |
+
sel_p_row["crs_5_code_list"] = [""]
|
| 18 |
+
|
| 19 |
+
sel_p_row["sdg_list"] = [sel_p_row['sgd_pred_code'].item()]
|
| 20 |
+
|
| 21 |
+
st.dataframe(
|
| 22 |
+
sel_p_row[["iati_id", "title_main", "orga_abbreviation", "client", "description_main", "country_name", "country_flag", "sdg_list", "crs_3_code_list", "crs_5_code_list"]],
|
| 23 |
+
use_container_width = True,
|
| 24 |
+
height = 35 + 35 * len(sel_p_row),
|
| 25 |
+
column_config={
|
| 26 |
+
"iati_id": st.column_config.TextColumn(
|
| 27 |
+
"IATI ID",
|
| 28 |
+
help="IATI Project ID",
|
| 29 |
+
disabled=True,
|
| 30 |
+
width="small"
|
| 31 |
+
),
|
| 32 |
+
"orga_abbreviation": st.column_config.TextColumn(
|
| 33 |
+
"Organization",
|
| 34 |
+
help="If description not in English, description in other language provided",
|
| 35 |
+
disabled=True,
|
| 36 |
+
width="small"
|
| 37 |
+
),
|
| 38 |
+
"client": st.column_config.TextColumn(
|
| 39 |
+
"Client",
|
| 40 |
+
help="Client organization of customer",
|
| 41 |
+
disabled=True,
|
| 42 |
+
width="small"
|
| 43 |
+
),
|
| 44 |
+
"title_main": st.column_config.TextColumn(
|
| 45 |
+
"Title",
|
| 46 |
+
help="If title not in English, title in other language provided",
|
| 47 |
+
disabled=True,
|
| 48 |
+
width="large"
|
| 49 |
+
),
|
| 50 |
+
"description_main": st.column_config.TextColumn(
|
| 51 |
+
"Description",
|
| 52 |
+
help="If description not in English, description in other language provided",
|
| 53 |
+
disabled=True,
|
| 54 |
+
width="large"
|
| 55 |
+
),
|
| 56 |
+
"country_name": st.column_config.TextColumn(
|
| 57 |
+
"Country",
|
| 58 |
+
help="Country of project",
|
| 59 |
+
disabled=True,
|
| 60 |
+
width="small"
|
| 61 |
+
),
|
| 62 |
+
"country_flag": st.column_config.ImageColumn(
|
| 63 |
+
"Flag",
|
| 64 |
+
help="country flag",
|
| 65 |
+
width="small"
|
| 66 |
+
),
|
| 67 |
+
"sdg_list": st.column_config.ListColumn(
|
| 68 |
+
"SDG Prediction",
|
| 69 |
+
help="Prediction of SDG's",
|
| 70 |
+
width="small"
|
| 71 |
+
),
|
| 72 |
+
"crs_3_code_list": st.column_config.ListColumn(
|
| 73 |
+
"CRS 3",
|
| 74 |
+
help="CRS 3 code given by organization",
|
| 75 |
+
width="small"
|
| 76 |
+
),
|
| 77 |
+
"crs_5_code_list": st.column_config.ListColumn(
|
| 78 |
+
"CRS 5",
|
| 79 |
+
help="CRS 5 code given by organization",
|
| 80 |
+
width="small"
|
| 81 |
+
),
|
| 82 |
+
},
|
| 83 |
+
hide_index=True,
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
|
| 87 |
if len(result_df) == 0:
|
| 88 |
+
st.write("No results found!")
|
| 89 |
else:
|
| 90 |
result_df = result_df.reset_index(drop=True)
|
| 91 |
|
similarity_page.py
CHANGED
|
@@ -336,8 +336,6 @@ def show_single_matching_page():
|
|
| 336 |
#selected_index = None
|
| 337 |
if project_option:
|
| 338 |
selected_project_index = search_list.index(project_option)
|
| 339 |
-
st.dataframe(projects_df.iloc[selected_project_index])
|
| 340 |
-
|
| 341 |
# COUNTRY CODES LIST
|
| 342 |
country_code_list = [option[-3:-1] for option in country_option_s]
|
| 343 |
|
|
@@ -346,11 +344,7 @@ def show_single_matching_page():
|
|
| 346 |
|
| 347 |
TOP_X_PROJECTS = 10
|
| 348 |
filtered_df_s = filter_single(projects_df, country_code_list, orga_code_list)
|
| 349 |
-
st.dataframe(filtered_df_s)
|
| 350 |
-
|
| 351 |
if isinstance(filtered_df_s, pd.DataFrame) and len(filtered_df_s) != 0:
|
| 352 |
-
|
| 353 |
top_projects_df = find_similar(selected_project_index, sim_matrix, filtered_df_s, 10)
|
| 354 |
-
|
| 355 |
-
#show_single_table(top_projects_df)
|
| 356 |
|
|
|
|
| 336 |
#selected_index = None
|
| 337 |
if project_option:
|
| 338 |
selected_project_index = search_list.index(project_option)
|
|
|
|
|
|
|
| 339 |
# COUNTRY CODES LIST
|
| 340 |
country_code_list = [option[-3:-1] for option in country_option_s]
|
| 341 |
|
|
|
|
| 344 |
|
| 345 |
TOP_X_PROJECTS = 10
|
| 346 |
filtered_df_s = filter_single(projects_df, country_code_list, orga_code_list)
|
|
|
|
|
|
|
| 347 |
if isinstance(filtered_df_s, pd.DataFrame) and len(filtered_df_s) != 0:
|
|
|
|
| 348 |
top_projects_df = find_similar(selected_project_index, sim_matrix, filtered_df_s, 10)
|
| 349 |
+
show_single_table(selected_project_index, projects_df, top_projects_df)
|
|
|
|
| 350 |
|