Spaces:
Sleeping
Sleeping
Update src/visualization.py
Browse files612 unmodified lines613614615616617618619620621622623624625626627628629630631632633634635636637638639640612 unmodified linesssd_mean = ssd_mean / nb_good_sampleslogger.info(f"SSD moyen pour les échantillons de test: {ssd_mean:.4g}")return rel_error, ssd_meandef plot_comparaison_courbes(self,data_processor, model, X_test, lst_I_real, lst_V):param_names = ['Rsh', 'Rs', 'n', 'J0', 'Jph']y_pred = model.predict(X_test)# Inverser la normalisationy_pred_orig = data_processor.inverse_transform_params(y_pred)for i in range (len(X_test)):params = {'Rsh':0, 'Rs':0, 'n':0, 'J0':0, 'Jph':0}params_pred = y_pred_orig[i]for i, param in enumerate(param_names):params[param] = params_pred[i]I_model = -iv_curve(lst_V[i], params['Rsh'], params['Rs'], params['n']*self.Vth, params['J0'], params['Jph'])plt.plot(lst_V[i], I_model, label='Courbe I-V prédite', color='red')plt.plot(lst_V[i], lst_I_real[i], label='Courbe I-V réelle', color='blue')plt.title(f'Comparaison des courbes I-V - Échantillon {i}', fontsize=14, fontweight='bold')plt.xlabel('Tension (V)', fontsize=12)plt.ylabel('Courant (I)', fontsize=12)plt.grid(True, linestyle='--', alpha=0.7)plt.legend(fontsize=12)plt.show()def comparaison_courbes(self,data_processor, model, X_test, lst_I_real, lst_V):612 unmodified lines613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649612 unmodified linesssd_mean = ssd_mean / nb_good_sampleslogger.info(f"SSD moyen pour les échantillons de test: {ssd_mean:.4g}")return rel_error, ssd_meandef plot_comparaison_courbes(self,data_processor, model, X_test, lst_I_real, lst_V, Plot =True):param_names = ['Rsh', 'Rs', 'n', 'J0', 'Jph']y_pred = model.predict(X_test)# Inverser la normalisationy_pred_orig = data_processor.inverse_transform_params(y_pred)print(len(X_test))print(len(lst_V))print(lst_V)for i in range (len(X_test)):print(i)params = {'Rsh':0, 'Rs':0, 'n':0, 'J0':0, 'Jph':0}params_pred = y_pred_orig[i]for j, param in enumerate(param_names):params[param] = params_pred[j]I_model = -iv_curve(lst_V[i], params['Rsh'], params['Rs'], params['n']*self.Vth, params['J0'], params['Jph'])if Plot:plt.plot(lst_V[i], I_model, label='Courbe I-V prédite', color='red')plt.plot(lst_V[i], lst_I_real[i], label='Courbe I-V réelle', color='blue')plt.title(f'Comparaison des courbes I-V - Échantillon {i}', fontsize=14, fontweight='bold')plt.xlabel('Tension (V)', fontsize=12)plt.ylabel('Courant (I)', fontsize=12)plt.grid(True, linestyle='--', alpha=0.7)plt.legend(fontsize=12)plt.show()return params, I_modeldef comparaison_courbes(self,data_processor, model, X_test, lst_I_real, lst_V):
src/visualization.py+22-13