Jimin Park commited on
Commit
5ca7f7e
·
1 Parent(s): a372432

kermitting soon

Browse files
Files changed (2) hide show
  1. util/app.py +2 -2
  2. util/helper.py +10 -7
util/app.py CHANGED
@@ -60,7 +60,7 @@ champion_encoder.fit(CHAMPIONS)
60
  def get_user_training_df(player_opgg_url):
61
  try:
62
  print("========= Inside get_user_training_df(player_opgg_url) ============= \n")
63
- print("player_opgg_url: ", player_opgg_url, "\n type(player_opgg_url): ", type(player_opgg_url), "\n")
64
 
65
  # Add input validation
66
  if not player_opgg_url or not isinstance(player_opgg_url, str):
@@ -133,7 +133,7 @@ def predict_champion(player_opgg_url, *champions):
133
  return training_df
134
 
135
  training_df = convert_df(training_df)
136
- print("type(training_df): ", type(training_df), "\n")
137
  print("check_datatypes(training_df) BEFORE feature eng. :", check_datatypes(training_df), "\n")
138
 
139
  training_df = apply_feature_engineering(training_df)
 
60
  def get_user_training_df(player_opgg_url):
61
  try:
62
  print("========= Inside get_user_training_df(player_opgg_url) ============= \n")
63
+ #print("player_opgg_url: ", player_opgg_url, "\n type(player_opgg_url): ", type(player_opgg_url), "\n")
64
 
65
  # Add input validation
66
  if not player_opgg_url or not isinstance(player_opgg_url, str):
 
133
  return training_df
134
 
135
  training_df = convert_df(training_df)
136
+ #print("type(training_df): ", type(training_df), "\n")
137
  print("check_datatypes(training_df) BEFORE feature eng. :", check_datatypes(training_df), "\n")
138
 
139
  training_df = apply_feature_engineering(training_df)
util/helper.py CHANGED
@@ -951,15 +951,15 @@ def calculate_champion_loyalty(df):
951
 
952
  season_games = [int(x) if isinstance(x, str) and x.isdigit() else 0 for x in season_games]
953
 
954
- print(f"recent_games was: {recent_games}, types: {[type(x) for x in recent_games]}")
955
- print(f"season_games was: {season_games}, types: {[type(x) for x in season_games]}")
956
 
957
- print("\nSumming recent games... \n")
958
  total_recent_games = sum(recent_games)
959
- print("total_recent_games: ", total_recent_games, "\n")
960
  total_season_games = sum(season_games)
961
- print("total_season_games: ", total_season_games, "\n")
962
- print("End of summing recent games... \n Total recent_games = ", total_recent_games, "\n total_season_games: ", total_season_games, "\n \n \n")
963
 
964
  if total_recent_games == 0:
965
  return {
@@ -993,11 +993,14 @@ def calculate_champion_loyalty(df):
993
  confidence_score += 0.2 if pd.notna(row['most_champ_2']) else 0 # Increased weight for second
994
  confidence_score += sum(0.1 for i in range(1, 4) if pd.notna(row[f'season_champ_{i}']))
995
  confidence_score += sum(0.05 for i in range(4, 8) if pd.notna(row[f'season_champ_{i}']))
996
-
 
997
  recent_games = sum((row[f'W_{i}'] + row[f'L_{i}']) if pd.notna(row[f'most_champ_{i}']) else 0
998
  for i in range(1, 3)) # Only top 2
999
  confidence_score += min(0.1, recent_games / 100)
1000
 
 
 
1001
  return {
1002
  'loyalty_score': round(min(loyalty_score, 1.0), 3),
1003
  'confidence_score': round(min(confidence_score, 1.0), 3),
 
951
 
952
  season_games = [int(x) if isinstance(x, str) and x.isdigit() else 0 for x in season_games]
953
 
954
+ #print(f"recent_games was: {recent_games}, types: {[type(x) for x in recent_games]}")
955
+ #print(f"season_games was: {season_games}, types: {[type(x) for x in season_games]}")
956
 
957
+ #print("\nSumming recent games... \n")
958
  total_recent_games = sum(recent_games)
959
+ #print("total_recent_games: ", total_recent_games, "\n")
960
  total_season_games = sum(season_games)
961
+ #print("total_season_games: ", total_season_games, "\n")
962
+ #print("End of summing recent games... \n Total recent_games = ", total_recent_games, "\n total_season_games: ", total_season_games, "\n \n \n")
963
 
964
  if total_recent_games == 0:
965
  return {
 
993
  confidence_score += 0.2 if pd.notna(row['most_champ_2']) else 0 # Increased weight for second
994
  confidence_score += sum(0.1 for i in range(1, 4) if pd.notna(row[f'season_champ_{i}']))
995
  confidence_score += sum(0.05 for i in range(4, 8) if pd.notna(row[f'season_champ_{i}']))
996
+ print("...END calculate confidence score\n")
997
+
998
  recent_games = sum((row[f'W_{i}'] + row[f'L_{i}']) if pd.notna(row[f'most_champ_{i}']) else 0
999
  for i in range(1, 3)) # Only top 2
1000
  confidence_score += min(0.1, recent_games / 100)
1001
 
1002
+ print(f"loyalty_score, confidence score: [{loyalty_score}], [{confidence_score}] \n")
1003
+ print("===================== exiting: get_loyalty_scores()===================")
1004
  return {
1005
  'loyalty_score': round(min(loyalty_score, 1.0), 3),
1006
  'confidence_score': round(min(confidence_score, 1.0), 3),