class_docstr: The numeric encoder takes numbers (float or integer) and converts it into tensors of the form:
  ``[0 if the number is none, otherwise 1, 1 if the number is positive, otherwise 0, natural_log(abs(number)), number/absolute_mean]``
  
  This representation is: ``[1 if the number is positive, otherwise 0, natural_log(abs(number)), number/absolute_mean]]`` if encoding target values, since target values can't be none.
  
  The ``absolute_mean`` is computed in the ``prepare`` method and is just the mean of the absolute values of all numbers feed to prepare (which are not none)
  
  ``none`` stands for any number that is an actual python ``None`` value or any sort of non-numeric value (a string, nan, inf)
class_docstr_tok: ["The","numeric","encoder","takes","numbers","(","float","or","integer",")","and","converts","it","into","tensors","of","the","form",":","``","[","0","if","the","number","is","none",",","otherwise","1",",","1","if","the","number","is","positive",",","otherwise","0",",","natural_log","(","abs","(","number",")",")",",","number\/absolute_mean","]","``","This","representation","is",":","``","[","1","if","the","number","is","positive",",","otherwise","0",",","natural_log","(","abs","(","number",")",")",",","number\/absolute_mean","]","]","``","if","encoding","target","values",",","since","target","values","ca","n't","be","none",".","The","``","absolute_mean","``","is","computed","in","the","``","prepare","``","method","and","is","just","the","mean","of","the","absolute","values","of","all","numbers","feed","to","prepare","(","which","are","not","none",")","``","none","``","stands","for","any","number","that","is","an","actual","python","``","None","``","value","or","any","sort","of","non-numeric","value","(","a","string",",","nan",",","inf",")"]
docstr: :param data: A pandas series or numpy array containing the numbers to be encoded
  :returns: A torch tensor with the representations of each number
docstr_tok: [":","param","data",":","A","pandas","series","or","numpy","array","containing","the","numbers","to","be","encoded",":","returns",":","A","torch","tensor","with","the","representations","of","each","number"]
code: def encode(self, data: Union[np.ndarray, pd.Series]):
      """
      :param data: A pandas series or numpy array containing the numbers to be encoded
      :returns: A torch tensor with the representations of each number
      """
      if not self.is_prepared:
          raise Exception(
              'You need to call "prepare" before calling "encode" or "decode".'
          )
  
      if isinstance(data, pd.Series):
          data = data.values
  
      inp_data = np.nan_to_num(
          data.astype(float),
          nan=0,
          posinf=np.finfo(np.float32).max,
          neginf=np.finfo(np.float32).min,
      )  # noqa
      if not self.positive_domain:
          sign = np.vectorize(self._sign_fn, otypes=[float])(inp_data)
      else:
          sign = np.zeros(len(data))
      log_value = np.vectorize(self._log_fn, otypes=[float])(inp_data)
      log_value = np.nan_to_num(log_value, nan=0, posinf=20, neginf=-20)
  
      norm = np.vectorize(self._norm_fn, otypes=[float])(inp_data)
      norm = np.nan_to_num(norm, nan=0, posinf=20, neginf=-20)
  
      if self.is_target:
          components = [sign, log_value, norm]
      else:
          nones = np.vectorize(self._none_fn, otypes=[float])(data)
          components = [sign, log_value, norm, nones]
  
      return torch.Tensor(np.asarray(components)).T
  
file_path: lightwood/lightwood/encoder/numeric/numeric.py
imports: import math
  from typing import Union
  import torch
  import numpy
  import pandas
  from type_infer.dtype import dtype
  from lightwood.encoder.base import BaseEncoder
  from lightwood.helpers.general import is_none
label_desc: Use image node_id 3 for calling the NumericEncoder obj's underlying member method code with example usage: obj.encode(data) and returns: torch