From 533ceaefdb95a3b134733f2621e17864371abbb0 Mon Sep 17 00:00:00 2001 From: AndreasKarasenko Date: Tue, 7 May 2024 11:52:49 +0200 Subject: [PATCH] added optional background color for darkmode --- lime/explanation.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lime/explanation.py b/lime/explanation.py index a189729a..2d6761c1 100644 --- a/lime/explanation.py +++ b/lime/explanation.py @@ -186,6 +186,7 @@ def show_in_notebook(self, labels=None, predict_proba=True, show_predicted_value=True, + col_b = "#ffffff", **kwargs): """Shows html explanation in ipython notebook. @@ -196,6 +197,7 @@ def show_in_notebook(self, display(HTML(self.as_html(labels=labels, predict_proba=predict_proba, show_predicted_value=show_predicted_value, + col_b=col_b, **kwargs))) def save_to_file(self, @@ -203,6 +205,7 @@ def save_to_file(self, labels=None, predict_proba=True, show_predicted_value=True, + col_b = "#ffffff", **kwargs): """Saves html explanation to file. . @@ -216,6 +219,7 @@ def save_to_file(self, file_.write(self.as_html(labels=labels, predict_proba=predict_proba, show_predicted_value=show_predicted_value, + col_b=col_b, **kwargs)) file_.close() @@ -223,6 +227,7 @@ def as_html(self, labels=None, predict_proba=True, show_predicted_value=True, + col_b='#ffffff', **kwargs): """Returns the explanation as an html page. @@ -235,6 +240,7 @@ def as_html(self, for the top classes. (only used for classification) show_predicted_value: if true, add barchart with expected value (only used for regression) + col_b: background color for the plot kwargs: keyword arguments, passed to domain_mapper Returns: @@ -251,9 +257,18 @@ def jsonize(x): bundle = open(os.path.join(this_dir, 'bundle.js'), encoding="utf8").read() - out = u''' + out = u''' + + - ''' % bundle + + + + '''.format(col_b, bundle) random_id = id_generator(size=15, random_state=check_random_state(self.random_state)) out += u'''