Natrénování a vyhodnocení modelu

Advanced Deep Learning with Keras

Zach Deane-Mayer

Data Scientist

Basketbalová data

Cíl: Předpovědět výsledky turnaje

Dostupná data: hodnocení týmů od organizátorů turnaje

import pandas as pd
games_tourney = pd.read_csv('datasets/games_tourney.csv')
games_tourney.head()

Out[1]:
   season  team_1  team_2  home  seed_diff  score_diff  score_1  score_2  won
0    1985     288      73     0         -3          -9       41       50    0
1    1985    5929      73     0          4           6       61       55    1
2    1985    9884      73     0          5          -4       59       63    0
3    1985      73     288     0          3           9       50       41    1
4    1985    3920     410     0          1          -9       54       63    0
Advanced Deep Learning with Keras

Basketbalová data

Vstup: Rozdíl nasazení

import pandas as pd
games_tourney = pd.read_csv('datasets/games_tourney.csv')
games_tourney.head()

Advanced Deep Learning with Keras

Basketbalová data

Výstup: Rozdíl skóre

import pandas as pd
games_tourney = pd.read_csv('datasets/games_tourney.csv')
games_tourney.head()

Advanced Deep Learning with Keras

Basketbalová data

Vstup:

  • Rozdíl nasazení – jedno číslo: -15 až +15
  • Nasazení v rozsahu 1–16
  • Nejvyšší rozdíl: 16-1 = +15
  • Nejnižší rozdíl: 1-16 = -15

Výstup:

  • Rozdíl skóre – jedno číslo: -50 až +50
Advanced Deep Learning with Keras

Basketbalová data

  • Rozdíl nasazení: 15
    • Tým 1: 16
    • Tým 2: 1
  • Rozdíl nasazení: -15
    • Tým 1: 1
    • Tým 2: 16

Advanced Deep Learning with Keras

Basketbalová data

  • Rozdíl skóre: -9
    • Tým 1: 41
    • Tým 2: 50
  • Rozdíl skóre: 6
    • Tým 1: 61
    • Tým 2: 55

Advanced Deep Learning with Keras

Basketbalová data

import pandas as pd
games_tourney = pd.read_csv('datasets/games_tourney_samp.csv')
games_tourney.head()

Out[1]:
   season  team_1  team_2  home  seed_diff  score_diff  score_1  score_2  won
0    2017     320    6323     0         13          18      100       82    1
1    2017    6323     320     0        -13         -18       82      100    0
Advanced Deep Learning with Keras

Sestavení modelu

from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Dense
input_tensor = Input(shape=(1,))
output_tensor = Dense(1)(input_tensor)
model = Model(input_tensor, output_tensor)
model.compile(optimizer='adam', loss='mae')

Advanced Deep Learning with Keras

Trénování modelu

from pandas import read_csv
games = read_csv('datasets/games_tourney.csv')
model.fit(games['seed_diff'],
          games['score_diff'],
          batch_size=64,
          validation_split=.20,
          verbose=True)

Advanced Deep Learning with Keras

Vyhodnocení modelu

model.evaluate(games_test['seed_diff'],
               games_test['score_diff'])

1000/1000 [==============================] - 0s 26us/step
Out[1]: 9.145421981811523
Advanced Deep Learning with Keras

Pojďme si procvičit!

Advanced Deep Learning with Keras

Preparing Video For Download...