Coverage for hopwise/model/exlib_recommender/xgboost.py: 85%

13 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-09-30 13:25 +0000

1# @Time : 2020/11/19 

2# @Author : Chen Yang 

3# @Email : 254170321@qq.com 

4 

5r"""hopwise.model.exlib_recommender.xgboost 

6######################################## 

7""" 

8 

9import xgboost as xgb 

10 

11from hopwise.utils import InputType, ModelType 

12 

13 

14class XGBoost(xgb.Booster): 

15 r"""XGBoost is inherited from xgb.Booster""" 

16 

17 type = ModelType.DECISIONTREE 

18 input_type = InputType.POINTWISE 

19 

20 def __init__(self, config, dataset): 

21 super().__init__(params=None, cache=(), model_file=None) 

22 

23 def to(self, device): 

24 return self 

25 

26 def load_state_dict(self, model_file): 

27 r"""Load state dictionary 

28 

29 Args: 

30 model_file (str): file path of saved model 

31 

32 """ 

33 self.load_model(model_file) 

34 

35 def load_other_parameter(self, other_parameter): 

36 r"""Load other parameters""" 

37 pass