class_docstr: Agrawal stream generator.
  
  The generator was introduced by Agrawal et al. [^1], and was a common
  source of data for early work on scaling up decision tree learners.
  The generator produces a stream containing nine features, six numeric and
  three categorical.
  There are 10 functions defined for generating binary class labels from the
  features. Presumably these determine whether the loan should be approved.
  Classification functions are listed in the original paper [^1].
  
  **Feature** | **Description** | **Values**
  
  * `salary` | salary | uniformly distributed from 20k to 150k
  
  * `commission` | commission | 0 if `salary` < 75k else uniformly distributed from 10k to 75k
  
  * `age` | age | uniformly distributed from 20 to 80
  
  * `elevel` | education level | uniformly chosen from 0 to 4
  
  * `car` | car maker | uniformly chosen from 1 to 20
  
  * `zipcode` | zip code of the town | uniformly chosen from 0 to 8
  
  * `hvalue` | house value | uniformly distributed from 50k x zipcode to 100k x zipcode
  
  * `hyears` | years house owned | uniformly distributed from 1 to 30
  
  * `loan` | total loan amount | uniformly distributed from 0 to 500k
  
  Parameters
  ----------
  classification_function
      The classification function to use for the generation.
      Valid values are from 0 to 9.
  seed
      Random seed for reproducibility.
  balance_classes
      If True, the class distribution will converge to a uniform distribution.
  perturbation
      The probability that noise will happen in the generation. Each new
      sample will be perturbed by the magnitude of `perturbation`.
      Valid values are in the range [0.0 to 1.0].
  
  Examples
  --------
  
  >>> from river.datasets import synth
  
  >>> dataset = synth.Agrawal(
  ...     classification_function=0,
  ...     seed=42
  ... )
  
  >>> dataset
  Synthetic data generator
  <BLANKLINE>
      Name  Agrawal
      Task  Binary classification
   Samples  ∞
  Features  9
   Outputs  1
   Classes  2
    Sparse  False
  <BLANKLINE>
  Configuration
  -------------
  classification_function  0
                     seed  42
          balance_classes  False
             perturbation  0.0
  
  >>> for x, y in dataset.take(5):
  ...     print(list(x.values()), y)
  [103125.4837, 0, 21, 2, 8, 3, 319768.9642, 4, 338349.7437] 1
  [135983.3438, 0, 25, 4, 14, 0, 423837.7755, 7, 116330.4466] 1
  [98262.4347, 0, 55, 1, 18, 6, 144088.1244, 19, 139095.3541] 0
  [133009.0417, 0, 68, 1, 14, 5, 233361.4025, 7, 478606.5361] 1
  [63757.2908, 16955.9382, 26, 2, 12, 4, 522851.3093, 24, 229712.4398] 1
  
  Notes
  -----
  The sample generation works as follows: The 9 features are generated
  with the random generator, initialized with the seed passed by the
  user. Then, the classification function decides, as a function of all
  the attributes, whether to classify the instance as class 0 or class
  1. The next step is to verify if the classes should be balanced, and
  if so, balance the classes. Finally, add noise if `perturbation` > 0.0.
  
  References
  ----------
  [^1]: Rakesh Agrawal, Tomasz Imielinksi, and Arun Swami. "Database Mining:
        A Performance Perspective", IEEE Transactions on Knowledge and
        Data Engineering, 5(6), December 1993.
class_docstr_tok: ["Agrawal","stream","generator",".","The","generator","was","introduced","by","Agrawal","et","al",".","[","^1","]",",","and","was","a","common","source","of","data","for","early","work","on","scaling","up","decision","tree","learners",".","The","generator","produces","a","stream","containing","nine","features",",","six","numeric","and","three","categorical",".","There","are","10","functions","defined","for","generating","binary","class","labels","from","the","features",".","Presumably","these","determine","whether","the","loan","should","be","approved",".","Classification","functions","are","listed","in","the","original","paper","[","^1","]",".","*","*","Feature","*","*","|","*","*","Description","*","*","|","*","*","Values","*","*","*","`","salary","`","|","salary","|","uniformly","distributed","from","20k","to","150k","*","`","commission","`","|","commission","|","0","if","`","salary","`","<","75k","else","uniformly","distributed","from","10k","to","75k","*","`","age","`","|","age","|","uniformly","distributed","from","20","to","80","*","`","elevel","`","|","education","level","|","uniformly","chosen","from","0","to","4","*","`","car","`","|","car","maker","|","uniformly","chosen","from","1","to","20","*","`","zipcode","`","|","zip","code","of","the","town","|","uniformly","chosen","from","0","to","8","*","`","hvalue","`","|","house","value","|","uniformly","distributed","from","50k","x","zipcode","to","100k","x","zipcode","*","`","hyears","`","|","years","house","owned","|","uniformly","distributed","from","1","to","30","*","`","loan","`","|","total","loan","amount","|","uniformly","distributed","from","0","to","500k","Parameters","--","--","--","--","--","classification_function","The","classification","function","to","use","for","the","generation",".","Valid","values","are","from","0","to","9.","seed","Random","seed","for","reproducibility",".","balance_classes","If","True",",","the","class","distribution","will","converge","to","a","uniform","distribution",".","perturbation","The","probability","that","noise","will","happen","in","the","generation",".","Each","new","sample","will","be","perturbed","by","the","magnitude","of","`","perturbation","`",".","Valid","values","are","in","the","range","[","0.0","to","1.0","]",".","Examples","--","--","--","--",">",">",">","from","river.datasets","import","synth",">",">",">","dataset","=","synth.Agrawal","(","...","classification_function=0",",","...","seed=42","...",")",">",">",">","dataset","Synthetic","data","generator","<","BLANKLINE",">","Name","Agrawal","Task","Binary","classification","Samples","\u221e","Features","9","Outputs","1","Classes","2","Sparse","False","<","BLANKLINE",">","Configuration","--","--","--","--","--","--","-","classification_function","0","seed","42","balance_classes","False","perturbation","0.0",">",">",">","for","x",",","y","in","dataset.take","(","5",")",":","...","print","(","list","(","x.values","(",")",")",",","y",")","[","103125.4837",",","0",",","21",",","2",",","8",",","3",",","319768.9642",",","4",",","338349.7437","]","1","[","135983.3438",",","0",",","25",",","4",",","14",",","0",",","423837.7755",",","7",",","116330.4466","]","1","[","98262.4347",",","0",",","55",",","1",",","18",",","6",",","144088.1244",",","19",",","139095.3541","]","0","[","133009.0417",",","0",",","68",",","1",",","14",",","5",",","233361.4025",",","7",",","478606.5361","]","1","[","63757.2908",",","16955.9382",",","26",",","2",",","12",",","4",",","522851.3093",",","24",",","229712.4398","]","1","Notes","--","--","-","The","sample","generation","works","as","follows",":","The","9","features","are","generated","with","the","random","generator",",","initialized","with","the","seed","passed","by","the","user",".","Then",",","the","classification","function","decides",",","as","a","function","of","all","the","attributes",",","whether","to","classify","the","instance","as","class","0","or","class","1",".","The","next","step","is","to","verify","if","the","classes","should","be","balanced",",","and","if","so",",","balance","the","classes",".","Finally",",","add","noise","if","`","perturbation","`",">","0.0",".","References","--","--","--","--","--","[","^1","]",":","Rakesh","Agrawal",",","Tomasz","Imielinksi",",","and","Arun","Swami",".","``","Database","Mining",":","A","Performance","Perspective","''",",","IEEE","Transactions","on","Knowledge","and","Data","Engineering",",","5","(","6",")",",","December","1993","."]
code: def __init__(
      self,
      classification_function: int = 0,
      seed: int | None = None,
      balance_classes: bool = False,
      perturbation: float = 0.0,
  ):
      super().__init__(
          n_features=9,
          n_classes=2,
          n_outputs=1,
          task=datasets.base.BINARY_CLF,
      )
  
      # Classification functions to use
      self._classification_functions = [
          self._classification_function_0,
          self._classification_function_1,
          self._classification_function_2,
          self._classification_function_3,
          self._classification_function_4,
          self._classification_function_5,
          self._classification_function_6,
          self._classification_function_7,
          self._classification_function_8,
          self._classification_function_9,
      ]
      if classification_function not in range(10):
          raise ValueError(
              f"classification_function takes values from 0 to 9 "
              f"and {classification_function} was passed"
          )
      self.classification_function = classification_function
      self.balance_classes = balance_classes
      if not 0.0 <= perturbation <= 1.0:
          raise ValueError(
              f"noise percentage should be in [0.0..1.0] "
              f"and {perturbation} was passed"
          )
      self.perturbation = perturbation
      self.seed = seed
      self.n_num_features = 6
      self.n_cat_features = 3
      self._next_class_should_be_zero = False
      self.feature_names = [
          "salary",
          "commission",
          "age",
          "elevel",
          "car",
          "zipcode",
          "hvalue",
          "hyears",
          "loan",
      ]
      self.target_values = [i for i in range(self.n_classes)]
  
file_path: river/river/datasets/synth/agrawal.py
imports: from __future__ import annotations
  import random
  from river import datasets
label_desc: Use image node_id 1 to create a new Agrawal object from inherited base classes: datasets.base with example: obj = Agrawal(classification_function, seed, balance_classes, perturbation)