โมเดลจำแนกประเภท

Introduction to Deep Learning in Python

Dan Becker

Data Scientist and contributor to Keras and TensorFlow libraries

การจำแนกประเภท

  • ฟังก์ชัน loss 'categorical_crossentropy'
  • คล้าย log loss: ค่าน้อยกว่าดีกว่า
  • เพิ่ม metrics = ['accuracy'] ในขั้นตอน compile เพื่อดูผลลัพธ์ที่เข้าใจง่าย
  • Output layer มี node แยกสำหรับแต่ละผลลัพธ์ และใช้ activation 'softmax'
Introduction to Deep Learning in Python

ภาพรวมของข้อมูล

ch3_3.009.png

Introduction to Deep Learning in Python

ภาพรวมของข้อมูล

ch3_3.010.png

Introduction to Deep Learning in Python

แปลงข้อมูลเป็น categorical

ch3_3.011.png

Introduction to Deep Learning in Python

การจำแนกประเภท

from tensorflow.keras.utils import to_categorical

data = pd.read_csv('basketball_shot_log.csv')
predictors = data.drop(['shot_result'], axis=1).values
target = to_categorical(data['shot_result'])

model = Sequential()
model.add(Dense(100, activation='relu', input_shape = (n_cols,)))
model.add(Dense(100, activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(2, activation='softmax'))
model.compile(optimizer='adam', loss='categorical_crossentropy',
              metrics=['accuracy'])
model.fit(predictors, target)
Introduction to Deep Learning in Python

การจำแนกประเภท

Epoch 1/10
128069/128069 [==============================] - 4s - loss: 0.7706 - acc: 0.5759
Epoch 2/10
128069/128069 [==============================] - 5s - loss: 0.6656 - acc: 0.6003
Epoch 3/10
128069/128069 [==============================] - 6s - loss: 0.6611 - acc: 0.6094
Epoch 4/10
128069/128069 [==============================] - 7s - loss: 0.6584 - acc: 0.6106
Epoch 5/10
128069/128069 [==============================] - 7s - loss: 0.6561 - acc: 0.6150
Epoch 6/10
128069/128069 [==============================] - 9s - loss: 0.6553 - acc: 0.6158
Epoch 7/10
128069/128069 [==============================] - 9s - loss: 0.6543 - acc: 0.6162
Epoch 8/10
128069/128069 [==============================] - 9s - loss: 0.6538 - acc: 0.6158
Epoch 9/10
128069/128069 [==============================] - 10s - loss: 0.6535 - acc: 0.6157
Epoch 10/10
128069/128069 [==============================] - 10s - loss: 0.6531 - acc: 0.6166
Introduction to Deep Learning in Python

มาฝึกกันเถอะ!

Introduction to Deep Learning in Python

Preparing Video For Download...