Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. def custom_accuracy_score(Y_test, Y_pred):
  2.     """
  3.    Считает accuracy как процент попадания в отрезок +-0.1% от реальной цены
  4.  
  5.    Params:
  6.    Y_pred -- вектор предсказаний
  7.    Y_test -- таргет
  8.  
  9.    Returns:
  10.    custom_accuracy_score -- результат подсчёта accuracy
  11.    """
  12.     interval_array = np.array([[x - x*0.085, x + x*0.085] for x in Y_test]).T
  13.     custom_accuracy_score = sum((Y_pred >= interval_array[0]) & (Y_pred <= interval_array[1]))/len(Y_pred)
  14.     return custom_accuracy_score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement