[dask] Add type hints. (#6519)
* Add validate_features. * Show type hints in doc. Co-authored-by: Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -7,6 +7,7 @@ import collections
|
||||
from collections.abc import Mapping
|
||||
from typing import List, Optional, Any, Union, Dict
|
||||
# pylint: enable=no-name-in-module,import-error
|
||||
from typing import Callable, Tuple
|
||||
import ctypes
|
||||
import os
|
||||
import re
|
||||
@@ -991,6 +992,10 @@ class DeviceQuantileDMatrix(DMatrix):
|
||||
)
|
||||
|
||||
|
||||
Objective = Callable[[np.ndarray, DMatrix], Tuple[np.ndarray, np.ndarray]]
|
||||
Metric = Callable[[np.ndarray, DMatrix], Tuple[np.ndarray, np.ndarray]]
|
||||
|
||||
|
||||
class Booster(object):
|
||||
# pylint: disable=too-many-public-methods
|
||||
"""A Booster of XGBoost.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
|
||||
import os
|
||||
import platform
|
||||
from typing import List
|
||||
import sys
|
||||
|
||||
|
||||
@@ -10,12 +11,12 @@ class XGBoostLibraryNotFound(Exception):
|
||||
"""Error thrown by when xgboost is not found"""
|
||||
|
||||
|
||||
def find_lib_path():
|
||||
def find_lib_path() -> List[str]:
|
||||
"""Find the path to xgboost dynamic library files.
|
||||
|
||||
Returns
|
||||
-------
|
||||
lib_path: list(string)
|
||||
lib_path
|
||||
List of all found library path to xgboost
|
||||
"""
|
||||
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
|
||||
|
||||
0
python-package/xgboost/py.typed
Normal file
0
python-package/xgboost/py.typed
Normal file
@@ -443,8 +443,8 @@ class XGBModel(XGBModelBase):
|
||||
except TypeError:
|
||||
warnings.warn(str(k) + ' is not saved in Scikit-Learn meta.')
|
||||
meta['type'] = type(self).__name__
|
||||
meta = json.dumps(meta)
|
||||
self.get_booster().set_attr(scikit_learn=meta)
|
||||
meta_str = json.dumps(meta)
|
||||
self.get_booster().set_attr(scikit_learn=meta_str)
|
||||
self.get_booster().save_model(fname)
|
||||
# Delete the attribute after save
|
||||
self.get_booster().set_attr(scikit_learn=None)
|
||||
|
||||
Reference in New Issue
Block a user