Example - Vector Recommendations With NBA Players

With the growth of the NBA quickly introducing new way to calculate statistics that are human-calculated, it doesn’t make much sense to keep this using traditional human-orientated approaches and judgements based on players.

Here, we want to be able to identify players that have similar statistics to other players without having to look at each statistic line by line. We want to just know.

Below, we investigate the different players and their most similar counterparts as well as examine the efficiencies between the different players.

[7]:
nba_per_36 = pd.read_excel('data/nba_per_36.xlsx', skiprows=[0])
nba_per_game = pd.read_excel('data/nba_per_game.xlsx')
[9]:
nba_per_game.sample(2)
[9]:
FULL NAME TEAM POS AGE GP MPG MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions FTA FT% 2PA 2P% 3PA 3P% eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws. PPGPointsPoints per game. RPGReboundsRebounds per game. TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court. APGAssistsAssists per game. AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court SPGStealsSteals per game. BPGBlocksBlocks per game. TOPGTurnoversTurnovers per game. VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10 ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions. DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.
151 Angel Delgado Lac C 24.39 2 7.4 15.4 16.8 0.0 2 0.500 5 0.200 0 0.000 0.200 0.255 1.5 2.0 14.3 0.0 0.0 0.50 0.00 0.00 0.0 79.2 98.9
587 John Wall Was G 28.60 32 34.5 71.9 28.8 16.3 175 0.697 382 0.508 169 0.302 0.491 0.528 20.7 3.6 5.7 8.7 39.2 1.53 0.91 3.81 10.0 104.1 111.5
[2]:
from vectorai import ViClient
vi_client = ViClient(username, api_key, url)
Logged in. Welcome jacky-wong. To view list of available collections, call list_collections() method.
[16]:
from sklearn.preprocessing import StandardScaler

def create_collection(df, collection_name):
    df = df.fillna(0)
    scaler = StandardScaler()
    season_vector = scaler.fit_transform(df.drop(['FULL NAME', 'TEAM', 'POS', 'AGE', 'MPG'], axis=1))
    df['season_vector_'] = season_vector.tolist()
    if collection_name in vi_client.list_collections():
        vi_client.delete_collection(collection_name)
    return vi_client.insert_df(collection_name, df, chunksize=100)

create_collection(nba_per_game, 'nba_season_per_game_stats_demo')

[16]:
{'inserted_successfully': 622, 'failed': 0, 'failed_document_ids': []}
[17]:
create_collection(nba_per_36, 'nba_season_per_36_stats_demo')

[17]:
{'inserted_successfully': 212, 'failed': 0, 'failed_document_ids': []}

Visualising NBA players

[19]:
job = vi_client.dimensionality_reduction_job('nba_season_per_game_stats_demo', vector_field='season_vector_', n_components=2)
job = vi_client.dimensionality_reduction_job('nba_season_per_36_stats_demo', vector_field='season_vector_', n_components=2)
vi_client.wait_till_jobs_complete('nba_season_per_36_stats_demo', **job)
{'status': 'Finished'}
[19]:
'Done'
[5]:
# rename cluster_field to vector_field
fig = vi_client.plot_dimensionality_reduced_vectors(
    collection='nba_season_per_game_stats_demo', point_label='FULL NAME', cluster_field='season_vector_', cluster_label='POS',
    dim_reduction_field='_dr_.default.2.season_vector_')
fig.update_layout(
    title="NBA Players Stats Per Gmae",
    title_font_color="Black"
);
fig.show()

[6]:
fig = vi_client.plot_dimensionality_reduced_vectors(
    collection='nba_season_per_36_stats_demo', point_label='FULL NAME', cluster_field='season_vector_', cluster_label='POS',
    dim_reduction_field='_dr_.default.2.season_vector_')
fig.update_layout(
    title="NBA Players for 36 minutes",
    title_font_color="Black"
);
fig.show()

Interesting how much of an outlier Kawhi Leonard is when the stats are per 36 minutes (an important normalisation method to ensure consistent comparison across players).

