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

kermitting soon

Browse files
Files changed (3) hide show
  1. util/app.py +2 -2
  2. util/app_training_df_getter.py +3 -3
  3. util/helper.py +5 -5
util/app.py CHANGED
@@ -134,10 +134,10 @@ def predict_champion(player_opgg_url, *champions):
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)
140
- print("check_datatypes(training_df) :", check_datatypes(training_df), "\n")
141
 
142
  # Get feature columns
143
  feature_columns = [col for col in training_df.columns
 
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. :\n", check_datatypes(training_df), "\n")
138
 
139
  training_df = apply_feature_engineering(training_df)
140
+ print("check_datatypes(training_df) AFTER feature eng. \n:", check_datatypes(training_df), "\n")
141
 
142
  # Get feature columns
143
  feature_columns = [col for col in training_df.columns
util/app_training_df_getter.py CHANGED
@@ -378,7 +378,7 @@ def create_app_user_training_df(url):
378
  if recent_stats is None or recent_stats.empty:
379
  raise ValueError("recent_stats is empty. type(recent_stats): ", type(recent_stats) , " recent_stats: \n", recent_stats)
380
 
381
- print("Recent matches columns:", recent_stats.columns.tolist())
382
 
383
  # Check if player_id exists before trying to process it
384
  #if 'player_id' not in recent_stats.columns:
@@ -386,7 +386,7 @@ def create_app_user_training_df(url):
386
 
387
  # Process player_id
388
  recent_stats['player_id'] = recent_stats['player_id'].str.replace(" #", "-", regex=False)
389
- print("Processed player_ids:", recent_stats['player_id'].head())
390
 
391
  # Get player stats
392
  print("Fetching player stats...")
@@ -406,7 +406,7 @@ def create_app_user_training_df(url):
406
  if merged_stats is None or merged_stats.empty:
407
  raise ValueError("Failed to merge stats")
408
 
409
- print("Merged stats columns:", merged_stats.columns.tolist())
410
 
411
  # Create features
412
  print("Creating champion features...")
 
378
  if recent_stats is None or recent_stats.empty:
379
  raise ValueError("recent_stats is empty. type(recent_stats): ", type(recent_stats) , " recent_stats: \n", recent_stats)
380
 
381
+ #print("Recent matches columns:", recent_stats.columns.tolist())
382
 
383
  # Check if player_id exists before trying to process it
384
  #if 'player_id' not in recent_stats.columns:
 
386
 
387
  # Process player_id
388
  recent_stats['player_id'] = recent_stats['player_id'].str.replace(" #", "-", regex=False)
389
+ #print("Processed player_ids:", recent_stats['player_id'].head())
390
 
391
  # Get player stats
392
  print("Fetching player stats...")
 
406
  if merged_stats is None or merged_stats.empty:
407
  raise ValueError("Failed to merge stats")
408
 
409
+ #print("Merged stats columns:", merged_stats.columns.tolist())
410
 
411
  # Create features
412
  print("Creating champion features...")
util/helper.py CHANGED
@@ -902,7 +902,7 @@ def calculate_role_specialization(df):
902
 
903
  def calculate_champion_loyalty(df):
904
  df = df.copy()
905
- print("df.dtypes: \n", df.dtypes, "\n")
906
 
907
 
908
  def get_loyalty_scores(row):
@@ -986,21 +986,21 @@ def calculate_champion_loyalty(df):
986
 
987
  loyalty_score += combined_weight
988
 
989
- print("Start calculate confidence score...\n")
990
  # Calculate confidence score (adjusted for 2 champions)
991
  confidence_score = 0
992
  confidence_score += 0.5 if pd.notna(row['most_champ_1']) else 0 # Increased weight for main
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),
 
902
 
903
  def calculate_champion_loyalty(df):
904
  df = df.copy()
905
+ #print("df.dtypes: \n", df.dtypes, "\n")
906
 
907
 
908
  def get_loyalty_scores(row):
 
986
 
987
  loyalty_score += combined_weight
988
 
989
+ #print("Start calculate confidence score...\n")
990
  # Calculate confidence score (adjusted for 2 champions)
991
  confidence_score = 0
992
  confidence_score += 0.5 if pd.notna(row['most_champ_1']) else 0 # Increased weight for main
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),