here i implemented the scoring functions mae mse rmse rmsle are included those are used for calculating differences between predicted values and actual values metrics are slightly differentiated sometimes squared rooted even log is used using log and roots can be perceived as tools for penalizing big errors however using appropriate metrics depends on the situations and types of data mean absolute error examplesrounded for precision actual 1 2 3 predict 1 4 3 np aroundmaepredict actual decimals 2 0 67 actual 1 1 1 predict 1 1 1 maepredict actual 0 0 mean squared error examplesrounded for precision actual 1 2 3 predict 1 4 3 np aroundmsepredict actual decimals 2 1 33 actual 1 1 1 predict 1 1 1 msepredict actual 0 0 root mean squared error examplesrounded for precision actual 1 2 3 predict 1 4 3 np aroundrmsepredict actual decimals 2 1 15 actual 1 1 1 predict 1 1 1 rmsepredict actual 0 0 root mean square logarithmic error examplesrounded for precision actual 10 10 30 predict 10 2 30 np aroundrmslepredict actual decimals 2 0 75 actual 1 1 1 predict 1 1 1 rmslepredict actual 0 0 mean bias deviation this value is negative if the model underpredicts positive if it overpredicts examplerounded for precision here the model overpredicts actual 1 2 3 predict 2 3 4 np aroundmbdpredict actual decimals 2 50 0 here the model underpredicts actual 1 2 3 predict 0 1 1 np aroundmbdpredict actual decimals 2 66 67 printnumerator denumerator here i implemented the scoring functions mae mse rmse rmsle are included those are used for calculating differences between predicted values and actual values metrics are slightly differentiated sometimes squared rooted even log is used using log and roots can be perceived as tools for penalizing big errors however using appropriate metrics depends on the situations and types of data mean absolute error examples rounded for precision actual 1 2 3 predict 1 4 3 np around mae predict actual decimals 2 0 67 actual 1 1 1 predict 1 1 1 mae predict actual 0 0 mean squared error examples rounded for precision actual 1 2 3 predict 1 4 3 np around mse predict actual decimals 2 1 33 actual 1 1 1 predict 1 1 1 mse predict actual 0 0 root mean squared error examples rounded for precision actual 1 2 3 predict 1 4 3 np around rmse predict actual decimals 2 1 15 actual 1 1 1 predict 1 1 1 rmse predict actual 0 0 root mean square logarithmic error examples rounded for precision actual 10 10 30 predict 10 2 30 np around rmsle predict actual decimals 2 0 75 actual 1 1 1 predict 1 1 1 rmsle predict actual 0 0 mean bias deviation this value is negative if the model underpredicts positive if it overpredicts example rounded for precision here the model overpredicts actual 1 2 3 predict 2 3 4 np around mbd predict actual decimals 2 50 0 here the model underpredicts actual 1 2 3 predict 0 1 1 np around mbd predict actual decimals 2 66 67 print numerator denumerator
import numpy as np





def mae(predict, actual):
    
    predict = np.array(predict)
    actual = np.array(actual)

    difference = abs(predict - actual)
    score = difference.mean()

    return score



def mse(predict, actual):
    
    predict = np.array(predict)
    actual = np.array(actual)

    difference = predict - actual
    square_diff = np.square(difference)

    score = square_diff.mean()
    return score



def rmse(predict, actual):
    
    predict = np.array(predict)
    actual = np.array(actual)

    difference = predict - actual
    square_diff = np.square(difference)
    mean_square_diff = square_diff.mean()
    score = np.sqrt(mean_square_diff)
    return score



def rmsle(predict, actual):
    
    predict = np.array(predict)
    actual = np.array(actual)

    log_predict = np.log(predict + 1)
    log_actual = np.log(actual + 1)

    difference = log_predict - log_actual
    square_diff = np.square(difference)
    mean_square_diff = square_diff.mean()

    score = np.sqrt(mean_square_diff)

    return score



def mbd(predict, actual):
    
    predict = np.array(predict)
    actual = np.array(actual)

    difference = predict - actual
    numerator = np.sum(difference) / len(predict)
    denumerator = np.sum(actual) / len(predict)
    
    score = float(numerator) / denumerator * 100

    return score


def manual_accuracy(predict, actual):
    return np.mean(np.array(actual) == np.array(predict))