Laboratorio 9
Laboratorio 9
Laboratorio 9
Laboratorio 9
Este es un proyecto de clasificación binaria que tiene como objetivo predecir si la carrera de un
jugador de la NBA durará más de 5 años o no. Los datos incluyen las métricas de rendimiento de
los jugadores de la NBA en su carrera, mediante las cuales se deben hacer las predicciones.
Información de atributos
Name :Nombre
GP :Juegos jugados
MIN :Minutos jugados
PTS :Puntos por partido
FGM :Objetivos de campo realizados
FGA :Objetivos de campo intentados
FG% :Porcentaje de gol de campo
3P Mode :3 puntos hechos
3PA :Intentos de 3 puntos
3P% :3 puntos por ciento
FTM :Tiro libre hecho
FTA :Intentos de lanzamiento libre
FT% :Porcentaje de lanzamiento libre
OREB :Rebotes ofensivos
DREB :Rebotes defensivos
REB :Rebotes
AST :Asistencias
STL :Roba
BLK :Bloques
TOV :Pérdidas de balón
TARGET_5Yrs :Variable predictora (1-Si la duración de la carrera>= 5 años) y (0-si<5)
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1329 entries, 0 to 1328
Data columns (total 21 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Name 1329 non-null object
1 GP 1329 non-null int64
2 MIN 1329 non-null float64
3 PTS 1329 non-null float64
4 FGM 1329 non-null float64
5 FGA 1329 non-null float64
6 FG% 1329 non-null float64
7 3P Made 1329 non-null float64
8 3PA 1329 non-null float64
9 3P% 1329 non-null float64
10 FTM 1329 non-null float64
11 FTA 1329 non-null float64
12 FT% 1329 non-null float64
13 OREB 1329 non-null float64
14 DREB 1329 non-null float64
15 REB 1329 non-null float64
16 AST 1329 non-null float64
17 STL 1329 non-null float64
18 BLK 1329 non-null float64
19 TOV 1329 non-null float64
20 TARGET_5Yrs 1329 non-null int64
dtypes: float64(18), int64(2), object(1)
memory usage: 218.2+ KB
Actividad
In [10]: 1 sc = StandardScaler()
In [14]: 1 df_cont=pd.DataFrame(X_train_std,
2 columns=['GP','MIN','PTS','FGM','FGA','FG%','3P Made','
3 ,'DREB','REB','AST','STL','BLK','TOV'])
4 df_cont.head()
Out[14]:
GP MIN PTS FGM FGA FG% 3P Made 3PA 3P%
Grafico PCA
Out[16]:
GM FGA FG% 3P Made 3PA 3P% FTM FTA FT% OREB
Eigenvalues
[9.62886703e+00 3.88752049e+00 1.14785067e+00 8.82468378e-01
7.41793351e-01 5.71211935e-01 5.04693504e-01 4.58072858e-01
4.23206166e-01 2.50445431e-01 2.36815437e-01 1.01482688e-01
1.05137644e-01 5.33749414e-02 1.43320136e-02 7.94217812e-03
4.71724574e-03 3.49739946e-04 1.70394948e-04]
In [23]: 1 np.cumsum(pca.explained_variance_ratio_)[5]
Out[23]: 0.886399112348117
Out[28]:
PC1 PC2 PC3
Out[30]:
ARGET_5Yrs
0 0
1 0
2 1
3 0
4 1
Out[31]:
PC1 PC2 PC3 ARGET_5Yrs