SHARE
TWEET

Untitled

a guest Jun 19th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. train_classes =to_categorical(train_labels)
  2. test_classes =to_categorical(test_labels)
  3.  
  4.  
  5. score = {'AUC': 'roc_auc', 'Accuracy': make_scorer(accuracy_score)}
  6. with tf.device('/device:GPU:0'):
  7.  
  8.     grid =  GridSearchCV(estimator = kerasmodel, param_grid = p, cv = 4, scoring= score,refit = 'AUC',verbose = 5)
  9.  
  10.     grid_result = (grid.fit(train_data, train_classes,shuffle = 'true'))
  11.  
  12.     print("Best: %f using %s" % (grid_result.best_score_,
  13.     grid_result.best_params_))
  14.  
  15.     bestmodel = grid.best_estimator_
  16.  
  17.     preds = model.predict_proba(test_data)
  18.     auc = roc_auc_score(test_classes, preds)
  19.     acc = accuracy_score(test_classes[:,1], (preds[:,0]<preds[:,1])*1)
  20.  
  21.     preds2 = model.predict(test_data)
  22.     auc2 = roc_auc_score(test_labels,preds2)
  23.      
  24. Dense(10, activation = activation),
  25.     Dense(2, activation ='softmax')
  26.      
  27. model.compile(optimizer=optimizer(lr=lr),
  28.                               loss = loss,
  29.                               metrics = ['accuracy'])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top