class_docstr: Transform a DataFrame into a dict useful for working with skorch.
  
  Transforms cardinal data to floats and categorical data to vectors
  of ints so that they can be embedded.
  
  Although skorch can deal with pandas DataFrames, the default
  behavior is often not very useful. Use this transformer to
  transform the DataFrame into a dict with all float columns
  concatenated using the key "X" and all categorical values encoded
  as integers, using their respective column names as keys.
  
  Your module must have a matching signature for this to work. It
  must accept an argument ``X`` for all cardinal
  values. Additionally, for all categorical values, it must accept
  an argument with the same name as the corresponding column (see
  example below). If you need help with the required signature, use
  the ``describe_signature`` method of this class and pass it your
  data.
  
  You can choose whether you want to treat int columns the same as
  float columns (default) or as categorical values.
  
  To one-hot encode categorical features, initialize their
  corresponding embedding layers using the identity matrix.
  
  Examples
  --------
  >>> df = pd.DataFrame({
  ...     'col_floats': np.linspace(0, 1, 12),
  ...     'col_ints': [11, 11, 10] * 4,
  ...     'col_cats': ['a', 'b', 'a'] * 4,
  ... })
  >>> # cast to category dtype to later learn embeddings
  >>> df['col_cats'] = df['col_cats'].astype('category')
  >>> y = np.asarray([0, 1, 0] * 4)
  
  >>> class MyModule(nn.Module):
  ...     def __init__(self):
  ...         super().__init__()
  ...         self.reset_params()
  
  >>>     def reset_params(self):
  ...         self.embedding = nn.Embedding(2, 10)
  ...         self.linear = nn.Linear(2, 10)
  ...         self.out = nn.Linear(20, 2)
  ...         self.nonlin = nn.Softmax(dim=-1)
  
  >>>     def forward(self, X, col_cats):
  ...         # "X" contains the values from col_floats and col_ints
  ...         # "col_cats" contains the values from "col_cats"
  ...         X_lin = self.linear(X)
  ...         X_cat = self.embedding(col_cats)
  ...         X_concat = torch.cat((X_lin, X_cat), dim=1)
  ...         return self.nonlin(self.out(X_concat))
  
  >>> net = NeuralNetClassifier(MyModule)
  >>> pipe = Pipeline([
  ...     ('transform', DataFrameTransformer()),
  ...     ('net', net),
  ... ])
  >>> pipe.fit(df, y)
  
  Parameters
  ----------
  treat_int_as_categorical : bool (default=False)
    Whether to treat integers as categorical values or as cardinal
    values, i.e. the same as floats.
  
  float_dtype : numpy dtype or None (default=np.float32)
    The dtype to cast the cardinal values to. If None, don't change
    them.
  
  int_dtype : numpy dtype or None (default=np.int64)
    The dtype to cast the categorical values to. If None, don't
    change them. If you do this, it can happen that the categorical
    values will have different dtypes, reflecting the number of
    unique categories.
  
  Notes
  -----
  The value of X will always be 2-dimensional, even if it only
  contains 1 column.
