import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression import numpy as np Y_B2 = [36, 3876, 7716, 11556, 15396, 19236, 23076, 26916, 30756] Y_B3 = [97, 36786, 84655, 135454, 191580, 247876, 304307, 365937, 427737] YA_B2 = [28, 2124, 4199, 6345, 8380, 10441, 12525, 14607, 16690] YA_B3 = [36, 4106 , 8161 , 12071, 16060, 20056 , 24096, 28115, 32068] X = [0, 128, 256, 384, 512, 640, 768, 896, 1024] plt.scatter(X, Y_B2, color="b", label="RISCV Branchement 1/2") plt.scatter(X, Y_B3, color="b", marker="x", label="Branchement 1/3") plt.scatter(X, YA_B2, color="r", label="ARM Branchement 1/2") plt.scatter(X, YA_B3, color="r",marker="x", label="ARM Branchement 1/3") x = np.array(X).reshape(-1, 1) y = np.array(Y_B2).reshape(-1, 1) y2 = np.array(YA_B2).reshape(-1, 1) reg = LinearRegression().fit(x, y) reg2 = LinearRegression().fit(x, y2) print("score obtenu : " + str(reg.score(x, y))) print("score obtenu : " + str(reg2.score(x, y2))) print("attente à zéro : {}".format(reg.intercept_)) print("attente à zéro : {}".format(reg2.intercept_)) x_lin = [0, max(X)] y_lin = [reg.predict(np.array([0]).reshape(-1, 1)), reg.predict(np.array([x_lin[1]]).reshape(-1, 1))] y_lin2 = [reg2.predict(np.array([0]).reshape(-1, 1)), reg2.predict(np.array([x_lin[1]]).reshape(-1, 1))] y_lin = [y_lin[0][0][0], y_lin[1][0][0]] y_lin2 = [y_lin2[0][0][0], y_lin2[1][0][0]] plt.plot(x_lin, y_lin, color = "b", label="RegLin score : {:.4f}".format(reg.score(x, y))) plt.plot(x_lin, y_lin2, color = "r", label="RegLin score : {:.4f}".format(reg2.score(x, y2))) plt.xlim([0, 1024]) plt.ylim([50, 450000]) plt.legend() plt.title("Cycles d'exécution en fonction de n_max") plt.ylabel("Cycles") plt.xlabel("N_max") plt.savefig("memory_cycles.png") plt.show()