# CC_MAE_RMSE.py for demoing (pearsonr) Correlation Coefficient (CC), # Mean Absolute Error (MAE), and Root Mean Squared Error (RMSE). # D. Parson, September 2024. from scipy.stats import pearsonr, spearmanr from random import Random from sklearn.metrics import mean_squared_error from sklearn.metrics import mean_absolute_error from math import sqrt, log2 def CC(sequence1, sequence2): # Correlation Coefficient (CC) without numpy types cc, err = pearsonr(sequence1, sequence2) cc = round(float(cc), 2) return cc def SR(sequence1, sequence2): # Correlation Coefficient (CC) without numpy types cc, err = spearmanr(sequence1, sequence2) cc = round(float(cc), 2) return cc def MAE(sequence1, sequence2): # Mean absolute error without any numpy types return round(float(mean_absolute_error(sequence1, sequence2)),2) def RMSE(sequence1, sequence2): # Root mean squared error without any numpy types return round(sqrt(float(mean_squared_error(sequence1, sequence2))),2) lin1 = list(range(0,50,5)) lin2 = list(range(0,20,2)) sqr2 = [element ** 2 + 5 for element in lin1] pow2 = [2 ** element + 7 for element in lin1] sqrt2 = [sqrt(element) for element in sqr2] invpow2 = [log2(element) for element in pow2]