class_docstr_tok: ["Transform","a","DataFrame","into","a","dict","useful","for","working","with","skorch",".","Transforms","cardinal","data","to","floats","and","categorical","data","to","vectors","of","ints","so","that","they","can","be","embedded",".","Although","skorch","can","deal","with","pandas","DataFrames",",","the","default","behavior","is","often","not","very","useful",".","Use","this","transformer","to","transform","the","DataFrame","into","a","dict","with","all","float","columns","concatenated","using","the","key","``","X","''","and","all","categorical","values","encoded","as","integers",",","using","their","respective","column","names","as","keys",".","Your","module","must","have","a","matching","signature","for","this","to","work",".","It","must","accept","an","argument","``","X","``","for","all","cardinal","values",".","Additionally",",","for","all","categorical","values",",","it","must","accept","an","argument","with","the","same","name","as","the","corresponding","column","(","see","example","below",")",".","If","you","need","help","with","the","required","signature",",","use","the","``","describe_signature","``","method","of","this","class","and","pass","it","your","data",".","You","can","choose","whether","you","want","to","treat","int","columns","the","same","as","float","columns","(","default",")","or","as","categorical","values",".","To","one-hot","encode","categorical","features",",","initialize","their","corresponding","embedding","layers","using","the","identity","matrix",".","Examples","--","--","--","--",">",">",">","df","=","pd.DataFrame","(","{","...","'col_floats","'",":","np.linspace","(","0",",","1",",","12",")",",","...","'col_ints","'",":","[","11",",","11",",","10","]","*","4",",","...","'col_cats","'",":","[","'","a","'",",","'","b","'",",","'","a","'","]","*","4",",","...","}",")",">",">",">","#","cast","to","category","dtype","to","later","learn","embeddings",">",">",">","df","[","'col_cats","'","]","=","df","[","'col_cats","'","]",".astype","(","'category","'",")",">",">",">","y","=","np.asarray","(","[","0",",","1",",","0","]","*","4",")",">",">",">","class","MyModule","(","nn.Module",")",":","...","def","__init__","(","self",")",":","...","super","(",")",".__init__","(",")","...","self.reset_params","(",")",">",">",">","def","reset_params","(","self",")",":","...","self.embedding","=","nn.Embedding","(","2",",","10",")","...","self.linear","=","nn.Linear","(","2",",","10",")","...","self.out","=","nn.Linear","(","20",",","2",")","...","self.nonlin","=","nn.Softmax","(","dim=-1",")",">",">",">","def","forward","(","self",",","X",",","col_cats",")",":","...","#","``","X","''","contains","the","values","from","col_floats","and","col_ints","...","#","``","col_cats","''","contains","the","values","from","``","col_cats","''","...","X_lin","=","self.linear","(","X",")","...","X_cat","=","self.embedding","(","col_cats",")","...","X_concat","=","torch.cat","(","(","X_lin",",","X_cat",")",",","dim=1",")","...","return","self.nonlin","(","self.out","(","X_concat",")",")",">",">",">","net","=","NeuralNetClassifier","(","MyModule",")",">",">",">","pipe","=","Pipeline","(","[","...","(","'transform","'",",","DataFrameTransformer","(",")",")",",","...","(","'net","'",",","net",")",",","...","]",")",">",">",">","pipe.fit","(","df",",","y",")","Parameters","--","--","--","--","--","treat_int_as_categorical",":","bool","(","default=False",")","Whether","to","treat","integers","as","categorical","values","or","as","cardinal","values",",","i.e",".","the","same","as","floats",".","float_dtype",":","numpy","dtype","or","None","(","default=np.float32",")","The","dtype","to","cast","the","cardinal","values","to",".","If","None",",","do","n't","change","them",".","int_dtype",":","numpy","dtype","or","None","(","default=np.int64",")","The","dtype","to","cast","the","categorical","values","to",".","If","None",",","don't","change","them",".","If","you","do","this",",","it","can","happen","that","the","categorical","values","will","have","different","dtypes",",","reflecting","the","number","of","unique","categories",".","Notes","--","--","-","The","value","of","X","will","always","be","2-dimensional",",","even","if","it","only","contains","1","column","."]
docstr: Transform DataFrame to become a dict that works well with skorch.
  
  Parameters
  ----------
  df : pd.DataFrame
    Incoming DataFrame.
  
  Returns
  -------
  X_dict: dict
    Dictionary with all floats concatenated using the key "X"
    and all categorical values encoded as integers, using their
    respective column names as keys.
code: def transform(self, df):
      """Transform DataFrame to become a dict that works well with skorch.
  
      Parameters
      ----------
      df : pd.DataFrame
        Incoming DataFrame.
  
      Returns
      -------
      X_dict: dict
        Dictionary with all floats concatenated using the key "X"
        and all categorical values encoded as integers, using their
        respective column names as keys.
  
      """
      import pandas as pd
  
      self._check_dtypes(df)
  
      X_dict = {}
      Xf = []  # floats
  
      for col, dtype in zip(df, df.dtypes):
          X_col = df[col]
  
          if isinstance(dtype, pd.api.types.CategoricalDtype):
              x = X_col.cat.codes.values
              if self.int_dtype is not None:
                  x = x.astype(self.int_dtype)
              X_dict[col] = x
              continue
  
          if (
              np.issubdtype(dtype, np.integer)
              and self.treat_int_as_categorical
          ):
              x = X_col.astype("category").cat.codes.values
              if self.int_dtype is not None:
                  x = x.astype(self.int_dtype)
              X_dict[col] = x
              continue
  
          Xf.append(X_col.values)
  
      if not Xf:
          return X_dict
  
      X = np.stack(Xf, axis=1)
      if self.float_dtype is not None:
          X = X.astype(self.float_dtype)
      X_dict["X"] = X
      return X_dict
  
imports: from collections.abc import Sequence
  from functools import partial
  import numpy
  from sklearn.base import BaseEstimator
  from sklearn.base import TransformerMixin
  import torch
  from skorch._doctor import SkorchDoctor
  from skorch.cli import parse_args
  from skorch.utils import _make_split
  from skorch.utils import to_numpy
  from skorch.utils import is_torch_data_type
  from skorch.utils import to_tensor
label_desc: Use image node_id 4 for calling the DataFrameTransformer obj's underlying member method code with example usage: obj.transform(df) and returns: X_dict, X_dict