t.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. weight_v567 = {
  2. "xgbNorScaleType": 1,
  3. "xgbNorBias": -1.5147,
  4. "xgbNorWeight": 2.277,
  5. "xgbNorPowerWeight": 1.2216,
  6. "xgbNorPowerExp": 1.32
  7. }
  8. weight_v564 = {
  9. "fmRovBias": -0.0017,
  10. "fmRovWeight": 1.331,
  11. "fmRovSquareWeight": -6.4597,
  12. "fmRovCubeWeight": 14.393,
  13. "xgbNorScaleType": 1,
  14. "xgbNorBias": -1.5147,
  15. "xgbNorWeight": 2.277,
  16. "xgbNorPowerWeight": 1.2216,
  17. "xgbNorPowerExp": 1.32
  18. }
  19. score_map = {"fmRovOrigin": 0.27195945382118225, "NorXGBScore": 1.5618711709976196, "fmRov": 0.03600984021032825, "RovFMScore": 0.27195945382118225, "hasReturnRovScore": 2.442478, "vor": 8.230978}
  20. def rov_calibration(bias: float, weight: float, square_weight: float, cube_weight: float, score: float) -> float:
  21. new_score = bias + weight * score
  22. if abs(square_weight) > 1E-8:
  23. new_score += square_weight * (score ** 2)
  24. if abs(cube_weight) > 1E-8:
  25. new_score += cube_weight * (score ** 3)
  26. if new_score < 1E-8:
  27. new_score = score
  28. elif new_score > 0.9:
  29. new_score = 0.9
  30. return new_score
  31. def nor_calibration(scale_type: float, poly_bias: float, poly_weight: float,
  32. power_weight: float, power_exp: float, score: float) -> float:
  33. if scale_type < 1:
  34. return nor_poly_calibration(poly_bias, poly_weight, score)
  35. else:
  36. return nor_power_calibration(power_weight, power_exp, score)
  37. def nor_poly_calibration(bias: float, weight: float, score: float) -> float:
  38. new_score = bias + weight * score
  39. return max(new_score, 0)
  40. def nor_power_calibration(weight: float, exp: float, score: float) -> float:
  41. new_score = weight * (score ** exp)
  42. return min(new_score, 100)
  43. def _main():
  44. fmRovBias = float(weight_v564["fmRovBias"])
  45. fmRovWeight = float(weight_v564["fmRovWeight"])
  46. fmRovSquareWeight = float(weight_v564["fmRovSquareWeight"])
  47. fmRovCubeWeight = float(weight_v564["fmRovCubeWeight"])
  48. xgbNorScaleType = float(weight_v564["xgbNorScaleType"])
  49. xgbNorBias = float(weight_v564["xgbNorBias"])
  50. xgbNorWeight = float(weight_v564["xgbNorWeight"])
  51. xgbNorPowerWeight = float(weight_v564["xgbNorPowerWeight"])
  52. xgbNorPowerExp = float(weight_v564["xgbNorPowerExp"])
  53. fm_rov = float(score_map['fmRov'])
  54. nor = float(score_map['NorXGBScore'])
  55. vor = float(score_map['vor'])
  56. # new_fm_rov = rov_calibration(fmRovBias, fmRovWeight, fmRovSquareWeight, fmRovCubeWeight, fm_rov)
  57. new_fm_rov = fm_rov
  58. new_nor = nor_calibration(xgbNorScaleType, xgbNorBias, xgbNorWeight, xgbNorPowerWeight, xgbNorPowerExp, nor)
  59. print(new_fm_rov * (0.1 + new_nor) * (0.1 + vor))
  60. if __name__ == '__main__':
  61. _main()