Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import numpy as np
  2. import sklearn.linear_model
  3.  
  4.  
  5. def applyLogReg(X, Y, regularization):
  6. logreg = sklearn.linear_model.LogisticRegression(C=1/regularization)
  7. logreg.fit(X, Y)
  8. return logreg
  9.  
  10. def applyNeuralNetwork(X, Y, regularization, numberOfHiddenUnits):
  11. clf = MLPClassifier(solver='lbfgs', alpha=regularization, hidden_layer_sizes=(numberOfHiddenUnits), random_state=1)
  12. clf.fit(X, Y)
  13. return clf
  14.  
  15. def getAcuracy(model, X, response):
  16. predicted = model.predict(X)
  17. correct = 0
  18. for index in range(len(predicted)):
  19. if predicted[index] == response[index]:
  20. correct+=1
  21.  
  22. return correct/float(len(predicted)) * 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement