class_docstr: LED stream generator.
  
  This data source originates from the CART book [^1]. An implementation
  in C was donated to the UCI [^2] machine learning repository by David Aha.
  The goal is to predict the digit displayed on a seven-segment LED display,
  where each attribute has a 10% chance of being inverted. It has an optimal
  Bayes classification rate of 74%. The particular configuration of the
  generator used for experiments (LED) produces 24 binary attributes,
  17 of which are irrelevant.
  
  Parameters
  ----------
  seed
      Random seed for reproducibility.
  noise_percentage
      The probability that noise will happen in the generation. At each
      new sample generated, a random number is generated, and if it is equal
      or less than the noise_percentage, the led value  will be switched
  irrelevant_features
      Adds 17 non-relevant attributes to the stream.
  
  Examples
  --------
  >>> from river.datasets import synth
  
  >>> dataset = synth.LED(seed = 112, noise_percentage = 0.28, irrelevant_features= False)
  
  >>> for x, y in dataset.take(5):
  ...     print(x, y)
  {0: 1, 1: 0, 2: 1, 3: 0, 4: 0, 5: 1, 6: 0} 7
  {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 0} 8
  {0: 1, 1: 1, 2: 1, 3: 1, 4: 0, 5: 1, 6: 0} 9
  {0: 0, 1: 0, 2: 1, 3: 0, 4: 0, 5: 1, 6: 0} 1
  {0: 0, 1: 1, 2: 1, 3: 0, 4: 0, 5: 0, 6: 0} 1
  
  Notes
  -----
  An instance is generated based on the parameters passed. If `has_noise`
  is set then the total number of attributes will be 24, otherwise there will
  be 7 attributes.
  
  References
  ----------
  
  [^1]: Leo Breiman, Jerome Friedman, R. Olshen, and Charles J. Stone.
        Classification and Regression Trees. Wadsworth and Brooks,
        Monterey, CA,1984.
  
  [^2]: A. Asuncion and D. J. Newman. UCI Machine Learning Repository
        [http://www.ics.uci.edu/~mlearn/mlrepository.html].
        University of California, Irvine, School of Information and
        Computer Sciences,2007.
class_docstr_tok: ["LED","stream","generator",".","This","data","source","originates","from","the","CART","book","[","^1","]",".","An","implementation","in","C","was","donated","to","the","UCI","[","^2","]","machine","learning","repository","by","David","Aha",".","The","goal","is","to","predict","the","digit","displayed","on","a","seven-segment","LED","display",",","where","each","attribute","has","a","10","%","chance","of","being","inverted",".","It","has","an","optimal","Bayes","classification","rate","of","74","%",".","The","particular","configuration","of","the","generator","used","for","experiments","(","LED",")","produces","24","binary","attributes",",","17","of","which","are","irrelevant",".","Parameters","--","--","--","--","--","seed","Random","seed","for","reproducibility",".","noise_percentage","The","probability","that","noise","will","happen","in","the","generation",".","At","each","new","sample","generated",",","a","random","number","is","generated",",","and","if","it","is","equal","or","less","than","the","noise_percentage",",","the","led","value","will","be","switched","irrelevant_features","Adds","17","non-relevant","attributes","to","the","stream",".","Examples","--","--","--","--",">",">",">","from","river.datasets","import","synth",">",">",">","dataset","=","synth.LED","(","seed","=","112",",","noise_percentage","=","0.28",",","irrelevant_features=","False",")",">",">",">","for","x",",","y","in","dataset.take","(","5",")",":","...","print","(","x",",","y",")","{","0",":","1",",","1",":","0",",","2",":","1",",","3",":","0",",","4",":","0",",","5",":","1",",","6",":","0","}","7","{","0",":","1",",","1",":","1",",","2",":","1",",","3",":","1",",","4",":","1",",","5",":","1",",","6",":","0","}","8","{","0",":","1",",","1",":","1",",","2",":","1",",","3",":","1",",","4",":","0",",","5",":","1",",","6",":","0","}","9","{","0",":","0",",","1",":","0",",","2",":","1",",","3",":","0",",","4",":","0",",","5",":","1",",","6",":","0","}","1","{","0",":","0",",","1",":","1",",","2",":","1",",","3",":","0",",","4",":","0",",","5",":","0",",","6",":","0","}","1","Notes","--","--","-","An","instance","is","generated","based","on","the","parameters","passed",".","If","`","has_noise","`","is","set","then","the","total","number","of","attributes","will","be","24",",","otherwise","there","will","be","7","attributes",".","References","--","--","--","--","--","[","^1","]",":","Leo","Breiman",",","Jerome","Friedman",",","R.","Olshen",",","and","Charles","J",".","Stone",".","Classification","and","Regression","Trees",".","Wadsworth","and","Brooks",",","Monterey",",","CA,1984",".","[","^2","]",":","A.","Asuncion","and","D.","J.","Newman",".","UCI","Machine","Learning","Repository","[","http",":","\/\/www.ics.uci.edu\/~mlearn\/mlrepository.html","]",".","University","of","California",",","Irvine",",","School","of","Information","and","Computer","Sciences,2007","."]
code: def __iter__(self):
      self._rng = random.Random(self.seed)
  
      while True:
          x = dict()
          y = self._rng.randint(0, self.n_classes - 1)
  
          for i in range(self._N_RELEVANT_FEATURES):
              if (0.01 + self._rng.random()) <= self.noise_percentage:
                  x[i] = int(self._ORIGINAL_INSTANCES[y][i] == 0)
              else:
                  x[i] = self._ORIGINAL_INSTANCES[y][i]
  
          if self.irrelevant_features:
              for i in range(
                  self._N_RELEVANT_FEATURES,
                  self._N_FEATURES_INCLUDING_NOISE,
              ):
                  x[i] = self._rng.choice([0, 1])
  
          yield x, y
  
file_path: river/river/datasets/synth/led.py
imports: from __future__ import annotations
  import random
  from river import datasets
label_desc: Use image node_id 2 for calling the LED obj's underlying member method code with example usage: obj.__iter__() without return types