import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression import numpy as np Y = [661, 971, 1282, 1613, 1936, 2273, 2609, 2933, 3264] Y2 = [205, 290, 395, 478, 562, 625, 718, 808, 899] Y_ARM = [424, 824 , 1224 , 1624, 2024, 2424 , 2824, 3224, 3624] Y_gcc = [2296, 5119, 6715, 9078, 10830, 12541, 15041, 16780, 18883] Y_O3 = [165, 287, 380, 559, 900, 901, 776, 1122, 1574] X = [] temps = [] for i in range(9) : Y[i] = Y[i]*3/100 Y2[i]=Y[i]*3/100 Y_ARM[i] = Y_ARM[i]*3/100 Y_gcc[i] = Y_gcc[i]*3/100/4 Y_O3[i] = Y_O3[i]*3/100/4 X.append(50*(1+i)) temps.append(Y[i]/33333334) plt.scatter(X, Y, color="b", marker="x", label="FPGA 50 MHz") plt.scatter(X, Y2, color="g", marker="x", label="FPGA 200 MHz") plt.scatter(X, Y_ARM, color="g", label="mesures ARM") plt.scatter(X, Y_gcc, color="y",marker="*", label="desktop non opti") plt.scatter(X, Y_O3, color="pink", marker="*",label="desktop_opti") x = np.array(X).reshape(-1, 1) y = np.array(Y).reshape(-1, 1) y2 = np.array(Y2).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(reg.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 = "r", label="RegLin 50 score : {:.4f}".format(reg.score(x, y))) plt.plot(x_lin, y_lin2, color = "r") plt.xlim([0, 500]) plt.ylim([0, 100]) plt.legend() plt.title("Temps d'exécution en fonction de n_max") plt.ylabel("T (0.1 µs)") plt.xlabel("N_max") plt.savefig("M2_SETI/A2/fibonacci/linéaire.png") plt.show()