Skip to content

Commit 4463148

Browse files
jairideoutebolyen
authored andcommitted
MAINT: update to use q2templates.df_to_html (#58)
1 parent e5d7aa5 commit 4463148

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

q2_sample_classifier/utilities.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,15 @@ def _visualize(output_dir, estimator, cm, accuracy, importances=None,
347347

348348
# summarize model accuracy and params
349349
result = pd.Series(estimator.get_params(), name='Parameter setting')
350-
result = result.to_frame().to_html(classes=(
351-
"table table-striped table-hover")).replace('border="1"', 'border="0"')
350+
result = q2templates.df_to_html(result.to_frame())
352351

353-
cm = cm.to_html(classes=(
354-
"table table-striped table-hover")).replace('border="1"', 'border="0"')
352+
cm = q2templates.df_to_html(cm)
355353
if importances is not None:
356354
importances = sort_importances(importances)
357355
pd.set_option('display.float_format', '{:.3e}'.format)
358356
importances.to_csv(join(
359357
output_dir, 'feature_importance.tsv'), sep='\t', index=False)
360-
importances = importances.to_html(classes=(
361-
"table table-striped table-hover"), index=False).replace(
362-
'border="1"', 'border="0"')
358+
importances = q2templates.df_to_html(importances, index=False)
363359

364360
index = join(TEMPLATES, 'index.html')
365361
q2templates.render(index, output_dir, context={
@@ -384,9 +380,7 @@ def _visualize_maturity_index(table, metadata, group_by, category,
384380
importances = sort_importances(importances)
385381
importances.to_csv(
386382
join(output_dir, 'feature_importance.tsv'), index=False, sep='\t')
387-
importance = importances.to_html(classes=(
388-
"table table-striped table-hover"), index=False).replace(
389-
'border="1"', 'border="0"')
383+
importance = q2templates.df_to_html(importances, index=False)
390384

391385
# save predicted values, maturity, and MAZ score data
392386
maz_md = metadata[[group_by, category, predicted_category, maturity, maz]]
@@ -421,8 +415,7 @@ def _visualize_maturity_index(table, metadata, group_by, category,
421415

422416
result = pd.Series(estimator.get_params(), name='Parameter setting')
423417
result.append(pd.Series([accuracy], index=['Accuracy score']))
424-
result = result.to_frame().to_html(classes=(
425-
"table table-striped table-hover")).replace('border="1"', 'border="0"')
418+
result = q2templates.df_to_html(result.to_frame())
426419

427420
index = join(TEMPLATES, 'index.html')
428421
q2templates.render(index, output_dir, context={

0 commit comments

Comments
 (0)