class_docstr: A experiment tracker backed by a SQLite database
  
  :doc:`Click here <../comparison/SQLiteTracker>` to see the user guide.
  
  Parameters
  ----------
  path
      Database location
  
  Examples
  --------
  >>> from sklearn_evaluation import SQLiteTracker
  >>> tracker = SQLiteTracker("experiments.db")
  >>> experiment = tracker.new_experiment() # new experiment
  >>> experiment.log("accuracy", 0.8) # log metric
  0.8
  >>> tracker.get(experiment.uuid) # retrieve it later with the uuid
  Experiment({'accuracy': 0.8})
  >>> experiment.log_confusion_matrix([1, 1, 0, 0], [1, 0, 1, 0]) # doctest: +SKIP
  >>> data = tracker.get(experiment.uuid)
  >>> data['confusion_matrix'] # doctest: +SKIP
class_docstr_tok: ["A","experiment","tracker","backed","by","a","SQLite","database",":","doc",":","`","Click","here","<","..","\/comparison\/SQLiteTracker",">","`","to","see","the","user","guide",".","Parameters","--","--","--","--","--","path","Database","location","Examples","--","--","--","--",">",">",">","from","sklearn_evaluation","import","SQLiteTracker",">",">",">","tracker","=","SQLiteTracker","(","``","experiments.db","''",")",">",">",">","experiment","=","tracker.new_experiment","(",")","#","new","experiment",">",">",">","experiment.log","(","``","accuracy","''",",","0.8",")","#","log","metric","0.8",">",">",">","tracker.get","(","experiment.uuid",")","#","retrieve","it","later","with","the","uuid","Experiment","(","{","'accuracy","'",":","0.8","}",")",">",">",">","experiment.log_confusion_matrix","(","[","1",",","1",",","0",",","0","]",",","[","1",",","0",",","1",",","0","]",")","#","doctest",":","+SKIP",">",">",">","data","=","tracker.get","(","experiment.uuid",")",">",">",">","data","[","'confusion_matrix","'","]","#","doctest",":","+SKIP"]
docstr: Query the database
  
  Parameters
  ----------
  code : str
      The SQL query to execute
  
  as_frame : bool, default=True
      If True, it'll return the results of your query in a
      pandas.DataFrame, otherwise it'll return a Results object.
      The Results object can render HTML stored in the database but
      cannot be filtered or manipulated like a pandas.DataFrame
  
  render_plots: bool, default=False
      Whether to render plots in the results or not. Only valid when
      as_frame=False
  
  Examples
  --------
  >>> from sklearn_evaluation import SQLiteTracker
  >>> tracker = SQLiteTracker('experiments.db')
  >>> exp1 = tracker.new_experiment()
  >>> exp1.log("accuracy", 0.8) # doctest: +SKIP
  >>> exp1.log_confusion_matrix([1, 1, 0, 0], [1, 0, 1, 0]) # doctest: +SKIP
  >>> exp2 = tracker.new_experiment()
  >>> exp2.log("accuracy", 1.0) # doctest: +SKIP
  >>> exp2.log_confusion_matrix([1, 1, 0, 0], [1, 1, 0, 0]) # doctest: +SKIP
  
  >>> df = tracker.query('''
  ... SELECT uuid,
  ...        json_extract(parameters, '$.accuracy') AS accuracy,
  ...        json_extract(parameters, '$.confusion_matrix') AS cm
  ... FROM experiments
  ... ''', as_frame=True)
  
  
  >>> results = tracker.query('''
  ... SELECT uuid,
  ...        json_extract(parameters, '$.accuracy') AS accuracy,
  ...        json_extract(parameters, '$.confusion_matrix') AS cm
  ... FROM experiments
  ... ''', as_frame=False, render_plots=True)
