consts.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. ARBITER = 'arbiter'
  17. HOST = 'host'
  18. GUEST = 'guest'
  19. MODEL_AGG = "model_agg"
  20. GRAD_AGG = "grad_agg"
  21. BINARY = 'binary'
  22. MULTY = 'multi'
  23. CLASSIFICATION = "classification"
  24. REGRESSION = 'regression'
  25. CLUSTERING = 'clustering'
  26. ONE_VS_REST = 'one_vs_rest'
  27. PAILLIER = 'Paillier'
  28. PAILLIER_IPCL = 'IPCL'
  29. RANDOM_PADS = "RandomPads"
  30. NONE = "None"
  31. AFFINE = 'Affine'
  32. ITERATIVEAFFINE = 'IterativeAffine'
  33. RANDOM_ITERATIVEAFFINE = 'RandomIterativeAffine'
  34. L1_PENALTY = 'L1'
  35. L2_PENALTY = 'L2'
  36. FLOAT_ZERO = 1e-8
  37. OVERFLOW_THRESHOLD = 1e8
  38. OT_HAUCK = 'OT_Hauck'
  39. CE_PH = 'CommutativeEncryptionPohligHellman'
  40. XOR = 'xor'
  41. AES = 'aes'
  42. PARAM_MAXDEPTH = 5
  43. MAX_CLASSNUM = 1000
  44. MIN_BATCH_SIZE = 10
  45. SPARSE_VECTOR = "SparseVector"
  46. HETERO = "hetero"
  47. HOMO = "homo"
  48. RAW = "raw"
  49. RSA = "rsa"
  50. DH = "dh"
  51. ECDH = "ecdh"
  52. # evaluation
  53. AUC = "auc"
  54. KS = "ks"
  55. LIFT = "lift"
  56. GAIN = "gain"
  57. PRECISION = "precision"
  58. RECALL = "recall"
  59. ACCURACY = "accuracy"
  60. EXPLAINED_VARIANCE = "explained_variance"
  61. MEAN_ABSOLUTE_ERROR = "mean_absolute_error"
  62. MEAN_SQUARED_ERROR = "mean_squared_error"
  63. MEAN_SQUARED_LOG_ERROR = "mean_squared_log_error"
  64. MEDIAN_ABSOLUTE_ERROR = "median_absolute_error"
  65. R2_SCORE = "r2_score"
  66. ROOT_MEAN_SQUARED_ERROR = "root_mean_squared_error"
  67. ROC = "roc"
  68. F1_SCORE = 'f1_score'
  69. CONFUSION_MAT = 'confusion_mat'
  70. PSI = 'psi'
  71. VIF = 'vif'
  72. PEARSON = 'pearson'
  73. FEATURE_IMPORTANCE = 'feature_importance'
  74. QUANTILE_PR = 'quantile_pr'
  75. JACCARD_SIMILARITY_SCORE = 'jaccard_similarity_score'
  76. FOWLKES_MALLOWS_SCORE = 'fowlkes_mallows_score'
  77. ADJUSTED_RAND_SCORE = 'adjusted_rand_score'
  78. DAVIES_BOULDIN_INDEX = 'davies_bouldin_index'
  79. DISTANCE_MEASURE = 'distance_measure'
  80. CONTINGENCY_MATRIX = 'contingency_matrix'
  81. # evaluation alias metric
  82. ALL_METRIC_NAME = [AUC, KS, LIFT, GAIN, PRECISION, RECALL, ACCURACY, EXPLAINED_VARIANCE, MEAN_ABSOLUTE_ERROR,
  83. MEAN_SQUARED_ERROR, MEAN_SQUARED_LOG_ERROR, MEDIAN_ABSOLUTE_ERROR, R2_SCORE, ROOT_MEAN_SQUARED_ERROR,
  84. ROC, F1_SCORE, CONFUSION_MAT, PSI, QUANTILE_PR, JACCARD_SIMILARITY_SCORE, FOWLKES_MALLOWS_SCORE,
  85. ADJUSTED_RAND_SCORE, DAVIES_BOULDIN_INDEX, DISTANCE_MEASURE, CONTINGENCY_MATRIX]
  86. ALIAS = {
  87. ('l1', 'mae', 'regression_l1'): MEAN_ABSOLUTE_ERROR,
  88. ('l2', 'mse', 'regression_l2', 'regression'): MEAN_SQUARED_ERROR,
  89. ('l2_root', 'rmse'): ROOT_MEAN_SQUARED_ERROR,
  90. ('msle', ): MEAN_SQUARED_LOG_ERROR,
  91. ('r2', ): R2_SCORE,
  92. ('acc', ): ACCURACY,
  93. ('DBI', ): DAVIES_BOULDIN_INDEX,
  94. ('FMI', ): FOWLKES_MALLOWS_SCORE,
  95. ('RI', ): ADJUSTED_RAND_SCORE,
  96. ('jaccard', ): JACCARD_SIMILARITY_SCORE
  97. }
  98. # default evaluation metrics
  99. DEFAULT_BINARY_METRIC = [AUC, KS]
  100. DEFAULT_REGRESSION_METRIC = [ROOT_MEAN_SQUARED_ERROR, MEAN_ABSOLUTE_ERROR]
  101. DEFAULT_MULTI_METRIC = [ACCURACY, PRECISION, RECALL]
  102. DEFAULT_CLUSTER_METRIC = [DAVIES_BOULDIN_INDEX]
  103. # allowed metrics for different tasks
  104. ALL_BINARY_METRICS = [
  105. AUC,
  106. KS,
  107. LIFT,
  108. GAIN,
  109. ACCURACY,
  110. PRECISION,
  111. RECALL,
  112. ROC,
  113. CONFUSION_MAT,
  114. PSI,
  115. F1_SCORE,
  116. QUANTILE_PR
  117. ]
  118. ALL_REGRESSION_METRICS = [
  119. EXPLAINED_VARIANCE,
  120. MEAN_ABSOLUTE_ERROR,
  121. MEAN_SQUARED_ERROR,
  122. MEDIAN_ABSOLUTE_ERROR,
  123. R2_SCORE,
  124. ROOT_MEAN_SQUARED_ERROR
  125. ]
  126. ALL_MULTI_METRICS = [
  127. ACCURACY,
  128. PRECISION,
  129. RECALL
  130. ]
  131. ALL_CLUSTER_METRICS = [
  132. JACCARD_SIMILARITY_SCORE,
  133. FOWLKES_MALLOWS_SCORE,
  134. ADJUSTED_RAND_SCORE,
  135. DAVIES_BOULDIN_INDEX,
  136. DISTANCE_MEASURE,
  137. CONTINGENCY_MATRIX
  138. ]
  139. # single value metrics
  140. REGRESSION_SINGLE_VALUE_METRICS = [
  141. EXPLAINED_VARIANCE,
  142. MEAN_ABSOLUTE_ERROR,
  143. MEAN_SQUARED_ERROR,
  144. MEAN_SQUARED_LOG_ERROR,
  145. MEDIAN_ABSOLUTE_ERROR,
  146. R2_SCORE,
  147. ROOT_MEAN_SQUARED_ERROR,
  148. ]
  149. BINARY_SINGLE_VALUE_METRIC = [
  150. AUC,
  151. KS
  152. ]
  153. MULTI_SINGLE_VALUE_METRIC = [
  154. PRECISION,
  155. RECALL,
  156. ACCURACY
  157. ]
  158. CLUSTER_SINGLE_VALUE_METRIC = [
  159. JACCARD_SIMILARITY_SCORE,
  160. FOWLKES_MALLOWS_SCORE,
  161. ADJUSTED_RAND_SCORE,
  162. DAVIES_BOULDIN_INDEX
  163. ]
  164. # workflow
  165. TRAIN_DATA = "train_data"
  166. TEST_DATA = "test_data"
  167. # initialize method
  168. RANDOM_NORMAL = "random_normal"
  169. RANDOM_UNIFORM = 'random_uniform'
  170. ONES = 'ones'
  171. ZEROS = 'zeros'
  172. CONST = 'const'
  173. # decision tree
  174. MAX_SPLIT_NODES = 2 ** 16
  175. MAX_SPLITINFO_TO_COMPUTE = 2 ** 10
  176. NORMAL_TREE = 'normal'
  177. COMPLETE_SECURE_TREE = 'complete_secure'
  178. STD_TREE = 'std'
  179. MIX_TREE = 'mix'
  180. LAYERED_TREE = 'layered'
  181. SINGLE_OUTPUT = 'single_output'
  182. MULTI_OUTPUT = 'multi_output'
  183. HOST_LOCAL = 'hostLocal'
  184. TRAIN_EVALUATE = 'train_evaluate'
  185. VALIDATE_EVALUATE = 'validate_evaluate'
  186. # Feature engineering
  187. G_BIN_NUM = 10
  188. DEFAULT_COMPRESS_THRESHOLD = 10000
  189. DEFAULT_HEAD_SIZE = 10000
  190. DEFAULT_RELATIVE_ERROR = 1e-4
  191. ONE_HOT_LIMIT = 1024 # No more than 10 possible values
  192. PERCENTAGE_VALUE_LIMIT = 0.1
  193. SECURE_AGG_AMPLIFY_FACTOR = 1000
  194. QUANTILE = 'quantile'
  195. BUCKET = 'bucket'
  196. OPTIMAL = 'optimal'
  197. VIRTUAL_SUMMARY = 'virtual_summary'
  198. RECURSIVE_QUERY = 'recursive_query'
  199. # Feature selection methods
  200. UNIQUE_VALUE = 'unique_value'
  201. IV_VALUE_THRES = 'iv_value_thres'
  202. IV_PERCENTILE = 'iv_percentile'
  203. IV_TOP_K = 'iv_top_k'
  204. COEFFICIENT_OF_VARIATION_VALUE_THRES = 'coefficient_of_variation_value_thres'
  205. # COEFFICIENT_OF_VARIATION_PERCENTILE = 'coefficient_of_variation_percentile'
  206. OUTLIER_COLS = 'outlier_cols'
  207. MANUALLY_FILTER = 'manually'
  208. PERCENTAGE_VALUE = 'percentage_value'
  209. IV_FILTER = 'iv_filter'
  210. STATISTIC_FILTER = 'statistic_filter'
  211. PSI_FILTER = 'psi_filter'
  212. VIF_FILTER = 'vif_filter'
  213. CORRELATION_FILTER = 'correlation_filter'
  214. SECUREBOOST = 'sbt'
  215. HETERO_SBT_FILTER = 'hetero_sbt_filter'
  216. HOMO_SBT_FILTER = 'homo_sbt_filter'
  217. HETERO_FAST_SBT_FILTER = 'hetero_fast_sbt_filter'
  218. IV = 'iv'
  219. # Selection Pre-model
  220. STATISTIC_MODEL = 'statistic_model'
  221. BINNING_MODEL = 'binning_model'
  222. # imputer
  223. MIN = 'min'
  224. MAX = 'max'
  225. MEAN = 'mean'
  226. DESIGNATED = 'designated'
  227. STR = 'str'
  228. FLOAT = 'float'
  229. INT = 'int'
  230. ORIGIN = 'origin'
  231. MEDIAN = 'median'
  232. # min_max_scaler
  233. NORMAL = 'normal'
  234. CAP = 'cap'
  235. MINMAXSCALE = 'min_max_scale'
  236. STANDARDSCALE = 'standard_scale'
  237. ALL = 'all'
  238. COL = 'col'
  239. # intersection cache
  240. PHONE = 'phone'
  241. IMEI = 'imei'
  242. MD5 = 'md5'
  243. SHA1 = 'sha1'
  244. SHA224 = 'sha224'
  245. SHA256 = 'sha256'
  246. SHA384 = 'sha384'
  247. SHA512 = 'sha512'
  248. SM3 = 'sm3'
  249. INTERSECT_CACHE_TAG = 'Za'
  250. SHARE_INFO_COL_NAME = "share_info"
  251. # statistics
  252. COUNT = 'count'
  253. STANDARD_DEVIATION = 'stddev'
  254. SUMMARY = 'summary'
  255. DESCRIBE = 'describe'
  256. SUM = 'sum'
  257. COVARIANCE = 'cov'
  258. CORRELATION = 'corr'
  259. VARIANCE = 'variance'
  260. COEFFICIENT_OF_VARIATION = 'coefficient_of_variance'
  261. MISSING_COUNT = "missing_count"
  262. MISSING_RATIO = "missing_ratio"
  263. SKEWNESS = 'skewness'
  264. KURTOSIS = 'kurtosis'
  265. # adapters model name
  266. HOMO_SBT = 'homo_sbt'
  267. HETERO_SBT = 'hetero_sbt'
  268. HETERO_FAST_SBT = 'hetero_fast_sbt'
  269. HETERO_FAST_SBT_MIX = 'hetero_fast_sbt_mix'
  270. HETERO_FAST_SBT_LAYERED = 'hetero_fast_sbt_layered'
  271. # tree protobuf model name
  272. HETERO_SBT_GUEST_MODEL = 'HeteroSecureBoostingTreeGuest'
  273. HETERO_SBT_HOST_MODEL = 'HeteroSecureBoostingTreeHost'
  274. HETERO_FAST_SBT_GUEST_MODEL = "HeteroFastSecureBoostingTreeGuest"
  275. HETERO_FAST_SBT_HOST_MODEL = "HeteroFastSecureBoostingTreeHost"
  276. HOMO_SBT_GUEST_MODEL = "HomoSecureBoostingTreeGuest"
  277. HOMO_SBT_HOST_MODEL = "HomoSecureBoostingTreeHost"
  278. # tree decimal round to prevent float error
  279. TREE_DECIMAL_ROUND = 10
  280. # homm sbt backend
  281. MEMORY_BACKEND = 'memory'
  282. DISTRIBUTED_BACKEND = 'distributed'
  283. # column_expand
  284. MANUAL = 'manual'
  285. # scorecard
  286. CREDIT = 'credit'
  287. # sample weight
  288. BALANCED = 'balanced'
  289. # min r base fraction
  290. MIN_BASE_FRACTION = 0.01
  291. MAX_BASE_FRACTION = 0.99
  292. MAX_SAMPLE_OUTPUT_LIMIT = 10 ** 6
  293. # Hetero NN Selective BP Strategy
  294. SELECTIVE_SIZE = 1024
  295. # intersect join methods
  296. INNER_JOIN = "inner_join"
  297. LEFT_JOIN = "left_join"
  298. DEFAULT_KEY_LENGTH = 1024
  299. MIN_HASH_FUNC_COUNT = 4
  300. MAX_HASH_FUNC_COUNT = 32
  301. EINI_TREE_COMPLEXITY = 1000000000
  302. pytorch_backend = 'pytorch'
  303. keras_backend = 'keras'
  304. CURVE25519 = 'curve25519'
  305. # HOMO NN Framework
  306. FEDAVG_TRAINER = 'fedavg_trainer'
  307. # positive unlabeled
  308. PROBABILITY = "probability"
  309. QUANTITY = "quantity"
  310. PROPORTION = "proportion"
  311. DISTRIBUTION = "distribution"