コード例 #1
0
model.add(Dense(20, activation='relu', input_dim=len(elo_data.columns) - 1))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))

model.compile(optimizer='rmsprop',
              loss='binary_crossentropy',
              metrics=['accuracy'])

model.fit(X_train_elo,
          Y_train_elo,
          epochs=10,
          batch_size=50,
          validation_split=0.2,
          verbose=1)
model.test_on_batch(X_test_elo, Y_test_elo, sample_weight=None)
model.evaluate(X_test_elo, Y_test_elo, verbose=1)
pred = model.predict_classes(X_test_elo, verbose=1)

plot_model(model, to_file='model.png', show_shapes=True)

SVG(model_to_dot(model).create(prog='dot', format='svg'))

print(confusion_matrix(Y_test_elo, pred))
print classification_report(Y_test_elo, pred)
print(accuracy_score(Y_test_elo, pred))
fpr_elo, tpr_elo, thresholds_elo = roc_curve(Y_test_elo, pred)

auc = auc(fpr_elo, tpr_elo)

plt.figure(1)
コード例 #2
0
model.add(Dense(100, activation='relu', input_dim=X_data.shape[1]))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))

model.compile(optimizer='sgd',
              loss='binary_crossentropy',
              metrics=['accuracy'])

model.fit(X_train_Perf_based,
          Y_train_Perf_based,
          epochs=100,
          batch_size=20,
          validation_split=0.3,
          verbose=1)

model.test_on_batch(X_test_Perf_based, Y_test_Perf_based, sample_weight=None)

pred_Perf_based = model.predict_classes(X_test_Perf_based, verbose=1)

print(confusion_matrix(Y_test_Perf_based, pred_Perf_based))
print classification_report(Y_test_Perf_based, pred_Perf_based)
print(accuracy_score(Y_test_Perf_based, pred_Perf_based))
fpr_Perf_based, tpr_Perf_based, thresholds_Perf_based = roc_curve(
    Y_test_Perf_based, pred_Perf_based)

auc_keras = auc(fpr_Perf_based, tpr_Perf_based)

plt.figure(1)
plt.plot([0, 1], [0, 1], 'k--')
plt.plot(fpr_Perf_based,
         tpr_Perf_based,