Python Scikit Learn - Max Error














































Python Scikit Learn - Max Error



Introduction:

*It calculates the maximum residual error.
*It's best value is 0.


Parameters:

*y_true - 1d array like structure(set of true values)
*y_pred - 1d array like structure(set of predicted values by the classifier)



Returns:

*Returns a positive floating point value i.e. max error.



Implementation of Max Error:


class MaxErr:

  def __init__(self):
    self.ma = 0

  def pos(self,x):

    if x<0:
      return -x
    else:
      return x

  def calc_ma(self,l1,l2):

    for i in range(len(l1)):
      y = self.pos(l1[i] - l2[i])
      self.ma = max(self.ma , y)
    print(self.ma)

def main():
  ob = MaxErr()
  y_true = [3271]
  y_pred = [9271]
  ob.calc_ma(y_true,y_pred)

if __name__=="__main__":
  main()

Output :

6



Using Inbuilt Library :

from sklearn.metrics import max_error
y_true = [3, 2, 7, 1]
y_pred = [9, 2, 7, 1]
max_error(y_true, y_pred)


Output :

6



More Articles of Piyush unknown:

Name Views Likes
Python Scikit Learn - Precision Score 531 1
Python Scikit Learn - Mean Absolute Error 401 1
Python Scikit Learn Linear Model - MNIST with Logistic Regression 725 1
Python Scikit Learn Metrics - DCG Score 649 1
Python Scikit Learn Neighbors - KNeighborsClassifier 516 2
Python Scikit Learn Metrics - Sigmoid Kernel 815 2
Python Scikit Learn Metrics - Cohen Kappa Score 2261 1
Python Scikit Learn Metrics - ROC Curve 337 1
Python Scikit Learn Metrics - ROC AUC Score 514 1
Python Scikit Learn Metrics - Mean Poisson Deviance 1038 1
Python Scikit Learn Metrics - NaN Euclidean Distances 1920 1
Python Scikit Learn - Jaccard Score 1398 1
Python Scikit Learn Introduction 395 1
Python Scikit Learn - FBeta Score 427 1
Python Scikit Learn - Max Error 418 1
Python Scikit Learn Metrics - Chi2 Kernel 562 2
Python Scikit Learn Metrics - Manhattan Distances 807 1
Python Scikit Learn Metrics - Euclidean Distance 376 1
Python Scikit Learn Model Selection - Train Test Split 583 1
Python Scikit Learn Metrics - Laplacian Kernel 735 2
Python Scikit Learn Metrics - Zero One Loss 1102 1
Python Scikit Learn - Hamming Loss 404 1
Python Scikit Learn Metrics - Linear Kernel 624 1
Pytho Scikit Learn - Balanced Accuracy Score 842 1
Python Scikit Learn - Accuracy Score 433 1
Python Scikit Learn - F1 score 489 1
Python Scikit Learn Metrics - Polynomial Kernel 573 2
Python Scikit Learn Metrics - AUC 326 1
Python Scikit Learn - Mean Squared Log Error 362 1
Python Scikit Learn Metrics - Precision Recall Fscore Support 1190 1
Python Scikit Learn - R2 Score 434 1
Python Scikit Learn Preprocessing - Standard Scaler 320 1
Python Scikit Learn Linear Model - Linear Regression 297 1
Python Scikit Learn Metrics - Brier Score 684 1
Python Scikit Learn - Median Absolute Error 762 1
Python Scikit Learn Metrics - Multilabel Confusion Matrix 909 1
Python Scikit Learn Linear Model - Logistic Regression 331 1
Python Scikit Learn - Mean Squared Error 469 1
Python Scikit Learn - Matthews Correlation Coefficient 1254 1
Python Scikit Learn Metrics - Cosine Similarity 661 1
Python Scikit Learn Metrics - NDCG Score 2147 1
Python Scikit Learn Metrics - Pairwise Distances Argmin 569 2
Python Scikit Learn Preprocessing - Max Abs Scaler 845 1
Python Scikit Learn Preprocessing - Min Max Scaler 507 1
Python Scikit Learn Metrics - Mean Gamma Deviance 1147 1
Python Scikit Learn - Confusion Matrix 422 1
Python Scikit Learn - Recall Score 401 1
Python Scikit Learn Metrics - Cosine Distances 374 1
Python Scikit Learn - Explained Variance Score 949 1
Python Scikit Learn Metrics - Precision Recall Curve 654 1

Comments