fork download
  1. # Task 2:
  2.  
  3. def sigmoid(x):
  4. return 1 / (1 + np.e**(-x))
  5. def predict_class(x_data):
  6. prediction = np.dot(x_data, model.coef_.T) + model.intercept_
  7. prediction = sigmoid(prediction)
  8.  
  9. return (prediction >= 0.5).reshape(-1).astype(int)
  10.  
  11.  
  12. # Task 3:
  13. def calc_accuracy(y_true, y_pred):
  14. total = len(y_true)
  15. cnt = 0
  16. for i in range(total):
  17. if y_true[i] == y_pred[i]:
  18. cnt += 1
  19. return cnt / total
  20.  
  21.  
  22. # Task 4: Test these 2 functions
Success #stdin #stdout 0.08s 14120KB
stdin
Standard input is empty
stdout
Standard output is empty