Jan Mühlnikel
commited on
Commit
·
6f41b63
1
Parent(s):
e328e58
test
Browse files- functions/single_similar.py +15 -6
- similarity_page.py +4 -4
functions/single_similar.py
CHANGED
|
@@ -1,15 +1,24 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
|
| 4 |
-
def find_similar(p_index, similarity_matrix,
|
| 5 |
selected_row = similarity_matrix[p_index]
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
top_projects_df["similarity"] = top_values
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
|
| 4 |
+
def find_similar(p_index, similarity_matrix, filtered_df, top_x):
|
| 5 |
selected_row = similarity_matrix[p_index]
|
| 6 |
+
filtered_indices = filtered_df.index.tolist()
|
| 7 |
+
print(filtered_indices)
|
| 8 |
|
| 9 |
+
index_position_mapping = {index: position for position, index in enumerate(filtered_indices)}
|
| 10 |
+
print(index_position_mapping)
|
| 11 |
|
|
|
|
| 12 |
|
| 13 |
+
#filtered_column_matrix = similarity_matrix[:, filtered_indices]
|
| 14 |
+
|
| 15 |
+
#top_indexes = np.argsort(selected_row)[-top_x:][::-1]
|
| 16 |
+
#top_values = selected_row[top_indexes]
|
| 17 |
+
|
| 18 |
+
#top_projects_df = projects_df.iloc[top_indexes]
|
| 19 |
+
|
| 20 |
+
#top_projects_df["similarity"] = top_values
|
| 21 |
+
|
| 22 |
+
return "top_projects_df"
|
| 23 |
|
| 24 |
|
similarity_page.py
CHANGED
|
@@ -335,8 +335,8 @@ def show_single_matching_page():
|
|
| 335 |
|
| 336 |
#selected_index = None
|
| 337 |
if project_option:
|
| 338 |
-
|
| 339 |
-
st.dataframe(projects_df.iloc[
|
| 340 |
|
| 341 |
# COUNTRY CODES LIST
|
| 342 |
country_code_list = [option[-3:-1] for option in country_option_s]
|
|
@@ -350,6 +350,6 @@ def show_single_matching_page():
|
|
| 350 |
|
| 351 |
if isinstance(filtered_df_s, pd.DataFrame) and len(filtered_df_s) != 0:
|
| 352 |
|
| 353 |
-
top_projects_df = find_similar(
|
| 354 |
-
show_single_table(top_projects_df)
|
| 355 |
|
|
|
|
| 335 |
|
| 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]
|
|
|
|
| 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 |
+
#show_single_table(top_projects_df)
|
| 355 |
|