class_docstr: Robust random cut tree data structure as described in:
  
  S. Guha, N. Mishra, G. Roy, & O. Schrijvers. Robust random cut forest based anomaly
  detection on streams, in Proceedings of the 33rd International conference on machine
  learning, New York, NY, 2016 (pp. 2712-2721).
  
  Parameters:
  -----------
  X: np.ndarray (n x d) (optional)
     Array containing n data points, each with dimension d.
     If no data provided, an empty tree is created.
  index_labels: sequence of length n (optional) (default=None)
                Labels for data points provided in X.
                Defaults to [0, 1, ... n-1].
  precision: float (optional) (default=9)
             Floating-point precision for distinguishing duplicate points.
  random_state: int, RandomState instance or None (optional) (default=None)
      If int, random_state is the seed used by the random number generator;
      If RandomState instance, random_state is the random number generator;
      If None, the random number generator is the RandomState instance used by np.random.
  
  Attributes:
  -----------
  root: Branch or Leaf instance
        Pointer to root of tree.
  leaves: dict
          Dict containing pointers to all leaves in tree.
  ndim: int
        dimension of points in the tree
  
  Methods:
  --------
  insert_point: inserts a new point into the tree.
  forget_point: removes a point from the tree.
  disp: compute displacement associated with the removal of a leaf.
  codisp: compute collusive displacement associated with the removal of a leaf
          (anomaly score).
  map_leaves: traverses all nodes in the tree and executes a user-specified
              function on the leaves.
  map_branches: traverses all nodes in the tree and executes a user-specified
                function on the branches.
  query: finds nearest point in tree.
  get_bbox: find bounding box of points under a given node.
  find_duplicate: finds duplicate points in the tree.
  
  Example:
  --------
  # Create RCTree
  >>> X = np.random.randn(100,2)
  >>> tree = RCTree(X)
  
  # Insert a point
  >>> x = np.random.randn(2)
  >>> tree.insert_point(x, index=100)
  
  # Compute collusive displacement of new point (anomaly score)
  >>> tree.codisp(100)
  
  # Remove point
  >>> tree.forget_point(100)
class_docstr_tok: ["Robust","random","cut","tree","data","structure","as","described","in",":","S.","Guha",",","N.","Mishra",",","G.","Roy",",","&","O.","Schrijvers",".","Robust","random","cut","forest","based","anomaly","detection","on","streams",",","in","Proceedings","of","the","33rd","International","conference","on","machine","learning",",","New","York",",","NY",",","2016","(","pp",".","2712-2721",")",".","Parameters",":","--","--","--","--","--","-","X",":","np.ndarray","(","n","x","d",")","(","optional",")","Array","containing","n","data","points",",","each","with","dimension","d.","If","no","data","provided",",","an","empty","tree","is","created",".","index_labels",":","sequence","of","length","n","(","optional",")","(","default=None",")","Labels","for","data","points","provided","in","X.","Defaults","to","[","0",",","1",",","...","n-1","]",".","precision",":","float","(","optional",")","(","default=9",")","Floating-point","precision","for","distinguishing","duplicate","points",".","random_state",":","int",",","RandomState","instance","or","None","(","optional",")","(","default=None",")","If","int",",","random_state","is","the","seed","used","by","the","random","number","generator",";","If","RandomState","instance",",","random_state","is","the","random","number","generator",";","If","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","np.random",".","Attributes",":","--","--","--","--","--","-","root",":","Branch","or","Leaf","instance","Pointer","to","root","of","tree",".","leaves",":","dict","Dict","containing","pointers","to","all","leaves","in","tree",".","ndim",":","int","dimension","of","points","in","the","tree","Methods",":","--","--","--","--","insert_point",":","inserts","a","new","point","into","the","tree",".","forget_point",":","removes","a","point","from","the","tree",".","disp",":","compute","displacement","associated","with","the","removal","of","a","leaf",".","codisp",":","compute","collusive","displacement","associated","with","the","removal","of","a","leaf","(","anomaly","score",")",".","map_leaves",":","traverses","all","nodes","in","the","tree","and","executes","a","user-specified","function","on","the","leaves",".","map_branches",":","traverses","all","nodes","in","the","tree","and","executes","a","user-specified","function","on","the","branches",".","query",":","finds","nearest","point","in","tree",".","get_bbox",":","find","bounding","box","of","points","under","a","given","node",".","find_duplicate",":","finds","duplicate","points","in","the","tree",".","Example",":","--","--","--","--","#","Create","RCTree",">",">",">","X","=","np.random.randn","(","100,2",")",">",">",">","tree","=","RCTree","(","X",")","#","Insert","a","point",">",">",">","x","=","np.random.randn","(","2",")",">",">",">","tree.insert_point","(","x",",","index=100",")","#","Compute","collusive","displacement","of","new","point","(","anomaly","score",")",">",">",">","tree.codisp","(","100",")","#","Remove","point",">",">",">","tree.forget_point","(","100",")"]
docstr: Deserializes a nested dict representing an RCTree and loads into the RCTree
  instance. Note that this will delete all data in the current RCTree and
  replace it with the loaded data.
  
  Parameters:
  -----------
  obj: dict
       Nested dictionary representing all nodes in the RCTree.
  
  Example:
  --------
  # Load dict (see to_dict method for more info)
  >>> import json
  >>> with open('tree.json', 'r') as infile:
          obj = json.load(infile)
  
  # Create empty RCTree and load data
  >>> tree = rrcf.RCTree()
  >>> tree.load_dict(obj)
  
  # View loaded data
  >>> print(tree)
  >>>
  ─+
  ├───+
  │   ├──(3)
  │   └───+
  │       ├──(2)
  │       └──(0)
  └──(1)
