class_docstr: Random Tree generator.
  
  This generator is based on [^1]. The generator creates a random
  tree by splitting features at random and setting labels at its leaves.
  
  The tree structure is composed of node objects, which can be either inner
  nodes or leaf nodes. The choice comes as a function of the parameters
  passed to its initializer.
  
  Since the concepts are generated and classified according to a tree
  structure, in theory, it should favor decision tree learners.
  
  Parameters
  ----------
  seed_tree
      Seed for random generation of tree.
  seed_sample
      Seed for random generation of instances.
  n_classes
      The number of classes to generate.
  n_num_features
      The number of numerical features to generate.
  n_cat_features
      The number of categorical features to generate.
  n_categories_per_feature
      The number of values to generate per categorical feature.
  max_tree_depth
      The maximum depth of the tree concept.
  first_leaf_level
      The first level of the tree above `max_tree_depth` that can have leaves.
  fraction_leaves_per_level
      The fraction of leaves per level from `first_leaf_level` onwards.
  
  Examples
  --------
  
  >>> from river.datasets import synth
  
  >>> dataset = synth.RandomTree(seed_tree=42, seed_sample=42, n_classes=2,
  ...                            n_num_features=2, n_cat_features=2,
  ...                            n_categories_per_feature=2, max_tree_depth=6,
  ...                            first_leaf_level=3, fraction_leaves_per_level=0.15)
  
  >>> for x, y in dataset.take(5):
  ...     print(x, y)
  {'x_num_0': 0.6394, 'x_num_1': 0.0250, 'x_cat_0': 1, 'x_cat_1': 0} 0
  {'x_num_0': 0.2232, 'x_num_1': 0.7364, 'x_cat_0': 0, 'x_cat_1': 1} 1
  {'x_num_0': 0.0317, 'x_num_1': 0.0936, 'x_cat_0': 0, 'x_cat_1': 0} 0
  {'x_num_0': 0.5612, 'x_num_1': 0.7160, 'x_cat_0': 1, 'x_cat_1': 0} 0
  {'x_num_0': 0.4492, 'x_num_1': 0.2781, 'x_cat_0': 0, 'x_cat_1': 0} 0
  
  References
  ----------
  [^1]: Domingos, Pedro, and Geoff Hulten. "Mining high-speed data streams."
        In Proceedings of the sixth ACM SIGKDD international conference on
        Knowledge discovery and data mining, pp. 71-80. 2000.
class_docstr_tok: ["Random","Tree","generator",".","This","generator","is","based","on","[","^1","]",".","The","generator","creates","a","random","tree","by","splitting","features","at","random","and","setting","labels","at","its","leaves",".","The","tree","structure","is","composed","of","node","objects",",","which","can","be","either","inner","nodes","or","leaf","nodes",".","The","choice","comes","as","a","function","of","the","parameters","passed","to","its","initializer",".","Since","the","concepts","are","generated","and","classified","according","to","a","tree","structure",",","in","theory",",","it","should","favor","decision","tree","learners",".","Parameters","--","--","--","--","--","seed_tree","Seed","for","random","generation","of","tree",".","seed_sample","Seed","for","random","generation","of","instances",".","n_classes","The","number","of","classes","to","generate",".","n_num_features","The","number","of","numerical","features","to","generate",".","n_cat_features","The","number","of","categorical","features","to","generate",".","n_categories_per_feature","The","number","of","values","to","generate","per","categorical","feature",".","max_tree_depth","The","maximum","depth","of","the","tree","concept",".","first_leaf_level","The","first","level","of","the","tree","above","`","max_tree_depth","`","that","can","have","leaves",".","fraction_leaves_per_level","The","fraction","of","leaves","per","level","from","`","first_leaf_level","`","onwards",".","Examples","--","--","--","--",">",">",">","from","river.datasets","import","synth",">",">",">","dataset","=","synth.RandomTree","(","seed_tree=42",",","seed_sample=42",",","n_classes=2",",","...","n_num_features=2",",","n_cat_features=2",",","...","n_categories_per_feature=2",",","max_tree_depth=6",",","...","first_leaf_level=3",",","fraction_leaves_per_level=0.15",")",">",">",">","for","x",",","y","in","dataset.take","(","5",")",":","...","print","(","x",",","y",")","{","'x_num_0","'",":","0.6394",",","'x_num_1","'",":","0.0250",",","'x_cat_0","'",":","1",",","'x_cat_1","'",":","0","}","0","{","'x_num_0","'",":","0.2232",",","'x_num_1","'",":","0.7364",",","'x_cat_0","'",":","0",",","'x_cat_1","'",":","1","}","1","{","'x_num_0","'",":","0.0317",",","'x_num_1","'",":","0.0936",",","'x_cat_0","'",":","0",",","'x_cat_1","'",":","0","}","0","{","'x_num_0","'",":","0.5612",",","'x_num_1","'",":","0.7160",",","'x_cat_0","'",":","1",",","'x_cat_1","'",":","0","}","0","{","'x_num_0","'",":","0.4492",",","'x_num_1","'",":","0.2781",",","'x_cat_0","'",":","0",",","'x_cat_1","'",":","0","}","0","References","--","--","--","--","--","[","^1","]",":","Domingos",",","Pedro",",","and","Geoff","Hulten",".","``","Mining","high-speed","data","streams",".","''","In","Proceedings","of","the","sixth","ACM","SIGKDD","international","conference","on","Knowledge","discovery","and","data","mining",",","pp",".","71-80",".","2000","."]
code: def _classify_instance(self, node, x):
      if len(node.children) == 0:
          # Reached a leaf node
          return node.class_label
      feature = self.feature_names[node.split_feature_idx]
      if node.split_feature_idx < self.n_num_features:
          idx = 0 if x[feature] < node.split_feature_val else 1
          return self._classify_instance(node.children[idx], x)
      else:
          idx = x[feature]
          return self._classify_instance(node.children[idx], x)
  
file_path: river/river/datasets/synth/random_tree.py
imports: from __future__ import annotations
  import random
  from river import datasets
label_desc: Use image node_id 4 for calling the RandomTree obj's underlying member method code with example usage: obj._classify_instance(node, x) and returns: node, self, self