Skip to content

Commit

Permalink
Merge branch 'master' into r/revdepcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Dec 9, 2024
2 parents 791bd3a + d4d6c87 commit 679f1fa
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 256 deletions.
621 changes: 386 additions & 235 deletions docs/Installation-Guide.rst

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/_static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ $(() => {
/* Collapse specified sections in the installation guide */
if (window.location.pathname.toLocaleLowerCase().indexOf("installation-guide") !== -1) {
$(
'<style>.closed, .opened {cursor: pointer;} .closed:before, .opened:before {font-family: FontAwesome; display: inline-block; padding-right: 6px;} .closed:before {content: "\\f078";} .opened:before {content: "\\f077";}</style>',
'<style>.closed, .opened {cursor: pointer;} .closed:before, .opened:before {font-family: FontAwesome; display: inline-block; padding-right: 6px;} .closed:before {content: "\\f054";} .opened:before {content: "\\f078";}</style>',
).appendTo("body");
const collapsible = [
"#build-threadless-version-not-recommended",
"#build-mpi-version",
"#build-gpu-version",
"#build-cuda-version",
"#build-java-wrapper",
"#build-python-package",
"#build-r-package",
"#build-c-unit-tests",
];
$.each(collapsible, (_, val) => {
Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <LightGBM/utils/common.h>
#include <LightGBM/utils/file_io.h>

#include <cstdint>
#include <limits>
#include <string>
#include <functional>
Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/cuda/cuda_column_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <LightGBM/bin.h>
#include <LightGBM/utils/openmp_wrapper.h>

#include <cstdint>
#include <vector>

namespace LightGBM {
Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/cuda/cuda_row_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <LightGBM/train_share_states.h>
#include <LightGBM/utils/openmp_wrapper.h>

#include <cstdint>
#include <vector>

#define COPY_SUBROW_BLOCK_SIZE_ROW_DATA (1024)
Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <LightGBM/utils/random.h>
#include <LightGBM/utils/text_reader.h>

#include <cstdint>
#include <string>
#include <functional>
#include <map>
Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/feature_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <LightGBM/meta.h>
#include <LightGBM/utils/random.h>

#include <cstdint>
#include <cstdio>
#include <memory>
#include <vector>
Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/train_share_states.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <LightGBM/utils/threading.h>

#include <algorithm>
#include <cstdint>
#include <memory>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions include/LightGBM/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <LightGBM/dataset.h>
#include <LightGBM/meta.h>

#include <cstdint>
#include <string>
#include <map>
#include <memory>
Expand Down
10 changes: 0 additions & 10 deletions python-package/lightgbm/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
from sklearn.utils.multiclass import check_classification_targets
from sklearn.utils.validation import assert_all_finite, check_array, check_X_y

# sklearn.utils Tags types can be imported unconditionally once
# lightgbm's minimum scikit-learn version is 1.6 or higher
try:
from sklearn.utils import ClassifierTags as _sklearn_ClassifierTags
from sklearn.utils import RegressorTags as _sklearn_RegressorTags
except ImportError:
_sklearn_ClassifierTags = None
_sklearn_RegressorTags = None
try:
from sklearn.exceptions import NotFittedError
from sklearn.model_selection import BaseCrossValidator, GroupKFold, StratifiedKFold
Expand Down Expand Up @@ -148,8 +140,6 @@ class _LGBMRegressorBase: # type: ignore
_LGBMCheckClassificationTargets = None
_LGBMComputeSampleWeight = None
_LGBMValidateData = None
_sklearn_ClassifierTags = None
_sklearn_RegressorTags = None
_sklearn_version = None

# additional scikit-learn imports only for type hints
Expand Down
15 changes: 5 additions & 10 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
_LGBMModelBase,
_LGBMRegressorBase,
_LGBMValidateData,
_sklearn_ClassifierTags,
_sklearn_RegressorTags,
_sklearn_version,
dt_DataTable,
pd_DataFrame,
Expand Down Expand Up @@ -726,7 +724,7 @@ def __sklearn_tags__(self) -> Optional["_sklearn_Tags"]:
# take whatever tags are provided by BaseEstimator, then modify
# them with LightGBM-specific values
return self._update_sklearn_tags_from_dict(
tags=_LGBMModelBase.__sklearn_tags__(self),
tags=super().__sklearn_tags__(),
tags_dict=self._more_tags(),
)

Expand Down Expand Up @@ -1298,10 +1296,7 @@ def _more_tags(self) -> Dict[str, Any]:
return tags

def __sklearn_tags__(self) -> "_sklearn_Tags":
tags = LGBMModel.__sklearn_tags__(self)
tags.estimator_type = "regressor"
tags.regressor_tags = _sklearn_RegressorTags(multi_label=False)
return tags
return super().__sklearn_tags__()

def fit( # type: ignore[override]
self,
Expand Down Expand Up @@ -1360,9 +1355,9 @@ def _more_tags(self) -> Dict[str, Any]:
return tags

def __sklearn_tags__(self) -> "_sklearn_Tags":
tags = LGBMModel.__sklearn_tags__(self)
tags.estimator_type = "classifier"
tags.classifier_tags = _sklearn_ClassifierTags(multi_class=True, multi_label=False)
tags = super().__sklearn_tags__()
tags.classifier_tags.multi_class = True
tags.classifier_tags.multi_label = False
return tags

def fit( # type: ignore[override]
Expand Down
1 change: 1 addition & 0 deletions src/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <string>
#include <cstdio>
#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
Expand Down
2 changes: 2 additions & 0 deletions src/io/cuda/cuda_column_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <LightGBM/cuda/cuda_column_data.hpp>

#include <cstdint>

namespace LightGBM {

CUDAColumnData::CUDAColumnData(const data_size_t num_data, const int gpu_device_id) {
Expand Down
1 change: 1 addition & 0 deletions src/io/json11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <LightGBM/utils/log.h>

#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <limits>
Expand Down
6 changes: 6 additions & 0 deletions tests/python_package_test/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,12 @@ def test_sklearn_tags_should_correctly_reflect_lightgbm_specific_values(estimato
assert sklearn_tags.input_tags.allow_nan is True
assert sklearn_tags.input_tags.sparse is True
assert sklearn_tags.target_tags.one_d_labels is True
if estimator_class is lgb.LGBMClassifier:
assert sklearn_tags.estimator_type == "classifier"
assert sklearn_tags.classifier_tags.multi_class is True
assert sklearn_tags.classifier_tags.multi_label is False
elif estimator_class is lgb.LGBMRegressor:
assert sklearn_tags.estimator_type == "regressor"


@pytest.mark.parametrize("task", all_tasks)
Expand Down

0 comments on commit 679f1fa

Please sign in to comment.