[7]:
import numpy as np
def get_similar_players(collection_name, player_name, position=None, num_results=10):
    player_filter = [{
        'field': "FULL NAME",
        "filter_type": "text",
        "condition_value": player_name,
        "condition": "=="
    }]
    player_id = vi_client.filters(collection_name, filters=player_filter)[0]['_id']
    if position is None:
      results = vi_client.search_by_id(collection_name=collection_name,
      document_id=player_id,
      field='season_vector_',
      page_size=num_results,
      metric='l2'
      )
      for result in results['results']:
          print(f"{result['FULL NAME']} : {round(result['_search_score'], 2)}")
      return
    position_filter = [{
        'field': "POS",
        "filter_type": "text",
        "condition_value": position,
        "condition": "=="
    }]
    results = vi_client.advanced_search_by_id(collection_name, player_id, filters=position_filter, fields={'season_vector_': 1})
    for result in results['results']:
      print(f"{result['FULL NAME']} : {round(result['_search_score'], 2)}")
get_similar_players("nba_season_per_game_stats_demo", "Russell Westbrook")
Russell Westbrook : 1.0
LeBron James : 0.22
Nikola Jokic : 0.2
Luka Doncic : 0.17
Ben Simmons : 0.16
Jrue Holiday : 0.16
Trae Young : 0.16
Kyrie Irving : 0.15
Devin Booker : 0.15
De'Aaron Fox : 0.15
[8]:
get_similar_players("nba_season_per_game_stats_demo", "LeBron James")
LeBron James : 1.0
Nikola Jokic : 0.26
Luka Doncic : 0.26
Jrue Holiday : 0.23
Kyrie Irving : 0.23
Devin Booker : 0.23
Blake Griffin : 0.22
Russell Westbrook : 0.22
Kevin Durant : 0.21
Trae Young : 0.2
[9]:
get_similar_players("nba_season_per_game_stats_demo", "Stephen Curry")
Stephen Curry : 1.0
Kemba Walker : 0.26
Damian Lillard : 0.24
Bradley Beal : 0.24
Kyrie Irving : 0.23
Khris Middleton : 0.22
Donovan Mitchell : 0.22
D'Angelo Russell : 0.22
Buddy Hield : 0.21
Paul George : 0.21

I had no idea Kemba Walker was so similar to Stephen Curry. A simple comparison of the baseline stats shows this to be the case. (No disrespect - I simply don’t follow him!)

[11]:
get_similar_players("nba_season_per_game_stats_demo", "Rajon Rondo")
Rajon Rondo : 1.0
Elfrid Payton : 0.44
Kris Dunn : 0.29
Jeff Teague : 0.28
Lonzo Ball : 0.27
Ricky Rubio : 0.24
Dennis Smith Jr. : 0.23
Kyle Lowry : 0.23
Draymond Green : 0.23
Dennis Smith Jr. : 0.23

Interesting! Let us look at recommended players but only within the Guard position.

[12]:
get_similar_players("nba_season_per_game_stats_demo", "Russell Westbrook", "G")
Russell Westbrook : 1.0
Luka Doncic : 0.94
Jrue Holiday : 0.93
De'Aaron Fox : 0.91
Kyrie Irving : 0.91
Ben Simmons : 0.9
Eric Bledsoe : 0.9
Trae Young : 0.9
Ricky Rubio : 0.89
Dwyane Wade : 0.89
[13]:
get_similar_players("nba_season_per_game_stats_demo", "LeBron James", "F")
LeBron James : 1.0
Luka Doncic : 0.95
Blake Griffin : 0.92
Kevin Durant : 0.91
Giannis Antetokounmpo : 0.9
Ben Simmons : 0.88
Justise Winslow : 0.87
Khris Middleton : 0.86
Julius Randle : 0.85
Kawhi Leonard : 0.84
[14]:
get_similar_players("nba_season_per_game_stats_demo", "Dwayne Wade", "G")
Dwayne Bacon : 1.0
Cameron Reynolds : 0.88
Damion Lee : 0.86
Ryan Broekhoff : 0.84
Landry Shamet : 0.83
John Jenkins : 0.82
Jodie Meeks : 0.82
Troy Daniels : 0.81
Tony Snell : 0.81
Scott Machado : 0.8
[15]:
get_similar_players("nba_season_per_game_stats_demo", "Dwayne Wade", "G")
Dwayne Bacon : 1.0
Cameron Reynolds : 0.88
Damion Lee : 0.86
Ryan Broekhoff : 0.84
Landry Shamet : 0.83
John Jenkins : 0.82
Jodie Meeks : 0.82
Troy Daniels : 0.81
Tony Snell : 0.81
Scott Machado : 0.8
[24]:
def sum_players(collection_name, positive_players=[], negative_players=[]):
    """Complex search to sum up the NBA players to get the closest when you sum up various players.
    """
    pos_player_ids = {}
    neg_player_ids = {}

    for player in positive_players:
        player_filter = [{
            'field': "FULL NAME",
            "filter_type": "text",
            "condition_value": player,
            "condition": "=="
        }]
        player_id = vi_client.filters(collection_name, filters=player_filter)[0]['_id']
        pos_player_ids[player_id] = 1
        for player in negative_players:
            player_id = vi_client.filters(collection_name, filters=player_filter)[0]['_id']
            neg_player_ids[player_id] = 1

    results =  vi_client.advanced_search_by_ids(collection_name, document_ids=pos_player_ids,
    fields={'season_vector_':1})
    print(results)
    for result in results['results']:
        print(result['FULL NAME'])