docstr_tok: ["Query","the","database","Parameters","--","--","--","--","--","code",":","str","The","SQL","query","to","execute","as_frame",":","bool",",","default=True","If","True",",","it","'ll","return","the","results","of","your","query","in","a","pandas.DataFrame",",","otherwise","it","'ll","return","a","Results","object",".","The","Results","object","can","render","HTML","stored","in","the","database","but","can","not","be","filtered","or","manipulated","like","a","pandas.DataFrame","render_plots",":","bool",",","default=False","Whether","to","render","plots","in","the","results","or","not",".","Only","valid","when","as_frame=False","Examples","--","--","--","--",">",">",">","from","sklearn_evaluation","import","SQLiteTracker",">",">",">","tracker","=","SQLiteTracker","(","'experiments.db","'",")",">",">",">","exp1","=","tracker.new_experiment","(",")",">",">",">","exp1.log","(","``","accuracy","''",",","0.8",")","#","doctest",":","+SKIP",">",">",">","exp1.log_confusion_matrix","(","[","1",",","1",",","0",",","0","]",",","[","1",",","0",",","1",",","0","]",")","#","doctest",":","+SKIP",">",">",">","exp2","=","tracker.new_experiment","(",")",">",">",">","exp2.log","(","``","accuracy","''",",","1.0",")","#","doctest",":","+SKIP",">",">",">","exp2.log_confusion_matrix","(","[","1",",","1",",","0",",","0","]",",","[","1",",","1",",","0",",","0","]",")","#","doctest",":","+SKIP",">",">",">","df","=","tracker.query","(","``","'","...","SELECT","uuid",",","...","json_extract","(","parameters",",","'","$",".accuracy","'",")","AS","accuracy",",","...","json_extract","(","parameters",",","'","$",".confusion_matrix","'",")","AS","cm","...","FROM","experiments","...","``","'",",","as_frame=True",")",">",">",">","results","=","tracker.query","(","``","'","...","SELECT","uuid",",","...","json_extract","(","parameters",",","'","$",".accuracy","'",")","AS","accuracy",",","...","json_extract","(","parameters",",","'","$",".confusion_matrix","'",")","AS","cm","...","FROM","experiments","...","``","'",",","as_frame=False",",","render_plots=True",")"]
code: def query(self, code, as_frame=True, render_plots=False):
      """Query the database
  
      Parameters
      ----------
      code : str
          The SQL query to execute
  
      as_frame : bool, default=True
          If True, it'll return the results of your query in a
          pandas.DataFrame, otherwise it'll return a Results object.
          The Results object can render HTML stored in the database but
          cannot be filtered or manipulated like a pandas.DataFrame
  
      render_plots: bool, default=False
          Whether to render plots in the results or not. Only valid when
          as_frame=False
  
      Examples
      --------
      >>> from sklearn_evaluation import SQLiteTracker
      >>> tracker = SQLiteTracker('experiments.db')
      >>> exp1 = tracker.new_experiment()
      >>> exp1.log("accuracy", 0.8) # doctest: +SKIP
      >>> exp1.log_confusion_matrix([1, 1, 0, 0], [1, 0, 1, 0]) # doctest: +SKIP
      >>> exp2 = tracker.new_experiment()
      >>> exp2.log("accuracy", 1.0) # doctest: +SKIP
      >>> exp2.log_confusion_matrix([1, 1, 0, 0], [1, 1, 0, 0]) # doctest: +SKIP
  
      >>> df = tracker.query('''
      ... SELECT uuid,
      ...        json_extract(parameters, '$.accuracy') AS accuracy,
      ...        json_extract(parameters, '$.confusion_matrix') AS cm
      ... FROM experiments
      ... ''', as_frame=True)
  
  
      >>> results = tracker.query('''
      ... SELECT uuid,
      ...        json_extract(parameters, '$.accuracy') AS accuracy,
      ...        json_extract(parameters, '$.confusion_matrix') AS cm
      ... FROM experiments
      ... ''', as_frame=False, render_plots=True)
      """
      if as_frame:
          df = pd.read_sql(code, self.conn)
  
          if "uuid" in df:
              df = df.set_index("uuid")
  
          return df
      else:
          cursor = self.conn.execute(code)
          columns = [d[0] for d in cursor.description]
          rows = cursor.fetchall()
          return Results(columns, rows, render_plots=render_plots)
  
imports: from collections.abc import Mapping
  from uuid import uuid4
  import sqlite3
  import json
  import importlib
  import pandas
  from jinja2 import Template
  from sklearn_evaluation.table import Table
  from sklearn_evaluation.report.serialize import try_serialize_figures, figure2html
  from sklearn_evaluation.telemetry import SKLearnEvaluationLogger
  from sklearn_evaluation.nb.NotebookCollection import add_compare_tab, tabs_html_from_content, HTMLMapping
  from sklearn_evaluation import plot
label_desc: Use image node_id 4 for calling the SQLiteTracker obj's underlying member method code with example usage: obj.query(code, as_frame, render_plots) and returns: df, Results