James McCool commited on
Commit
1604a8f
·
1 Parent(s): 16d2d15

Refactor player matching logic in `find_name_mismatches.py` for improved accuracy

Browse files

- Changed the player list used for matching from a set to a list, ensuring that the closest matches are derived from a consistent data structure.
- Updated the logic for finding closest matches to enhance the accuracy of identifying players missing from projections.

global_func/find_name_mismatches.py CHANGED
@@ -20,6 +20,7 @@ def find_name_mismatches(contest_df, projections_df):
20
  for col in name_columns:
21
  portfolio_players.update(contest_df[col].unique())
22
  projection_players = set(projections_df['player_names'].unique())
 
23
  projection_players_list = list(projection_players)
24
 
25
  # Find players in portfolio that are missing from projections
@@ -31,7 +32,7 @@ def find_name_mismatches(contest_df, projections_df):
31
  if not isinstance(player, str):
32
  st.warning(f"Skipping non-string value: {player}")
33
  continue
34
- closest_matches = process.extract(player, portfolio_players, limit=1)
35
  if closest_matches[0][1] == 100: # If perfect match found
36
  match_name = closest_matches[0][0]
37
  # Update all occurrences in contest_df
@@ -59,7 +60,7 @@ def find_name_mismatches(contest_df, projections_df):
59
  current_player = st.session_state.players_to_process[st.session_state.current_player_index]
60
 
61
  # Find the top 3 closest matches
62
- closest_matches = process.extract(current_player, projection_players_list, limit=3)
63
 
64
  st.write(f"**Missing Player {st.session_state.current_player_index + 1} of {len(st.session_state.players_to_process)}:** {current_player}")
65
 
 
20
  for col in name_columns:
21
  portfolio_players.update(contest_df[col].unique())
22
  projection_players = set(projections_df['player_names'].unique())
23
+ portfolio_players_list = list(portfolio_players)
24
  projection_players_list = list(projection_players)
25
 
26
  # Find players in portfolio that are missing from projections
 
32
  if not isinstance(player, str):
33
  st.warning(f"Skipping non-string value: {player}")
34
  continue
35
+ closest_matches = process.extract(player, portfolio_players_list, limit=1)
36
  if closest_matches[0][1] == 100: # If perfect match found
37
  match_name = closest_matches[0][0]
38
  # Update all occurrences in contest_df
 
60
  current_player = st.session_state.players_to_process[st.session_state.current_player_index]
61
 
62
  # Find the top 3 closest matches
63
+ closest_matches = process.extract(current_player, portfolio_players_list, limit=3)
64
 
65
  st.write(f"**Missing Player {st.session_state.current_player_index + 1} of {len(st.session_state.players_to_process)}:** {current_player}")
66