Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:type class_param : list
:return: csv file data as str
"""
result = "Class"
classes.sort()
for item in classes:
result += ',"' + str(item) + '"'
result += "\n"
class_stat_keys = sorted(class_stat.keys())
if isinstance(class_param, list):
if set(class_param) <= set(class_stat_keys):
class_stat_keys = class_param
if len(class_stat_keys) < 1 or len(classes) < 1:
return ""
for key in class_stat_keys:
row = [rounder(class_stat[key][i], digit) for i in classes]
result += key + "," + ",".join(row)
result += "\n"
return result
return ""
for i in class_stat_keys:
background_color = DEFAULT_BACKGROUND_COLOR
if i in recommended_list:
background_color = RECOMMEND_BACKGROUND_COLOR
result += '\n'
result += '<a style="text-decoration:None;" href="'.format(
background_color) + document_link + PARAMS_LINK[i] + '">' + str(i) + '</a>\n'
for j in classes:
if i in BENCHMARK_LIST:
background_color = BENCHMARK_COLOR[i][class_stat[i][j]]
result += ''.format(
background_color)
else:
result += ''
result += rounder(class_stat[i][j], digit) + '\n'
params_text = PARAMS_DESCRIPTION[i]
if i not in CAPITALIZE_FILTER:
params_text = params_text.capitalize()
result += '' + \
params_text + '\n'
result += "\n"
result += "\n"
return result
if len(overall_stat_keys) < 1:
return ""
for i in overall_stat_keys:
background_color = DEFAULT_BACKGROUND_COLOR
if i in recommended_list:
background_color = RECOMMEND_BACKGROUND_COLOR
result += '\n'
result += '<a style="text-decoration:None;" href="'.format(
background_color) + document_link + PARAMS_LINK[i] + '">' + str(i) + '</a>\n'
if i in BENCHMARK_LIST:
background_color = BENCHMARK_COLOR[i][overall_stat[i]]
result += ''.format(
background_color)
else:
result += ''
result += rounder(overall_stat[i], digit) + '\n'
result += "\n"
result += "\n"
return result
:param class_param : class parameters list for print, Example : ["TPR","TNR","AUC"]
:type class_param : list
:return: printable result as str
"""
shift = max(map(len, PARAMS_DESCRIPTION.values())) + 5
classes_len = len(classes)
overall_stat_keys = sorted(overall_stat.keys())
result = ""
if isinstance(overall_param, list):
if set(overall_param) <= set(overall_stat_keys):
overall_stat_keys = sorted(overall_param)
if len(overall_stat_keys) > 0:
result = "Overall Statistics : " + "\n\n"
for key in overall_stat_keys:
result += key + " " * (shift - len(key) + 7) + \
rounder(overall_stat[key], digit) + "\n"
class_stat_keys = sorted(class_stat.keys())
if isinstance(class_param, list):
if set(class_param) <= set(class_stat_keys):
class_stat_keys = sorted(class_param)
classes.sort()
if len(class_stat_keys) > 0 and len(classes) > 0:
class_shift = max(
max(map(lambda x: len(str(x)), classes)) + 5, digit + 6, 14)
class_shift_format = "%-" + str(class_shift) + "s"
result += "\nClass Statistics :\n\n"
result += "Classes" + shift * " " + class_shift_format * \
classes_len % tuple(map(str, classes)) + "\n"
rounder_map = partial(rounder, digit=digit)
for key in class_stat_keys:
row = [class_stat[key][i] for i in classes]
params_text = PARAMS_DESCRIPTION[key]