class_docstr: Object returned by explainers.
docstr: Returns the explanation as an html page.
  
  Args:
      labels: desired labels to show explanations for (as barcharts).
          If you ask for a label for which an explanation wasn't
          computed, will throw an exception. If None, will show
          explanations for all available labels. (only used for classification)
      predict_proba: if true, add  barchart with prediction probabilities
          for the top classes. (only used for classification)
      show_predicted_value: if true, add  barchart with expected value
          (only used for regression)
      kwargs: keyword arguments, passed to domain_mapper
  
  Returns:
      code for an html page, including javascript includes.
docstr_tok: ["Returns","the","explanation","as","an","html","page",".","Args",":","labels",":","desired","labels","to","show","explanations","for","(","as","barcharts",")",".","If","you","ask","for","a","label","for","which","an","explanation","wasn't","computed",",","will","throw","an","exception",".","If","None",",","will","show","explanations","for","all","available","labels",".","(","only","used","for","classification",")","predict_proba",":","if","true",",","add","barchart","with","prediction","probabilities","for","the","top","classes",".","(","only","used","for","classification",")","show_predicted_value",":","if","true",",","add","barchart","with","expected","value","(","only","used","for","regression",")","kwargs",":","keyword","arguments",",","passed","to","domain_mapper","Returns",":","code","for","an","html","page",",","including","javascript","includes","."]
code: def as_html(
      self,
      labels=None,
      predict_proba=True,
      show_predicted_value=True,
      **kwargs,
  ):
      """Returns the explanation as an html page.
  
      Args:
          labels: desired labels to show explanations for (as barcharts).
              If you ask for a label for which an explanation wasn't
              computed, will throw an exception. If None, will show
              explanations for all available labels. (only used for classification)
          predict_proba: if true, add  barchart with prediction probabilities
              for the top classes. (only used for classification)
          show_predicted_value: if true, add  barchart with expected value
              (only used for regression)
          kwargs: keyword arguments, passed to domain_mapper
  
      Returns:
          code for an html page, including javascript includes.
      """
  
      def jsonize(x):
          return json.dumps(x, ensure_ascii=False)
  
      if labels is None and self.mode == "classification":
          labels = self.available_labels()
  
      this_dir, _ = os.path.split(__file__)
      bundle = open(
          os.path.join(this_dir, "bundle.js"), encoding="utf8"
      ).read()
  
      out = (
          """<html>
          <meta http-equiv="content-type" content="text/html; charset=UTF8">
          <head><script>%s </script></head><body>"""
          % bundle
      )
      random_id = id_generator(
          size=15, random_state=check_random_state(self.random_state)
      )
      out += (
          """
          <div class="lime top_div" id="top_div%s"></div>
          """
          % random_id
      )
  
      predict_proba_js = ""
      if self.mode == "classification" and predict_proba:
          predict_proba_js = """
              var pp_div = top_div.append('div')
                                  .classed('lime predict_proba', true);
              var pp_svg = pp_div.append('svg').style('width', '100%%');
              var pp = new lime.PredictProba(pp_svg, %s, %s);
              """ % (
              jsonize([str(x) for x in self.class_names]),
              jsonize(list(self.predict_proba.astype(float))),
          )
  
      predict_value_js = ""
      if self.mode == "regression" and show_predicted_value:
          # reference self.predicted_value
          # (svg, predicted_value, min_value, max_value)
          predict_value_js = """
                      var pp_div = top_div.append('div')
                                          .classed('lime predicted_value', true);
                      var pp_svg = pp_div.append('svg').style('width', '100%%');
                      var pp = new lime.PredictedValue(pp_svg, %s, %s, %s);
                      """ % (
              jsonize(float(self.predicted_value)),
              jsonize(float(self.min_value)),
              jsonize(float(self.max_value)),
          )
  
      exp_js = """var exp_div;
              var exp = new lime.Explanation(%s);
          """ % (
          jsonize([str(x) for x in self.class_names])
      )
  
      if self.mode == "classification":
          for label in labels:
              exp = jsonize(self.as_list(label))
              exp_js += """
                  exp_div = top_div.append('div').classed('lime explanation', true);
                  exp.show(%s, %d, exp_div);
                  """ % (
                  exp,
                  label,
              )
      else:
          exp = jsonize(self.as_list())
          exp_js += """
              exp_div = top_div.append('div').classed('lime explanation', true);
              exp.show(%s, %s, exp_div);
              """ % (
              exp,
              self.dummy_label,
          )
  
      raw_js = """var raw_div = top_div.append('div');"""
  
      if self.mode == "classification":
          html_data = self.local_exp[labels[0]]
      else:
          html_data = self.local_exp[self.dummy_label]
  
      raw_js += self.domain_mapper.visualize_instance_html(
          html_data,
          labels[0]
          if self.mode == "classification"
          else self.dummy_label,
          "raw_div",
          "exp",
          **kwargs,
      )
      out += """
          <script>
          var top_div = d3.select('#top_div%s').classed('lime top_div', true);
          %s
          %s
          %s
          %s
          </script>
          """ % (
          random_id,
          predict_proba_js,
          predict_value_js,
          exp_js,
          raw_js,
      )
      out += "</body></html>"
  
      return out
  
imports: from io import open
  import os
  import os.path
  import json
  import string
  import numpy
  from .exceptions import LimeError
  from sklearn.utils import check_random_state
label_desc: Use image node_id 8 for calling the Explanation obj's underlying member method code with example usage: obj.as_html(labels, predict_proba, show_predicted_value) and returns: out, json