def create_basic_report_data_dict(umbral,target,main_metric,feature_selection_method,penalize_falses,lista_variables_descartadas,ruta_logo): report_data = {glod.get_title_key(): "Overview With Execution Information", glod.get_logo_key():ruta_logo, glod.get_umbral_key(): str(umbral), glod.get_main_metric_key(): str(main_metric), glod.get_feature_selection_key(): str(feature_selection_method), glod.get_penalization_name(): str(penalize_falses), glod.get_objective_target_key(): target, glod.get_variables_key():{glod.get_deleted_by_user_key():lista_variables_descartadas}, glod.get_general_info_execution_key():'' } return report_data
def create_report_data_dict(evento,umbral,target,lista_variables_descartadas,ruta_logo): report_data = {glod.get_objective_target_key(): target, glod.get_event_key():evento, glod.get_logo_key():ruta_logo, glod.get_report_general_info_key():{glod.get_report_generic_target_key():{}, glod.get_variables_key():{glod.get_deleted_by_user_key():lista_variables_descartadas,glod.get_empty_or_constant_key():[],glod.get_score_relevant_key():[]}, glod.get_training_division_key():{}, glod.get_test_division_key():{}, }, glod.get_umbral_key(): str(umbral), glod.get_warning_key(): '' } return report_data
def create_report_data_dict(evento, umbral, target, lista_variables_descartadas, ruta_logo): '''This funcion allows to create the structure for the report data dictionary for the current event''' report_data = {glod.get_objective_target_key(): target, glod.get_event_key():evento, glod.get_logo_key():ruta_logo, glod.get_report_general_info_key():{glod.get_report_generic_target_key():{}, glod.get_variables_key():{glod.get_deleted_by_user_key():lista_variables_descartadas, glod.get_empty_or_constant_key():[], glod.get_score_relevant_key():[]}, glod.get_training_division_key():{}, glod.get_test_division_key():{}, }, glod.get_umbral_key(): str(umbral), glod.get_warning_key(): glod.get_empty_string() } return report_data
def create_basic_report_data_dict(basic_parameters, lista_variables_descartadas, ruta_logo): '''This funcion allows to create the structure for the report data dictionary''' umbral = basic_parameters[0] target = basic_parameters[1] main_metric = basic_parameters[2] feature_selection_method = basic_parameters[3] penalize_falses = basic_parameters[4] report_data = {glod.get_title_key(): "Overview With Execution Information", glod.get_logo_key():ruta_logo, glod.get_umbral_key(): str(umbral), glod.get_main_metric_key(): str(main_metric), glod.get_feature_selection_key(): str(feature_selection_method), glod.get_penalization_name(): str(penalize_falses), glod.get_objective_target_key(): target, glod.get_variables_key():{glod.get_deleted_by_user_key():\ lista_variables_descartadas}, glod.get_general_info_execution_key():glod.get_empty_string() } return report_data
def create_report_current_execution(report_dict,lista_eventos,lista_variables_usuario,lista_listas_variables_descartadas,lista_aprendizajes,lista_modelos, diccionario_aprendizajes, ruta_relativa_datos_auxiliares, ruta_directorio_resultados,enco): env = Environment(loader=FileSystemLoader('.')) ruta_plantilla_temporal = os.path.join(ruta_relativa_datos_auxiliares,'temp_html.html') template = env.get_template(ruta_relativa_datos_auxiliares + '/' + 'general_execution_template.html') template_vars = {glod.get_title_key(): report_dict[glod.get_title_key()], glod.get_logo_key():encode_image(report_dict[glod.get_logo_key()].replace('\'','')), glod.get_general_info_execution_key():'' } #General parameters (target,umbral,variables_descartadas) target = report_dict[glod.get_objective_target_key()] umbral = report_dict[glod.get_umbral_key()] main_metric = report_dict[glod.get_main_metric_key()] feature_selection_method = report_dict[glod.get_feature_selection_key()] penalize_falses = report_dict[glod.get_penalization_name()] lista_variables_descartadas = report_dict[glod.get_variables_key()][glod.get_deleted_by_user_key()] tabulacion = " " informacion= "<h3>Common Parameters </h3></p>" informacion+= tabulacion+tabulacion + "<i>Objective Target: </i>" + target + "</br></br>" informacion+=tabulacion+tabulacion + "<i>Percentil for Scoring Function: </i>" + umbral + "</br></br>" informacion+=tabulacion+tabulacion + "<i>Main metric: </i>" + main_metric + "</br></br>" informacion+=tabulacion+tabulacion + "<i>Feature selection method: </i>" + feature_selection_method + "</br></br>" informacion+=tabulacion+tabulacion + "<i>Penalize falses: </i>" + penalize_falses + "</br></br>" informacion+=tabulacion+tabulacion + "<i>Common Discarded Variables:</i></br>" for variable_descartada in lista_variables_descartadas: informacion+=tabulacion+tabulacion+tabulacion + variable_descartada + "</br>" if(lista_variables_descartadas == []): informacion+=tabulacion+"No variables were selected to be discarded</br>" informacion+="</p>" informacion+= "<h3>Events to be processed: </h3><p>" for indice in range(len(lista_eventos)): informacion+=tabulacion+"<strong>"+ lista_eventos[indice] + "</strong></br>" informacion+=tabulacion+tabulacion+"<i>Important features for the user:</i> </br>" if(lista_variables_usuario[indice]): for variable in lista_variables_usuario[indice]: informacion+=tabulacion+tabulacion+tabulacion+variable + "</br>" else: informacion+=tabulacion+tabulacion+tabulacion+"No important features were specified</br>" informacion+="</br>" informacion+=tabulacion+tabulacion+"<i>Discarded variables by the user:</i> </br>" if(lista_listas_variables_descartadas[indice]): for variable in lista_listas_variables_descartadas[indice]: informacion+=tabulacion+tabulacion+tabulacion+variable + "</br>" else: informacion+=tabulacion+tabulacion+tabulacion+"No variables were discarded</br>" informacion+="</br>" informacion += tabulacion+tabulacion+"<i>Learnings to be applied: </i></br>" aprendizaje = lista_aprendizajes[indice] modelos = lista_modelos[indice] if aprendizaje == glod.get_all_learning_modes_name():#looping supervised models informacion += tabulacion+tabulacion+tabulacion+"<u>" +\ str(diccionario_aprendizajes[1]) + "</u>:</br>" modelos_sup = modelos[0] for modelo_act in modelos_sup: informacion += tabulacion+tabulacion+tabulacion+tabulacion + modelo_act + "</br>" informacion += "</br>" informacion += tabulacion+tabulacion+tabulacion+"<u>" +\ str(diccionario_aprendizajes[2]) + "</u>:</br>" modelos_unsup = modelos[1] for modelo_act in modelos_unsup: informacion += tabulacion+tabulacion+tabulacion+tabulacion + modelo_act + "</br>" informacion += "</br>" else: informacion += tabulacion+tabulacion+tabulacion+"<u>"+aprendizaje + "</u>:</br>" for modelo_act in modelos: informacion += tabulacion+tabulacion+tabulacion+tabulacion + modelo_act + "</br>" informacion += "</p>" template_vars[glod.get_general_info_execution_key()] = informacion with codecs.open(ruta_plantilla_temporal,'w',encoding=enco) as output_file: output_file.write(template.render(template_vars)) with codecs.open(ruta_plantilla_temporal, 'r') as html_leido: pdf_resultante=os.path.join(ruta_directorio_resultados,"General_execution_report_"+ target +".pdf") with open(pdf_resultante, "wb") as gen_report: pisa.CreatePDF(html_leido.read(),gen_report) logging.getLogger("xhtml2pdf").addHandler(PisaNullHandler()) if(os.path.exists(ruta_plantilla_temporal)): os.remove(ruta_plantilla_temporal)
def update_report_percentil(report_dict,valor): report_dict[glod.get_umbral_key()] = valor return report_dict
def update_report_percentil(report_dict, valor): '''This funcion allows to register the percentil value in the report''' report_dict[glod.get_umbral_key()] = valor return report_dict