class_docstr: A multivariate hashing implementation with configurable dimensionality/precision.
  
  The advantage of this encoder is that it does not maintain a dictionary of observed categories.
  Consequently, the encoder does not grow in size and accepts new values during data scoring
  by design.
  
  It's important to read about how max_process & max_sample work
  before setting them manually, inappropriate setting slows down encoding.
  
  Default value of 'max_process' is 1 on Windows because multiprocessing might cause issues, see in :
  https://github.com/scikit-learn-contrib/categorical-encoding/issues/215
  https://docs.python.org/2/library/multiprocessing.html?highlight=process#windows
  
  Parameters
  ----------
  
  verbose: int
      integer indicating verbosity of the output. 0 for none.
  cols: list
      a list of columns to encode, if None, all string columns will be encoded.
  drop_invariant: bool
      boolean for whether or not to drop columns with 0 variance.
  return_df: bool
      boolean for whether to return a pandas DataFrame from transform (otherwise it will be a numpy array).
  hash_method: str
      which hashing method to use. Any method from hashlib works.
  max_process: int
      how many processes to use in transform(). Limited in range(1, 64).
      By default, it uses half of the logical CPUs.
      For example, 4C4T makes max_process=2, 4C8T makes max_process=4.
      Set it larger if you have a strong CPU.
      It is not recommended to set it larger than is the count of the
      logical CPUs as it will actually slow down the encoding.
  max_sample: int
      how many samples to encode by each process at a time.
      This setting is useful on low memory machines.
      By default, max_sample=(all samples num)/(max_process).
      For example, 4C8T CPU with 100,000 samples makes max_sample=25,000,
      6C12T CPU with 100,000 samples makes max_sample=16,666.
      It is not recommended to set it larger than the default value.
  n_components: int
      how many bits to use to represent the feature. By default, we use 8 bits.
      For high-cardinality features, consider using up-to 32 bits.
  process_creation_method: string
      either "fork", "spawn" or "forkserver" (availability depends on your 
      platform). See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
      for more details and tradeoffs. Defaults to "fork" on linux/macos as it
      is the fastest option and to "spawn" on windows as it is the only one
      available
  
  Example
  -------
  >>> from category_encoders.hashing import HashingEncoder
  >>> import pandas as pd
  >>> from sklearn.datasets import fetch_openml
  >>> bunch = fetch_openml(name="house_prices", as_frame=True)
  >>> display_cols = ["Id", "MSSubClass", "MSZoning", "LotFrontage", "YearBuilt", "Heating", "CentralAir"]
  >>> X = pd.DataFrame(bunch.data, columns=bunch.feature_names)[display_cols]
  >>> y = bunch.target
  >>> he = HashingEncoder(cols=['CentralAir', 'Heating']).fit(X, y)
  >>> numeric_dataset = he.transform(X)
  >>> print(numeric_dataset.info())
  <class 'pandas.core.frame.DataFrame'>
  RangeIndex: 1460 entries, 0 to 1459
  Data columns (total 13 columns):
   #   Column       Non-Null Count  Dtype  
  ---  ------       --------------  -----  
   0   col_0        1460 non-null   int64  
   1   col_1        1460 non-null   int64  
   2   col_2        1460 non-null   int64  
   3   col_3        1460 non-null   int64  
   4   col_4        1460 non-null   int64  
   5   col_5        1460 non-null   int64  
   6   col_6        1460 non-null   int64  
   7   col_7        1460 non-null   int64  
   8   Id           1460 non-null   float64
   9   MSSubClass   1460 non-null   float64
   10  MSZoning     1460 non-null   object 
   11  LotFrontage  1201 non-null   float64
   12  YearBuilt    1460 non-null   float64
  dtypes: float64(4), int64(8), object(1)
  memory usage: 148.4+ KB
  None
  
  References
  ----------
  .. [1] Feature Hashing for Large Scale Multitask Learning, from
  https://alex.smola.org/papers/2009/Weinbergeretal09.pdf
  .. [2] Don't be tricked by the Hashing Trick, from
  https://booking.ai/dont-be-tricked-by-the-hashing-trick-192a6aae3087
