class_docstr: Converts an input dataframe to another dataframe in libffm format. A text file of the converted
  Dataframe is optionally generated.
  
  .. note::
  
      The input dataframe is expected to represent the feature data in the following schema:
  
      .. code-block:: python
  
          |field-1|field-2|...|field-n|rating|
          |feature-1-1|feature-2-1|...|feature-n-1|1|
          |feature-1-2|feature-2-2|...|feature-n-2|0|
          ...
          |feature-1-i|feature-2-j|...|feature-n-k|0|
  
      Where
      1. each `field-*` is the column name of the dataframe (column of label/rating is excluded), and
      2. `feature-*-*` can be either a string or a numerical value, representing the categorical variable or
      actual numerical variable of the feature value in the field, respectively.
      3. If there are ordinal variables represented in int types, users should make sure these columns
      are properly converted to string type.
  
      The above data will be converted to the libffm format by following the convention as explained in
      `this paper <https://www.csie.ntu.edu.tw/~r01922136/slides/ffm.pdf>`_.
  
      i.e. `<field_index>:<field_feature_index>:1` or `<field_index>:<field_feature_index>:<field_feature_value>`,
      depending on the data type of the features in the original dataframe.
  
  Args:
      filepath (str): path to save the converted data.
  
  Attributes:
      field_count (int): count of field in the libffm format data
      feature_count (int): count of feature in the libffm format data
      filepath (str or None): file path where the output is stored - it can be None or a string
  
  Examples:
      >>> import pandas as pd
      >>> df_feature = pd.DataFrame({
              'rating': [1, 0, 0, 1, 1],
              'field1': ['xxx1', 'xxx2', 'xxx4', 'xxx4', 'xxx4'],
              'field2': [3, 4, 5, 6, 7],
              'field3': [1.0, 2.0, 3.0, 4.0, 5.0],
              'field4': ['1', '2', '3', '4', '5']
          })
      >>> converter = LibffmConverter().fit(df_feature, col_rating='rating')
      >>> df_out = converter.transform(df_feature)
      >>> df_out
          rating field1 field2   field3 field4
      0       1  1:1:1  2:4:3  3:5:1.0  4:6:1
      1       0  1:2:1  2:4:4  3:5:2.0  4:7:1
      2       0  1:3:1  2:4:5  3:5:3.0  4:8:1
      3       1  1:3:1  2:4:6  3:5:4.0  4:9:1
      4       1  1:3:1  2:4:7  3:5:5.0  4:10:1
class_docstr_tok: ["Converts","an","input","dataframe","to","another","dataframe","in","libffm","format",".","A","text","file","of","the","converted","Dataframe","is","optionally","generated",".","..","note",":",":","The","input","dataframe","is","expected","to","represent","the","feature","data","in","the","following","schema",":","..","code-block",":",":","python","|field-1|field-2|","...","|field-n|rating|","|feature-1-1|feature-2-1|","...","|feature-n-1|1|","|feature-1-2|feature-2-2|","...","|feature-n-2|0|","...","|feature-1-i|feature-2-j|","...","|feature-n-k|0|","Where","1.","each","`","field-","*","`","is","the","column","name","of","the","dataframe","(","column","of","label\/rating","is","excluded",")",",","and","2",".","`","feature-","*","-","*","`","can","be","either","a","string","or","a","numerical","value",",","representing","the","categorical","variable","or","actual","numerical","variable","of","the","feature","value","in","the","field",",","respectively",".","3",".","If","there","are","ordinal","variables","represented","in","int","types",",","users","should","make","sure","these","columns","are","properly","converted","to","string","type",".","The","above","data","will","be","converted","to","the","libffm","format","by","following","the","convention","as","explained","in","`","this","paper","<","https",":","\/\/www.csie.ntu.edu.tw\/~r01922136\/slides\/ffm.pdf",">","`","_",".","i.e",".","`","<","field_index",">",":","<","field_feature_index",">",":1","`","or","`","<","field_index",">",":","<","field_feature_index",">",":","<","field_feature_value",">","`",",","depending","on","the","data","type","of","the","features","in","the","original","dataframe",".","Args",":","filepath","(","str",")",":","path","to","save","the","converted","data",".","Attributes",":","field_count","(","int",")",":","count","of","field","in","the","libffm","format","data","feature_count","(","int",")",":","count","of","feature","in","the","libffm","format","data","filepath","(","str","or","None",")",":","file","path","where","the","output","is","stored","-","it","can","be","None","or","a","string","Examples",":",">",">",">","import","pandas","as","pd",">",">",">","df_feature","=","pd.DataFrame","(","{","'rating","'",":","[","1",",","0",",","0",",","1",",","1","]",",","'field1","'",":","[","'xxx1","'",",","'xxx2","'",",","'xxx4","'",",","'xxx4","'",",","'xxx4","'","]",",","'field2","'",":","[","3",",","4",",","5",",","6",",","7","]",",","'field3","'",":","[","1.0",",","2.0",",","3.0",",","4.0",",","5.0","]",",","'field4","'",":","[","'","1","'",",","'","2","'",",","'","3","'",",","'","4","'",",","'","5","'","]","}",")",">",">",">","converter","=","LibffmConverter","(",")",".fit","(","df_feature",",","col_rating='rating","'",")",">",">",">","df_out","=","converter.transform","(","df_feature",")",">",">",">","df_out","rating","field1","field2","field3","field4","0","1","1:1:1","2:4:3","3:5:1.0","4:6:1","1","0","1:2:1","2:4:4","3:5:2.0","4:7:1","2","0","1:3:1","2:4:5","3:5:3.0","4:8:1","3","1","1:3:1","2:4:6","3:5:4.0","4:9:1","4","1","1:3:1","2:4:7","3:5:5.0","4:10:1"]
docstr: Get parameters (attributes) of the libffm converter
  
  Return:
      dict: A dictionary that contains parameters field count, feature count, and file path.
docstr_tok: ["Get","parameters","(","attributes",")","of","the","libffm","converter","Return",":","dict",":","A","dictionary","that","contains","parameters","field","count",",","feature","count",",","and","file","path","."]
code: def get_params(self):
      """Get parameters (attributes) of the libffm converter
  
      Return:
          dict: A dictionary that contains parameters field count, feature count, and file path.
      """
      return {
          "field count": self.field_count,
          "feature count": self.feature_count,
          "file path": self.filepath,
      }
  
imports: import logging
  import pandas
  import numpy
  from functools import lru_cache, wraps
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_LABEL_COL
label_desc: Use image node_id 5 for calling the LibffmConverter obj's underlying member method code with example usage: obj.get_params() and returns: dict