[25]:
# What is the closest you get when you add Ben Simmons and Kawhi Leonard?
sum_players("nba_season_per_game_stats_demo", ['Ben Simmons', 'Russell Westbrook'])
{'results': [{'_id': 'SoMQgXQBv-xqKfY1Sm_P', 'MPG': 36.0, 'RPGReboundsRebounds per game.': 11.1, 'TOPGTurnoversTurnovers per game.': 4.44, '2P%': 0.481, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 15.5, '3P%': 0.29, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.501, 'FT%': 0.658, 'FULL NAME': 'Russell Westbrook', 'APGAssistsAssists per game.': 10.7, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 30.9, 'AGE': 30.41, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 15.9, '2PA': 1062, '3PA': 411, 'SPGStealsSteals per game.': 1.95, 'BPGBlocksBlocks per game.': 0.45, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.468, 'GP': 73, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 97.2, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 105.2, 'FTA': 450, 'POS': 'G', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 75.0, 'TEAM': 'Okc', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 16.2, 'PPGPointsPoints per game.': 22.9, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 46.5, '_dr_': {'default': {'2': {}}}, '_search_score': 0.9824028}, {'_id': 'B4MQgXQBv-xqKfY1Sm_P', 'MPG': 34.2, 'RPGReboundsRebounds per game.': 8.8, 'TOPGTurnoversTurnovers per game.': 3.47, '2P%': 0.566, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 12.2, '3P%': 0.0, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.582, 'FT%': 0.6, 'FULL NAME': 'Ben Simmons', 'APGAssistsAssists per game.': 7.7, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 22.1, 'AGE': 22.72, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 13.7, '2PA': 954, '3PA': 6, 'SPGStealsSteals per game.': 1.42, 'BPGBlocksBlocks per game.': 0.77, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.563, 'GP': 79, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 103.1, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 113.8, 'FTA': 428, 'POS': 'G-F', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 71.2, 'TEAM': 'Phi', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 19.3, 'PPGPointsPoints per game.': 16.9, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 34.2, '_dr_': {'default': {'2': {}}}, '_search_score': 0.9676176000000001}, {'_id': 'UUIQgXQB6ETDC656R8wp', 'MPG': 31.3, 'RPGReboundsRebounds per game.': 10.8, 'TOPGTurnoversTurnovers per game.': 3.1, '2P%': 0.569, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 14.9, '3P%': 0.307, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.589, 'FT%': 0.821, 'FULL NAME': 'Nikola Jokic', 'APGAssistsAssists per game.': 7.3, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 27.4, 'AGE': 24.14, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 18.7, '2PA': 936, '3PA': 270, 'SPGStealsSteals per game.': 1.35, 'BPGBlocksBlocks per game.': 0.69, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.545, 'GP': 80, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 99.0, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 119.2, 'FTA': 352, 'POS': 'C', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 65.2, 'TEAM': 'Den', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 15.4, 'PPGPointsPoints per game.': 20.1, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 37.1, '_dr_': {'default': {'2': {}}}, '_search_score': 0.96315}, {'_id': 'QUIQgXQB6ETDC656Rcw0', 'MPG': 35.2, 'RPGReboundsRebounds per game.': 8.4, 'TOPGTurnoversTurnovers per game.': 3.58, '2P%': 0.582, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 14.1, '3P%': 0.339, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.588, 'FT%': 0.665, 'FULL NAME': 'LeBron James', 'APGAssistsAssists per game.': 8.3, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 31.6, 'AGE': 34.28, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 12.3, '2PA': 768, '3PA': 327, 'SPGStealsSteals per game.': 1.31, 'BPGBlocksBlocks per game.': 0.6, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.56, 'GP': 55, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 106.2, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 114.4, 'FTA': 418, 'POS': 'F', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 73.4, 'TEAM': 'Lal', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 13.3, 'PPGPointsPoints per game.': 27.4, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 39.4, '_dr_': {'default': {'2': {}}}, '_search_score': 0.9505332}, {'_id': 'IkIQgXQB6ETDC656Rcw0', 'MPG': 35.8, 'RPGReboundsRebounds per game.': 5.0, 'TOPGTurnoversTurnovers per game.': 3.16, '2P%': 0.539, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 10.4, '3P%': 0.325, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.555, 'FT%': 0.768, 'FULL NAME': 'Jrue Holiday', 'APGAssistsAssists per game.': 7.7, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 25.5, 'AGE': 28.83, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 7.2, '2PA': 796, '3PA': 363, 'SPGStealsSteals per game.': 1.64, 'BPGBlocksBlocks per game.': 0.81, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.523, 'GP': 67, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 110.1, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 110.9, 'FTA': 271, 'POS': 'G', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 74.7, 'TEAM': 'Nor', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 14.2, 'PPGPointsPoints per game.': 21.2, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 31.8, '_dr_': {'default': {'2': {}}}, '_search_score': 0.9209309000000001}, {'_id': 'hoMQgXQBv-xqKfY1Q26G', 'MPG': 31.4, 'RPGReboundsRebounds per game.': 3.8, 'TOPGTurnoversTurnovers per game.': 2.8, '2P%': 0.482, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 10.0, '3P%': 0.371, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.544, 'FT%': 0.727, 'FULL NAME': "De'Aaron Fox", 'APGAssistsAssists per game.': 7.3, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 24.5, 'AGE': 21.31, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 6.2, '2PA': 870, '3PA': 232, 'SPGStealsSteals per game.': 1.64, 'BPGBlocksBlocks per game.': 0.56, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.497, 'GP': 81, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 107.1, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 109.9, 'FTA': 417, 'POS': 'G', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 65.5, 'TEAM': 'Sac', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 15.0, 'PPGPointsPoints per game.': 17.3, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 33.2, '_dr_': {'default': {'2': {}}}, '_search_score': 0.9166042999999999}, {'_id': 'Y4MQgXQBv-xqKfY1Q26G', 'MPG': 32.2, 'RPGReboundsRebounds per game.': 7.8, 'TOPGTurnoversTurnovers per game.': 3.42, '2P%': 0.503, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 12.4, '3P%': 0.326, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.545, 'FT%': 0.713, 'FULL NAME': 'Luka Doncic', 'APGAssistsAssists per game.': 6.0, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 30.5, 'AGE': 20.12, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 13.0, '2PA': 672, '3PA': 515, 'SPGStealsSteals per game.': 1.08, 'BPGBlocksBlocks per game.': 0.35, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.497, 'GP': 72, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 105.1, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 106.9, 'FTA': 485, 'POS': 'G-F', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 67.1, 'TEAM': 'Dal', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 14.9, 'PPGPointsPoints per game.': 21.2, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 31.6, '_dr_': {'default': {'2': {}}}, '_search_score': 0.9088172000000001}, {'_id': 'XIMQgXQBv-xqKfY1Q26G', 'MPG': 34.9, 'RPGReboundsRebounds per game.': 6.0, 'TOPGTurnoversTurnovers per game.': 2.57, '2P%': 0.492, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 10.6, '3P%': 0.156, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.542, 'FT%': 0.831, 'FULL NAME': 'DeMar DeRozan', 'APGAssistsAssists per game.': 6.2, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 27.9, 'AGE': 29.68, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 9.4, '2PA': 1268, '3PA': 45, 'SPGStealsSteals per game.': 1.12, 'BPGBlocksBlocks per game.': 0.47, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.483, 'GP': 77, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 106.4, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 110.0, 'FTA': 439, 'POS': 'G', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 72.7, 'TEAM': 'San', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 11.6, 'PPGPointsPoints per game.': 21.2, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 27.6, '_dr_': {'default': {'2': {}}}, '_search_score': 0.8976381}, {'_id': '04MQgXQBv-xqKfY1QW1E', 'MPG': 32.8, 'RPGReboundsRebounds per game.': 12.5, 'TOPGTurnoversTurnovers per game.': 3.71, '2P%': 0.64, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 15.5, '3P%': 0.256, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.643, 'FT%': 0.729, 'FULL NAME': 'Giannis Antetokounmpo', 'APGAssistsAssists per game.': 5.9, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 32.3, 'AGE': 24.35, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 19.4, '2PA': 1045, '3PA': 203, 'SPGStealsSteals per game.': 1.26, 'BPGBlocksBlocks per game.': 1.53, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.599, 'GP': 72, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 93.9, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 121.6, 'FTA': 686, 'POS': 'F', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 68.2, 'TEAM': 'Mil', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 14.7, 'PPGPointsPoints per game.': 27.7, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 30.3, '_dr_': {'default': {'2': {}}}, '_search_score': 0.8937579}, {'_id': 'WIMQgXQBv-xqKfY1TG9h', 'MPG': 29.7, 'RPGReboundsRebounds per game.': 5.4, 'TOPGTurnoversTurnovers per game.': 2.15, '2P%': 0.462, 'VIVersatility IndexVersatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10': 8.9, '3P%': 0.375, 'TS%True Shooting PercentageTrue shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws.': 0.513, 'FT%': 0.628, 'FULL NAME': 'Justise Winslow', 'APGAssistsAssists per game.': 4.3, 'USG%Usage RateUsage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor': 20.8, 'AGE': 23.04, 'TRB%Total Rebound PercentageTotal rebound percentage is estimated percentage of available rebounds grabbed by the player while the player is on the court.': 9.6, '2PA': 493, '3PA': 256, 'SPGStealsSteals per game.': 1.09, 'BPGBlocksBlocks per game.': 0.29, 'eFG%Effective Shooting PercentageWith eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA': 0.497, 'GP': 66, 'DRTGDefensive RatingIndividual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.': 101.5, 'ORTGOffensive RatingIndividual offensive rating is the number of points produced by a player per 100 total individual possessions.': 102.6, 'FTA': 137, 'POS': 'F', 'MIN%Minutes PercentagePercentage of team minutes used by a player while he was on the floor': 61.9, 'TEAM': 'Mia', 'Tor%Turnover RateA metric that estimates the number of turnovers a player commits per 100 possessions': 14.9, 'PPGPointsPoints per game.': 12.6, 'AST%Assist PercentageAssist percentage is an estimated percentage of teammate field goals a player assisted while the player is on the court': 21.9, '_dr_': {'default': {'2': {}}}, '_search_score': 0.8891511000000001}], 'count': 622}
Russell Westbrook
Ben Simmons
Nikola Jokic
LeBron James
Jrue Holiday
De'Aaron Fox
Luka Doncic
DeMar DeRozan
Giannis Antetokounmpo
Justise Winslow
[35]:
anchor_doc = documents.pop(6)
[3]:
import random
documents = vi_client.random_documents("nba_season_per_game_stats_demo", seed=random.randint(0, 100))['documents']
vi_client.plot_1d_cosine_similarity(documents, vector_fields='season_vector_', label='FULL NAME')
[4]:
vi_client.plot_2d_cosine_similarity(documents, documents[:2], 'season_vector_', 'FULL NAME')