config.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. class CustConfig:
  2. FEATURE_COLUMNS = [
  3. "BB_RETAIL_CUSTOMER_CODE", # 零售户代码
  4. "BB_RTL_CUST_POSITION_TYPE_NAME", # 零售户商圈类型名称
  5. "BB_RTL_CUST_MARKET_TYPE_NAME", # 零售户市场类型名称
  6. # "BB_RTL_CUST_BUSINESS_TYPE_NAME", # 零售户业态名称
  7. "BB_RTL_CUST_SUB_BUSI_PLACE_NAME", # 零售户业态细分名称
  8. "BB_RTL_CUST_GRADE_NAME", # 零售户分档名称
  9. # "BB_RTL_CUST_TERMINAL_LEVEL_NAME", # 零售户终端层级名称
  10. # "BB_RTL_CUST_TERMINALEVEL_NAME", # 零售户终端层级细分名称
  11. # "MD04_MG_RTL_CUST_CREDITCLASS_NAME", # 零售户信用等级名称
  12. # "MD04_MG_SAMPLE_CUST_FLAG", # 样本户标识
  13. # "MD07_RTL_CUST_IS_SALE_LARGE_FLAG", # 零售户大户标识
  14. # "BB_CUSTOMER_MANAGER_SCOPE_NAME", # 零售户经营范围名称
  15. # "BB_RTL_CUST_OPERATE_METHOD_NAME", # 零售户经营方式名称
  16. # "BB_RTL_CUST_CGT_OPERATE_SCOPE_NAME", # 零售户卷烟经营规模名称
  17. "BB_RTL_CUST_CHAIN_FLAG", # 零售户连锁标识
  18. "MD04_DIR_SAL_STORE_FLAG", # 直营店标识
  19. "STORE_AREA", # 店铺经营面积
  20. "OPERATOR_AGE", # 经营者年龄
  21. "OPERATOR_EDU_LEVEL", # 零售客户经营者文化程
  22. # "AVERAGE_CONSUMER_FLOW", # 月均消费人流
  23. # "NEW_PRODUCT_MEMBERS_QTY", # 新品消费会员数量
  24. ]
  25. # 数据清洗规则
  26. CLEANING_RULES = {
  27. "BB_RTL_CUST_POSITION_TYPE_NAME": {"method": "fillna", "opt": "fill", "value": "其他", "type": "str"},
  28. "BB_RTL_CUST_MARKET_TYPE_NAME": {"method": "fillna", "opt": "fill", "value": "城网", "type": "str"},
  29. "BB_RTL_CUST_SUB_BUSI_PLACE_NAME": {"method": "fillna", "opt": "fill", "value": "其他", "type": "str"},
  30. "BB_RTL_CUST_GRADE_NAME": {"method": "fillna", "opt": "fill", "value": "十五档", "type": "str"},
  31. # "BB_RTL_CUST_TERMINALEVEL_NAME": {"method": "fillna", "opt": "replace", "value": "BB_RTL_CUST_TERMINAL_LEVEL_NAME", "type": "str"},
  32. # "MD04_MG_RTL_CUST_CREDITCLASS_NAME": {"method": "fillna", "opt": "fill", "value": "未评价", "type": "str"},
  33. # "MD04_MG_SAMPLE_CUST_FLAG": {"method": "fillna", "value": "N", "opt": "fill"},
  34. # "MD07_RTL_CUST_IS_SALE_LARGE_FLAG": {"method": "fillna", "value": "N", "opt": "fill"},
  35. # "BB_RTL_CUST_CGT_OPERATE_SCOPE_NAME": {"method": "fillna", "value": "中", "opt": "fill"},
  36. "BB_RTL_CUST_CHAIN_FLAG": {"method": "fillna", "opt": "fill", "value": "否", "type": "str"},
  37. "MD04_DIR_SAL_STORE_FLAG": {"method": "fillna", "opt": "fill", "value": "否", "type": "str"},
  38. "STORE_AREA": {"method": "fillna", "opt": "mean", "type": "num"},
  39. "OPERATOR_AGE": {"method": "fillna", "opt": "mean", "type": "num"},
  40. "OPERATOR_EDU_LEVEL": {"method": "fillna", "opt": "fill", "value": "01", "type": "str"},
  41. }
  42. # one-hot编码
  43. ONEHOT = [
  44. "BB_RTL_CUST_POSITION_TYPE_NAME",
  45. "BB_RTL_CUST_MARKET_TYPE_NAME",
  46. "BB_RTL_CUST_SUB_BUSI_PLACE_NAME",
  47. "BB_RTL_CUST_GRADE_NAME",
  48. "BB_RTL_CUST_CHAIN_FLAG",
  49. "MD04_DIR_SAL_STORE_FLAG",
  50. "OPERATOR_EDU_LEVEL",
  51. ]
  52. ONEHOT_CAT = {
  53. "BB_RTL_CUST_POSITION_TYPE_NAME": ["居民区", "商业娱乐区", "交通枢纽区", "旅游景区", "工业区", "集贸区", "院校学区", "办公区", "其他"],
  54. "BB_RTL_CUST_MARKET_TYPE_NAME": ["城网", "农网"],
  55. "BB_RTL_CUST_SUB_BUSI_PLACE_NAME": ["便利店", "超市", "烟草专业店", "娱乐服务类", "其他"],
  56. "BB_RTL_CUST_GRADE_NAME": ['一档', '二档', '三档', '四档', '五档', '六档', '七档', '八档', '九档', '十档', '十一档', '十二档',
  57. '十三档', '十四档', '十五档', '十六档', '十七档', '十八档', '十九档', '二十档', '二十一档', '二十二档',
  58. '二十三档', '二十四档', '二十五档', '二十六档', '二十七档', '二十八档', '二十九档', '三十档'],
  59. "BB_RTL_CUST_CHAIN_FLAG": ["是", "否"],
  60. "MD04_DIR_SAL_STORE_FLAG": ["是", "否"],
  61. "OPERATOR_EDU_LEVEL": [1, 2, 3, 4, 5, 6, 7]
  62. }
  63. class ProductConfig:
  64. FEATURE_COLUMNS = [
  65. "product_code", # 商品编码
  66. # "factory_name", # 工业公司名称
  67. # "brand_code", # 品牌编码
  68. "adjust_price", # 含税调拨价
  69. "notwithtax_adjust_price", # 不含税调拨价
  70. "whole_sale_price", # 统一批发价
  71. "direct_retail_price", # 建议零售价
  72. "allot_price", # 调拨价
  73. "direct_whole_price", # 批发指导价
  74. "retail_price", # 零售价
  75. "price_type_name", # 卷烟价类名称
  76. "gear_type_name", # 卷烟档位名称
  77. "category_type_name", # 卷烟品类名称
  78. "is_key_brand", # 是否重点品牌
  79. "is_high_level", # 是否高端烟
  80. "is_upscale_level", # 是否高端烟不含高价
  81. "is_high_price", # 是否高价烟
  82. "is_low_price", # 是否低价烟
  83. "is_low_tar", # 是否低焦油烟
  84. "is_encourage", # 是否全国鼓励品牌
  85. "is_abnormity", # 是否异形包装
  86. "is_intake", # 是否进口烟
  87. "is_short", # 是否紧俏品牌
  88. "is_medium", # 是否中支烟
  89. "is_shortbranch", # 是否短支烟
  90. "is_ordinary_price_type", # 是否普一类烟
  91. "source_type", # 来源类型
  92. "tar_qty", # 焦油含量
  93. "product_style_code_name", # 包装类型名称
  94. "chinese_mix", # 中式混合
  95. "sub_price_type_name", # 细分卷烟价类名称
  96. ]
  97. CLEANING_RULES = {
  98. "adjust_price": {"method": "fillna", "opt": "mean", "type": "num"},
  99. "notwithtax_adjust_price": {"method": "fillna", "opt": "mean", "type": "num"},
  100. "whole_sale_price": {"method": "fillna", "opt": "mean", "type": "num"},
  101. "direct_retail_price": {"method": "fillna", "opt": "mean", "type": "num"},
  102. "allot_price": {"method": "fillna", "opt": "fill", "type": "num", "value": 0.0},
  103. "direct_whole_price": {"method": "fillna", "opt": "mean", "type": "num"},
  104. "retail_price": {"method": "fillna", "opt": "mean", "type": "num"},
  105. "price_type_name": {"method": "fillna", "opt": "fill", "type": "str", "value": "一类烟"},
  106. "gear_type_name": {"method": "fillna", "opt": "fill", "type": "str", "value": "其他"},
  107. "category_type_name": {"method": "fillna", "opt": "fill", "type": "str", "value": "其他"},
  108. "is_key_brand": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  109. "is_high_level": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  110. "is_upscale_level": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  111. "is_high_price": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  112. "is_low_price": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  113. "is_low_tar": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  114. "is_encourage": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  115. "is_abnormity": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  116. "is_intake": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  117. "is_short": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  118. "is_medium": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  119. "is_shortbranch": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  120. "is_ordinary_price_type": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  121. "source_type": {"method": "fillna", "opt": "fill", "type": "str", "value": "其他"},
  122. "tar_qty": {"method": "fillna", "opt": "mean", "type": "num"},
  123. "product_style_code_name": {"method": "fillna", "opt": "fill", "type": "str", "value": "其他"},
  124. "chinese_mix": {"method": "fillna", "opt": "fill", "type": "str", "value": "否"},
  125. "sub_price_type_name": {"method": "fillna", "opt": "fill", "type": "str", "value": "普一类烟"},
  126. }
  127. ONEHOT = [
  128. "price_type_name", # 卷烟价类名称
  129. "gear_type_name", # 卷烟档位名称
  130. "category_type_name", # 卷烟品类名称
  131. "is_key_brand", # 是否重点品牌
  132. "is_high_level", # 是否高端烟
  133. "is_upscale_level", # 是否高端烟不含高价
  134. "is_high_price", # 是否高价烟
  135. "is_low_price", # 是否低价烟
  136. "is_low_tar", # 是否低焦油烟
  137. "is_encourage", # 是否全国鼓励品牌
  138. "is_abnormity", # 是否异形包装
  139. "is_intake", # 是否进口烟
  140. "is_short", # 是否紧俏品牌
  141. "is_medium", # 是否中支烟
  142. "is_shortbranch", # 是否短支烟
  143. "is_ordinary_price_type", # 是否普一类烟
  144. "source_type", # 来源类型
  145. "product_style_code_name", # 包装类型名称
  146. "chinese_mix", # 中式混合
  147. "sub_price_type_name", # 细分卷烟价类名称
  148. ]
  149. ONEHOT_CAT = {
  150. "price_type_name": ["一类烟", "二类烟", "三类烟", "四类烟", "五类烟", "无价类"],
  151. "gear_type_name": ["第一档位", "第二档位", "第三档位", "第四档位", "第五档位", "第六档位", "第七档位", "第八档位", "其他"],
  152. "category_type_name": ["第1品类", "第2品类", "第3品类", "第4品类", "第5品类", "第6品类", "第7品类",
  153. "第8品类", "第9品类", "第10品类", "第11品类", "第12品类", "第13品类", "其他"],
  154. "is_key_brand": ["是", "否"],
  155. "is_high_level": ["是", "否"],
  156. "is_upscale_level": ["是", "否"],
  157. "is_high_price": ["是", "否"],
  158. "is_low_price": ["是", "否"],
  159. "is_low_tar": ["是", "否"],
  160. "is_encourage": ["是", "否"],
  161. "is_abnormity": ["是", "否"],
  162. "is_intake": ["是", "否"],
  163. "is_short": ["是", "否"],
  164. "is_medium": ["是", "否"],
  165. "is_shortbranch": ["是", "否"],
  166. "is_ordinary_price_type": ["是", "否"],
  167. "source_type": ["是", "否"],
  168. "product_style_code_name": ["条盒硬盒", "条包硬盒", "条盒软盒", "条包软盒", "铁盒", "其他"],
  169. "chinese_mix": ["是", "否"],
  170. "sub_price_type_name": ["高端烟", "高价位烟", "普一类烟", "二类烟", "三类烟", "四类烟", "五类烟", "无价类"],
  171. }