<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 KNN exercise with NBA player data
Introduction
NBA player statistics from 2014-2015 (partial season)
Step1:  Step 2
Step2:  Step 3
Step3:  Step 4
Step4:  Step 5
Step5:  Bonus
<ASSISTANT_TASK:>
Python Code:
# read the data into a DataFrame
import pandas as pd
url = 'https://raw.githubusercontent.com/kjones8812/DAT4-students/master/kerry/Final/NBA_players_2015.csv'
nba = pd.read_csv(url, index_col=0)
nba.head()
# examine the columns
# examine the positions
Explanation: KNN exercise with NBA player data
Introduction
NBA player statistics from 2014-2015 (partial season): data, data dictionary
Goal: Predict player position using assists, steals, blocks, turnovers, and personal fouls
Step 1: Read the data into Pandas
End of explanation
# map positions to numbers
# create feature matrix (X) (use fields: 'ast', 'stl', 'blk', 'tov', 'pf')
# create response vector (y)
Explanation: Step 2: Create X and y
Use the following features: assists, steals, blocks, turnovers, personal fouls
End of explanation
# import class
# instantiate with K=5
# fit with data
Explanation: Step 3: Train a KNN model (K=5)
End of explanation
# create a list to represent a player
# make a prediction
# calculate predicted probabilities
Explanation: Step 4: Predict player position and calculate predicted probability of each position
Predict for a player with these statistics: 1 assist, 1 steal, 0 blocks, 1 turnover, 2 personal fouls
End of explanation
# repeat for K=50
# calculate predicted probabilities
Explanation: Step 5: Repeat steps 3 and 4 using K=50
End of explanation
# allow plots to appear in the notebook
%matplotlib inline
import matplotlib.pyplot as plt
# increase default figure and font sizes for easier viewing
plt.rcParams['figure.figsize'] = (6, 4)
plt.rcParams['font.size'] = 14
Explanation: Bonus: Explore the features to decide which ones are predictive
End of explanation
<END_TASK>