Skip to content

xinranhe/Dota2

Repository files navigation

Learning Embedding of Dota2 Heroes and Items

Methodology

  • Data collection:

    • Use dota2py wrapper of Steam Web API
    • Use get_match_history_by_sequence_num to obtain all matches following a sequence number
    • Use DotaMax to obtain match skill level
    • Check whether the math is stored or parsed by yasp. Grab the yasp data if yes.
    • In this experiment, use only All Pick games of all skill levels and at least 25 minutes.
    • In total ~80K matches
    • Run python crawler.py <start_seqnum> <end_seqnum> to crawl data
      • Current crawl to sequence number: 1663750000 on lille
  • Learn low-dimension embedding of Dota2 heroes via skip-n gram model.

  • Learn low-dimension embedding of Dota2 items via skip-n gram model.

    • Treat all items possessed by same player as a sentence
    • Treat each item as a word
    • We learn item embedding only from winning team
    • Use uniformly sampled heroes as negative instances
  • visualization:

    • Use different methods in sklearn to project the embedding into 2D
      • TSNE
      • Isomap
      • MDS
      • Spectral
      • PCA

Usage

  1. All data are stored in Mongodb in lille.

  2. Run following script to learn embedding

     python learn_embedding.py [hero/item] [match filter dict]
    

    Example: use all matches with mode all pick or ranked all picked lasting at least 25 minutes

     python learn_embedding.py item "{'\$or': [{'game_mode': 1}, {'game_mode': 22}], 'duration': {'\$gt': 1500}}"
    
  3. Run script to generate visualization webpage Visualize hero embedding:

     python draw_hero_embedding.py embed_weight_hero.pkl mds,tsne,isomap,spectral,pca
    

    Visualize item embedding:

     python draw_item_embedding.py embed_weight_item.pkl mds,tsne,isomap,spectral,pca
    

Hero Embedding Result

Visualization of Embedding

We briefly annotated the visualization result by PCA as follows:

Nearest Neighbor

We query the nearest neighbor of a given hero using the learned embedding.

Hero Nearest Heroes
          
          
          
      <img src=result/heroes/nature'sprophet.png style="height:30px; width:30px">    
          
          
          
          
          
          
          
          
          
          
        
          
          
          
          
          
      
          
          
          
          
          
          
          
          
          
          
          
          
  <img src=result/heroes/nature'sprophet.png style="height:30px; width:30px">        
          
          
      
          
          
          
          
          
          
          
          
          
          
          
          
          
          
<img src=result/heroes/nature'sprophet.png style="height:30px; width:30px">           
          
          
          
          
        
          
          
          
          
          
          
        
        
          
          
          
          
          
          
          
          
          
          
          
          
          
        
          
          
          
          
          
          
          
          
          
          
          
        
          
          
          
          
          
          
          
          
          
          
          
    <img src=result/heroes/nature'sprophet.png style="height:30px; width:30px">      
        <img src=result/heroes/nature'sprophet.png style="height:30px; width:30px">  
        
          
      
          
          
          

Item Embedding Result

Visualization of Embedding

Visualization using Isomap

Nearest Neighbor

We query the nearest neighbor of a given item using the learned embedding.

Item Nearest Items
          
        
          
        
          
          
        
        
        
        
          
          
          
      
          
          
      
        
          
          
          
          
          
    
        
    
          
          
        
          
          
          
      
          
          
          
          
          
          
          
          
          
          
          
      
    
      
          
        
    
          
          
          
          
          
      
      
          
          
      
      
          
        
          
          
      
          
          
          
          
          
          
        
          
          
          
      
          
          
          
          
          
        
          
          
        
    
        
          
          
          
          
      
          
          
      
          
          
        
      
    
          
          
      
          
      
        
    
    
          
      
        
          
          
          
          
          
          
          
          
          
      
          
        
          
          
          
          
          
          
        
        
          
          
          
          
          
        
          
          
          
  
          
        
        
          

About

ML project on dota2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published