class_docstr_tok: ["A","multivariate","hashing","implementation","with","configurable","dimensionality\/precision",".","The","advantage","of","this","encoder","is","that","it","does","not","maintain","a","dictionary","of","observed","categories",".","Consequently",",","the","encoder","does","not","grow","in","size","and","accepts","new","values","during","data","scoring","by","design",".","It","'s","important","to","read","about","how","max_process","&","max_sample","work","before","setting","them","manually",",","inappropriate","setting","slows","down","encoding",".","Default","value","of","'max_process","'","is","1","on","Windows","because","multiprocessing","might","cause","issues",",","see","in",":","https",":","\/\/github.com\/scikit-learn-contrib\/categorical-encoding\/issues\/215","https",":","\/\/docs.python.org\/2\/library\/multiprocessing.html","?","highlight=process","#","windows","Parameters","--","--","--","--","--","verbose",":","int","integer","indicating","verbosity","of","the","output",".","0","for","none",".","cols",":","list","a","list","of","columns","to","encode",",","if","None",",","all","string","columns","will","be","encoded",".","drop_invariant",":","bool","boolean","for","whether","or","not","to","drop","columns","with","0","variance",".","return_df",":","bool","boolean","for","whether","to","return","a","pandas","DataFrame","from","transform","(","otherwise","it","will","be","a","numpy","array",")",".","hash_method",":","str","which","hashing","method","to","use",".","Any","method","from","hashlib","works",".","max_process",":","int","how","many","processes","to","use","in","transform","(",")",".","Limited","in","range","(","1",",","64",")",".","By","default",",","it","uses","half","of","the","logical","CPUs",".","For","example",",","4C4T","makes","max_process=2",",","4C8T","makes","max_process=4",".","Set","it","larger","if","you","have","a","strong","CPU",".","It","is","not","recommended","to","set","it","larger","than","is","the","count","of","the","logical","CPUs","as","it","will","actually","slow","down","the","encoding",".","max_sample",":","int","how","many","samples","to","encode","by","each","process","at","a","time",".","This","setting","is","useful","on","low","memory","machines",".","By","default",",","max_sample=","(","all","samples","num",")","\/","(","max_process",")",".","For","example",",","4C8T","CPU","with","100,000","samples","makes","max_sample=25,000",",","6C12T","CPU","with","100,000","samples","makes","max_sample=16,666",".","It","is","not","recommended","to","set","it","larger","than","the","default","value",".","n_components",":","int","how","many","bits","to","use","to","represent","the","feature",".","By","default",",","we","use","8","bits",".","For","high-cardinality","features",",","consider","using","up-to","32","bits",".","process_creation_method",":","string","either","``","fork","''",",","``","spawn","''","or","``","forkserver","''","(","availability","depends","on","your","platform",")",".","See","https",":","\/\/docs.python.org\/3\/library\/multiprocessing.html","#","contexts-and-start-methods","for","more","details","and","tradeoffs",".","Defaults","to","``","fork","''","on","linux\/macos","as","it","is","the","fastest","option","and","to","``","spawn","''","on","windows","as","it","is","the","only","one","available","Example","--","--","--","-",">",">",">","from","category_encoders.hashing","import","HashingEncoder",">",">",">","import","pandas","as","pd",">",">",">","from","sklearn.datasets","import","fetch_openml",">",">",">","bunch","=","fetch_openml","(","name=","''","house_prices","''",",","as_frame=True",")",">",">",">","display_cols","=","[","``","Id","''",",","``","MSSubClass","''",",","``","MSZoning","''",",","``","LotFrontage","''",",","``","YearBuilt","''",",","``","Heating","''",",","``","CentralAir","''","]",">",">",">","X","=","pd.DataFrame","(","bunch.data",",","columns=bunch.feature_names",")","[","display_cols","]",">",">",">","y","=","bunch.target",">",">",">","he","=","HashingEncoder","(","cols=","[","'CentralAir","'",",","'Heating","'","]",")",".fit","(","X",",","y",")",">",">",">","numeric_dataset","=","he.transform","(","X",")",">",">",">","print","(","numeric_dataset.info","(",")",")","<","class","'pandas.core.frame.DataFrame","'",">","RangeIndex",":","1460","entries",",","0","to","1459","Data","columns","(","total","13","columns",")",":","#","Column","Non-Null","Count","Dtype","--","-","--","--","--","--","--","--","--","--","--","--","--","--","-","0","col_0","1460","non-null","int64","1","col_1","1460","non-null","int64","2","col_2","1460","non-null","int64","3","col_3","1460","non-null","int64","4","col_4","1460","non-null","int64","5","col_5","1460","non-null","int64","6","col_6","1460","non-null","int64","7","col_7","1460","non-null","int64","8","Id","1460","non-null","float64","9","MSSubClass","1460","non-null","float64","10","MSZoning","1460","non-null","object","11","LotFrontage","1201","non-null","float64","12","YearBuilt","1460","non-null","float64","dtypes",":","float64","(","4",")",",","int64","(","8",")",",","object","(","1",")","memory","usage",":","148.4+","KB","None","References","--","--","--","--","--","..","[","1","]","Feature","Hashing","for","Large","Scale","Multitask","Learning",",","from","https",":","\/\/alex.smola.org\/papers\/2009\/Weinbergeretal09.pdf","..","[","2","]","Do","n't","be","tricked","by","the","Hashing","Trick",",","from","https",":","\/\/booking.ai\/dont-be-tricked-by-the-hashing-trick-192a6aae3087"]
code: def __init__(
      self,
      max_process=0,
      max_sample=0,
      verbose=0,
      n_components=8,
      cols=None,
      drop_invariant=False,
      return_df=True,
      hash_method="md5",
      process_creation_method="fork",
  ):
      super().__init__(
          verbose=verbose,
          cols=cols,
          drop_invariant=drop_invariant,
          return_df=return_df,
          handle_unknown="does not apply",
          handle_missing="does not apply",
      )
  
      if max_process not in range(1, 128):
          if platform.system() == "Windows":
              self.max_process = 1
          else:
              self.max_process = int(
                  math.ceil(multiprocessing.cpu_count() / 2)
              )
              if self.max_process < 1:
                  self.max_process = 1
              elif self.max_process > 128:
                  self.max_process = 128
      else:
          self.max_process = max_process
      self.max_sample = int(max_sample)
      if platform.system() == "Windows":
          self.process_creation_method = "spawn"
      else:
          self.process_creation_method = process_creation_method
      self.data_lines = 0
      self.X = None
  
      self.n_components = n_components
      self.hash_method = hash_method
  
file_path: category_encoders/category_encoders/hashing.py
imports: import hashlib
  import category_encoders.utils
  import multiprocessing
  import pandas
  import numpy
  import math
  import platform
  from concurrent.futures import ProcessPoolExecutor
label_desc: Use image node_id 1 to create a new HashingEncoder object from inherited base classes: util, util with example: obj = HashingEncoder(max_process, max_sample, verbose, n_components, cols, drop_invariant, return_df, hash_method, process_creation_method)