docstr_tok: ["Deserializes","a","nested","dict","representing","an","RCTree","and","loads","into","the","RCTree","instance",".","Note","that","this","will","delete","all","data","in","the","current","RCTree","and","replace","it","with","the","loaded","data",".","Parameters",":","--","--","--","--","--","-","obj",":","dict","Nested","dictionary","representing","all","nodes","in","the","RCTree",".","Example",":","--","--","--","--","#","Load","dict","(","see","to_dict","method","for","more","info",")",">",">",">","import","json",">",">",">","with","open","(","'tree.json","'",",","'","r","'",")","as","infile",":","obj","=","json.load","(","infile",")","#","Create","empty","RCTree","and","load","data",">",">",">","tree","=","rrcf.RCTree","(",")",">",">",">","tree.load_dict","(","obj",")","#","View","loaded","data",">",">",">","print","(","tree",")",">",">",">","\u2500+","\u251c\u2500\u2500\u2500+","\u2502","\u251c\u2500\u2500","(","3",")","\u2502","\u2514\u2500\u2500\u2500+","\u2502","\u251c\u2500\u2500","(","2",")","\u2502","\u2514\u2500\u2500","(","0",")","\u2514\u2500\u2500","(","1",")"]
code: def load_dict(self, obj):
      """
      Deserializes a nested dict representing an RCTree and loads into the RCTree
      instance. Note that this will delete all data in the current RCTree and
      replace it with the loaded data.
  
      Parameters:
      -----------
      obj: dict
           Nested dictionary representing all nodes in the RCTree.
  
      Example:
      --------
      # Load dict (see to_dict method for more info)
      >>> import json
      >>> with open('tree.json', 'r') as infile:
              obj = json.load(infile)
  
      # Create empty RCTree and load data
      >>> tree = rrcf.RCTree()
      >>> tree.load_dict(obj)
  
      # View loaded data
      >>> print(tree)
      >>>
      ─+
      ├───+
      │   ├──(3)
      │   └───+
      │       ├──(2)
      │       └──(0)
      └──(1)
      """
      # Create anchor node
      anchor = Branch(q=None, p=None)
      # Create dictionary for restoring duplicates
      duplicates = {}
      # Deserialize json object
      self._deserialize(obj, anchor, duplicates)
      # Get root node
      root = anchor.l
      root.u = None
      # Fill in leaves dict
      leaves = {}
      for k, v in duplicates.items():
          for i in v:
              leaves[i] = k
      # Set root of tree to new root
      self.root = root
      self.leaves = leaves
      # Set number of dimensions based on first leaf
      self.ndim = len(next(iter(leaves.values())).x)
  
imports: import numpy
label_desc: Use image node_id 18 for calling the RCTree obj's underlying member method code with example usage: obj.load_dict(obj) without return types