Jan Mühlnikel
commited on
Commit
·
3137797
1
Parent(s):
52c689e
experiment
Browse files- functions/calc_matches.py +13 -9
functions/calc_matches.py
CHANGED
@@ -45,25 +45,29 @@ def calc_matches(filtered_df, project_df, similarity_matrix, top_x):
|
|
45 |
|
46 |
# Take the first k indices to get the top k maximum values
|
47 |
top_indices = sorted_indices[:top_x]
|
48 |
-
|
49 |
# Convert flat indices to 2D row and column indices
|
50 |
-
row_indices, col_indices = match_matrix.nonzero()
|
51 |
-
row_indices = row_indices[top_indices]
|
52 |
-
col_indices = col_indices[top_indices]
|
53 |
|
54 |
# Get the values corresponding to the top k indices
|
55 |
top_values = flat_data[top_indices]
|
56 |
|
57 |
-
#top_filtered_df_indices = [filtered_df_index_map[i] for i in col_indices]
|
58 |
-
#top_project_df_indices = [project_df_index_map[i] for i in row_indices]
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
# Create resulting dataframes with top matches and their similarity scores
|
63 |
-
p1_df = filtered_df.loc[
|
64 |
p1_df['similarity'] = top_values
|
65 |
|
66 |
-
p2_df = project_df.loc[
|
67 |
p2_df['similarity'] = top_values
|
68 |
print("finished calc matches")
|
69 |
|
|
|
45 |
|
46 |
# Take the first k indices to get the top k maximum values
|
47 |
top_indices = sorted_indices[:top_x]
|
48 |
+
st.write(top_indices)
|
49 |
# Convert flat indices to 2D row and column indices
|
50 |
+
#row_indices, col_indices = match_matrix.nonzero()
|
51 |
+
#row_indices = row_indices[top_indices]
|
52 |
+
#col_indices = col_indices[top_indices]
|
53 |
|
54 |
# Get the values corresponding to the top k indices
|
55 |
top_values = flat_data[top_indices]
|
56 |
|
|
|
|
|
57 |
|
58 |
+
# Get the values corresponding to the top k indices
|
59 |
+
top_values = match_matrix[row_indices, col_indices]
|
60 |
+
|
61 |
+
top_filtered_df_indices = [filtered_df_index_map[i] for i in col_indices]
|
62 |
+
top_project_df_indices = [project_df_index_map[i] for i in row_indices]
|
63 |
+
|
64 |
+
st.write(top_filtered_df_indices)
|
65 |
|
66 |
# Create resulting dataframes with top matches and their similarity scores
|
67 |
+
p1_df = filtered_df.loc[top_filtered_df_indices].copy()
|
68 |
p1_df['similarity'] = top_values
|
69 |
|
70 |
+
p2_df = project_df.loc[top_project_df_indices].copy()
|
71 |
p2_df['similarity'] = top_values
|
72 |
print("finished calc matches")
|
73 |
|