Jimin Park commited on
Commit
14d8730
·
1 Parent(s): 3f8a0dc

added new structure

Browse files
Files changed (1) hide show
  1. util/app.py +19 -10
util/app.py CHANGED
@@ -122,22 +122,31 @@ def show_stats(player_opgg_url):
122
  )
123
 
124
  # Extract additional stats
125
- #playstyle = training_features['playstyle'].mode()[0] # Most common playstyle
126
  role_specialization = training_features['role_specialization'].mode()[0] # Most common role
127
  champion_loyalty_score = training_features['champion_loyalty_score'].mean().round(2) # Average loyalty
128
 
129
- # Updated HTML display
 
 
 
 
 
 
 
 
 
 
 
130
  stats_html = f"""
131
  <div style='padding: 20px; background: #f5f5f5; border-radius: 10px;'>
132
  <h3>Player's Recent Stats</h3>
133
- <p><strong>Wins:</strong> {wins} | <strong>Losses:</strong> {losses}</p>
134
- <p><strong>Winrate:</strong> {winrate}</p>
135
- <p><strong>Favorite Champions:</strong> {', '.join(map(str, favorite_champions))}</p>
136
- <hr>
137
- <h4>Additional Insights</h4>
138
- <p><strong>Playstyle:</strong> {playstyle}</p>
139
- <p><strong>Role Specialization:</strong> {role_specialization}</p>
140
- <p><strong>Champion Loyalty Score:</strong> {champion_loyalty_score}</p>
141
  </div>
142
  """
143
 
 
122
  )
123
 
124
  # Extract additional stats
125
+ playstyle = training_features['playstyle'].mode()[0] if 'playstyle' in training_features else 'N/A'
126
  role_specialization = training_features['role_specialization'].mode()[0] # Most common role
127
  champion_loyalty_score = training_features['champion_loyalty_score'].mean().round(2) # Average loyalty
128
 
129
+ # Map numeric playstyle to descriptive text
130
+ playstyle_mapping = {
131
+ 0: "Assassin/Carry",
132
+ 1: "Support/Utility",
133
+ 2: "Tank/Initiator",
134
+ 3: "Split-pusher",
135
+ 4: "Aggressive/Fighter",
136
+ 5: "Undefined"
137
+ }
138
+ playstyle_text = playstyle_mapping.get(playstyle, "Undefined")
139
+
140
+ # Format HTML output
141
  stats_html = f"""
142
  <div style='padding: 20px; background: #f5f5f5; border-radius: 10px;'>
143
  <h3>Player's Recent Stats</h3>
144
+ <p>Wins: {wins} | Losses: {losses}</p>
145
+ <p>Winrate: {winrate}</p>
146
+ <p>Favorite Champions: {', '.join(favorite_champions)}</p>
147
+ <p>Playstyle: {playstyle_text}</p>
148
+ <p>Role Specialization: {role_specialization}</p>
149
+ <p>Champion Loyalty Score: {champion_loyalty_score:.2f}</p>
 
 
150
  </div>
151
  """
152