Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34408a7fdc | ||
|
|
f9b246f5ee | ||
|
|
8467880aeb | ||
|
|
e74560c86a | ||
|
|
882b966536 | ||
|
|
115e4c3360 |
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(xgboost LANGUAGES CXX C VERSION 1.1.0)
|
project(xgboost LANGUAGES CXX C VERSION 1.1.1)
|
||||||
include(cmake/Utils.cmake)
|
include(cmake/Utils.cmake)
|
||||||
list(APPEND CMAKE_MODULE_PATH "${xgboost_SOURCE_DIR}/cmake/modules")
|
list(APPEND CMAKE_MODULE_PATH "${xgboost_SOURCE_DIR}/cmake/modules")
|
||||||
cmake_policy(SET CMP0022 NEW)
|
cmake_policy(SET CMP0022 NEW)
|
||||||
@@ -57,6 +57,7 @@ address, leak, undefined and thread.")
|
|||||||
## Plugins
|
## Plugins
|
||||||
option(PLUGIN_LZ4 "Build lz4 plugin" OFF)
|
option(PLUGIN_LZ4 "Build lz4 plugin" OFF)
|
||||||
option(PLUGIN_DENSE_PARSER "Build dense parser plugin" OFF)
|
option(PLUGIN_DENSE_PARSER "Build dense parser plugin" OFF)
|
||||||
|
option(ADD_PKGCONFIG "Add xgboost.pc into system." ON)
|
||||||
|
|
||||||
#-- Checks for building XGBoost
|
#-- Checks for building XGBoost
|
||||||
if (USE_DEBUG_OUTPUT AND (NOT (CMAKE_BUILD_TYPE MATCHES Debug)))
|
if (USE_DEBUG_OUTPUT AND (NOT (CMAKE_BUILD_TYPE MATCHES Debug)))
|
||||||
@@ -274,3 +275,12 @@ endif (GOOGLE_TEST)
|
|||||||
# replace /MD with /MT. See https://github.com/dmlc/xgboost/issues/4462
|
# replace /MD with /MT. See https://github.com/dmlc/xgboost/issues/4462
|
||||||
# for issues caused by mixing of /MD and /MT flags
|
# for issues caused by mixing of /MD and /MT flags
|
||||||
msvc_use_static_runtime()
|
msvc_use_static_runtime()
|
||||||
|
|
||||||
|
# Add xgboost.pc
|
||||||
|
if (ADD_PKGCONFIG)
|
||||||
|
configure_file(${xgboost_SOURCE_DIR}/cmake/xgboost.pc.in ${xgboost_BINARY_DIR}/xgboost.pc @ONLY)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${xgboost_BINARY_DIR}/xgboost.pc
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
|
endif (ADD_PKGCONFIG)
|
||||||
|
|||||||
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@@ -48,7 +48,6 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
parallel ([
|
parallel ([
|
||||||
'clang-tidy': { ClangTidy() },
|
'clang-tidy': { ClangTidy() },
|
||||||
'lint': { Lint() },
|
|
||||||
'sphinx-doc': { SphinxDoc() },
|
'sphinx-doc': { SphinxDoc() },
|
||||||
'doxygen': { Doxygen() }
|
'doxygen': { Doxygen() }
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
parallel ([
|
parallel ([
|
||||||
'build-win64-cuda9.0': { BuildWin64() }
|
'build-win64-cuda10.0': { BuildWin64() }
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
milestone ordinal: 2
|
milestone ordinal: 2
|
||||||
@@ -40,7 +40,6 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
parallel ([
|
parallel ([
|
||||||
'test-win64-cpu': { TestWin64CPU() },
|
'test-win64-cpu': { TestWin64CPU() },
|
||||||
'test-win64-gpu-cuda9.0': { TestWin64GPU(cuda_target: 'cuda9') },
|
|
||||||
'test-win64-gpu-cuda10.0': { TestWin64GPU(cuda_target: 'cuda10_0') },
|
'test-win64-gpu-cuda10.0': { TestWin64GPU(cuda_target: 'cuda10_0') },
|
||||||
'test-win64-gpu-cuda10.1': { TestWin64GPU(cuda_target: 'cuda10_1') }
|
'test-win64-gpu-cuda10.1': { TestWin64GPU(cuda_target: 'cuda10_1') }
|
||||||
])
|
])
|
||||||
@@ -67,7 +66,7 @@ def checkoutSrcs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def BuildWin64() {
|
def BuildWin64() {
|
||||||
node('win64 && build') {
|
node('win64 && build && cuda10') {
|
||||||
unstash name: 'srcs'
|
unstash name: 'srcs'
|
||||||
echo "Building XGBoost for Windows AMD64 target..."
|
echo "Building XGBoost for Windows AMD64 target..."
|
||||||
bat "nvcc --version"
|
bat "nvcc --version"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Package: xgboost
|
Package: xgboost
|
||||||
Type: Package
|
Type: Package
|
||||||
Title: Extreme Gradient Boosting
|
Title: Extreme Gradient Boosting
|
||||||
Version: 1.1.0.1
|
Version: 1.1.1.1
|
||||||
Date: 2020-02-21
|
Date: 2020-02-21
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person("Tianqi", "Chen", role = c("aut"),
|
person("Tianqi", "Chen", role = c("aut"),
|
||||||
|
|||||||
2
R-package/configure
vendored
2
R-package/configure
vendored
@@ -2698,7 +2698,7 @@ fi
|
|||||||
if test `uname -s` = "Darwin"
|
if test `uname -s` = "Darwin"
|
||||||
then
|
then
|
||||||
OPENMP_CXXFLAGS='-Xclang -fopenmp'
|
OPENMP_CXXFLAGS='-Xclang -fopenmp'
|
||||||
OPENMP_LIB='/usr/local/lib/libomp.dylib'
|
OPENMP_LIB='-lomp'
|
||||||
ac_pkg_openmp=no
|
ac_pkg_openmp=no
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenMP will work in a package" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenMP will work in a package" >&5
|
||||||
$as_echo_n "checking whether OpenMP will work in a package... " >&6; }
|
$as_echo_n "checking whether OpenMP will work in a package... " >&6; }
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fi
|
|||||||
if test `uname -s` = "Darwin"
|
if test `uname -s` = "Darwin"
|
||||||
then
|
then
|
||||||
OPENMP_CXXFLAGS='-Xclang -fopenmp'
|
OPENMP_CXXFLAGS='-Xclang -fopenmp'
|
||||||
OPENMP_LIB='/usr/local/lib/libomp.dylib'
|
OPENMP_LIB='-lomp'
|
||||||
ac_pkg_openmp=no
|
ac_pkg_openmp=no
|
||||||
AC_MSG_CHECKING([whether OpenMP will work in a package])
|
AC_MSG_CHECKING([whether OpenMP will work in a package])
|
||||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <omp.h>]], [[ return (omp_get_max_threads() <= 1); ]])])
|
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <omp.h>]], [[ return (omp_get_max_threads() <= 1); ]])])
|
||||||
|
|||||||
12
cmake/xgboost.pc.in
Normal file
12
cmake/xgboost.pc.in
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
version=@xgboost_VERSION@
|
||||||
|
exec_prefix=${prefix}/bin
|
||||||
|
libdir=${prefix}/lib
|
||||||
|
includedir=${prefix}/include
|
||||||
|
|
||||||
|
Name: xgboost
|
||||||
|
Description: XGBoost - Scalable and Flexible Gradient Boosting.
|
||||||
|
Version: ${version}
|
||||||
|
|
||||||
|
Cflags: -I${includedir}
|
||||||
|
Libs: -L${libdir} -lxgboost
|
||||||
@@ -35,7 +35,7 @@ There are four kinds of censoring:
|
|||||||
|
|
||||||
* **Uncensored**: the label is not censored and given as a single number.
|
* **Uncensored**: the label is not censored and given as a single number.
|
||||||
* **Right-censored**: the label is of form :math:`[a, +\infty)`, where :math:`a` is the lower bound.
|
* **Right-censored**: the label is of form :math:`[a, +\infty)`, where :math:`a` is the lower bound.
|
||||||
* **Left-censored**: the label is of form :math:`(-\infty, b]`, where :math:`b` is the upper bound.
|
* **Left-censored**: the label is of form :math:`[0, b]`, where :math:`b` is the upper bound.
|
||||||
* **Interval-censored**: the label is of form :math:`[a, b]`, where :math:`a` and :math:`b` are the lower and upper bounds, respectively.
|
* **Interval-censored**: the label is of form :math:`[a, b]`, where :math:`a` and :math:`b` are the lower and upper bounds, respectively.
|
||||||
|
|
||||||
Right-censoring is the most commonly used.
|
Right-censoring is the most commonly used.
|
||||||
@@ -83,7 +83,7 @@ Censoring type Interval form Lower bound finite? Upper bound finite?
|
|||||||
================= ==================== =================== ===================
|
================= ==================== =================== ===================
|
||||||
Uncensored :math:`[a, a]` |tick| |tick|
|
Uncensored :math:`[a, a]` |tick| |tick|
|
||||||
Right-censored :math:`[a, +\infty)` |tick| |cross|
|
Right-censored :math:`[a, +\infty)` |tick| |cross|
|
||||||
Left-censored :math:`(-\infty, b]` |cross| |tick|
|
Left-censored :math:`[0, b]` |tick| |tick|
|
||||||
Interval-censored :math:`[a, b]` |tick| |tick|
|
Interval-censored :math:`[a, b]` |tick| |tick|
|
||||||
================= ==================== =================== ===================
|
================= ==================== =================== ===================
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ Collect the lower bound numbers in one array (let's call it ``y_lower_bound``) a
|
|||||||
# Associate ranged labels with the data matrix.
|
# Associate ranged labels with the data matrix.
|
||||||
# This example shows each kind of censored labels.
|
# This example shows each kind of censored labels.
|
||||||
# uncensored right left interval
|
# uncensored right left interval
|
||||||
y_lower_bound = np.array([ 2.0, 3.0, -np.inf, 4.0])
|
y_lower_bound = np.array([ 2.0, 3.0, 0.0, 4.0])
|
||||||
y_upper_bound = np.array([ 2.0, +np.inf, 4.0, 5.0])
|
y_upper_bound = np.array([ 2.0, +np.inf, 4.0, 5.0])
|
||||||
dtrain.set_float_info('label_lower_bound', y_lower_bound)
|
dtrain.set_float_info('label_lower_bound', y_lower_bound)
|
||||||
dtrain.set_float_info('label_upper_bound', y_upper_bound)
|
dtrain.set_float_info('label_upper_bound', y_upper_bound)
|
||||||
@@ -120,7 +120,7 @@ Collect the lower bound numbers in one array (let's call it ``y_lower_bound``) a
|
|||||||
# Associate ranged labels with the data matrix.
|
# Associate ranged labels with the data matrix.
|
||||||
# This example shows each kind of censored labels.
|
# This example shows each kind of censored labels.
|
||||||
# uncensored right left interval
|
# uncensored right left interval
|
||||||
y_lower_bound <- c( 2., 3., -Inf, 4.)
|
y_lower_bound <- c( 2., 3., 0., 4.)
|
||||||
y_upper_bound <- c( 2., +Inf, 4., 5.)
|
y_upper_bound <- c( 2., +Inf, 4., 5.)
|
||||||
setinfo(dtrain, 'label_lower_bound', y_lower_bound)
|
setinfo(dtrain, 'label_lower_bound', y_lower_bound)
|
||||||
setinfo(dtrain, 'label_upper_bound', y_upper_bound)
|
setinfo(dtrain, 'label_upper_bound', y_upper_bound)
|
||||||
@@ -136,7 +136,7 @@ Now we are ready to invoke the training API:
|
|||||||
'aft_loss_distribution_scale': 1.20,
|
'aft_loss_distribution_scale': 1.20,
|
||||||
'tree_method': 'hist', 'learning_rate': 0.05, 'max_depth': 2}
|
'tree_method': 'hist', 'learning_rate': 0.05, 'max_depth': 2}
|
||||||
bst = xgb.train(params, dtrain, num_boost_round=5,
|
bst = xgb.train(params, dtrain, num_boost_round=5,
|
||||||
evals=[(dtrain, 'train'), (dvalid, 'valid')])
|
evals=[(dtrain, 'train')])
|
||||||
|
|
||||||
.. code-block:: r
|
.. code-block:: r
|
||||||
:caption: R
|
:caption: R
|
||||||
@@ -165,4 +165,4 @@ Currently, you can choose from three probability distributions for ``aft_loss_di
|
|||||||
``extreme`` :math:`e^z e^{-\exp{z}}`
|
``extreme`` :math:`e^z e^{-\exp{z}}`
|
||||||
========================= ===========================================
|
========================= ===========================================
|
||||||
|
|
||||||
Note that it is not yet possible to set the ranged label using the scikit-learn interface (e.g. :class:`xgboost.XGBRegressor`). For now, you should use :class:`xgboost.train` with :class:`xgboost.DMatrix`.
|
Note that it is not yet possible to set the ranged label using the scikit-learn interface (e.g. :class:`xgboost.XGBRegressor`). For now, you should use :class:`xgboost.train` with :class:`xgboost.DMatrix`.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost-jvm_2.12</artifactId>
|
<artifactId>xgboost-jvm_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>XGBoost JVM Package</name>
|
<name>XGBoost JVM Package</name>
|
||||||
<description>JVM Package for XGBoost</description>
|
<description>JVM Package for XGBoost</description>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost-jvm_2.12</artifactId>
|
<artifactId>xgboost-jvm_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j-example_2.12</artifactId>
|
<artifactId>xgboost4j-example_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j-spark_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-spark_${scala.binary.version}</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.spark</groupId>
|
<groupId>org.apache.spark</groupId>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j-flink_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-flink_${scala.binary.version}</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost-jvm_2.12</artifactId>
|
<artifactId>xgboost-jvm_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j-flink_2.12</artifactId>
|
<artifactId>xgboost4j-flink_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost-jvm_2.12</artifactId>
|
<artifactId>xgboost-jvm_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j-spark_2.12</artifactId>
|
<artifactId>xgboost4j-spark_2.12</artifactId>
|
||||||
<build>
|
<build>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.spark</groupId>
|
<groupId>org.apache.spark</groupId>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost-jvm_2.12</artifactId>
|
<artifactId>xgboost-jvm_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j_2.12</artifactId>
|
<artifactId>xgboost4j_2.12</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.1.0
|
1.1.1
|
||||||
|
|||||||
@@ -1467,6 +1467,7 @@ class Booster(object):
|
|||||||
self._validate_features(data)
|
self._validate_features(data)
|
||||||
return self.eval_set([(data, name)], iteration)
|
return self.eval_set([(data, name)], iteration)
|
||||||
|
|
||||||
|
# pylint: disable=too-many-function-args
|
||||||
def predict(self,
|
def predict(self,
|
||||||
data,
|
data,
|
||||||
output_margin=False,
|
output_margin=False,
|
||||||
@@ -1588,7 +1589,7 @@ class Booster(object):
|
|||||||
ngroup = int(chunk_size / ((data.num_col() + 1) *
|
ngroup = int(chunk_size / ((data.num_col() + 1) *
|
||||||
(data.num_col() + 1)))
|
(data.num_col() + 1)))
|
||||||
if ngroup == 1:
|
if ngroup == 1:
|
||||||
preds = preds.reshape(nrow,
|
preds = preds.reshape(nrow, # pylint: disable=too-many-function-args
|
||||||
data.num_col() + 1,
|
data.num_col() + 1,
|
||||||
data.num_col() + 1)
|
data.num_col() + 1)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -689,15 +689,23 @@ class LearnerIO : public LearnerConfiguration {
|
|||||||
warn_old_model = false;
|
warn_old_model = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mparam_.major_version >= 1) {
|
if (mparam_.major_version < 1) {
|
||||||
learner_model_param_ = LearnerModelParam(mparam_,
|
|
||||||
obj_->ProbToMargin(mparam_.base_score));
|
|
||||||
} else {
|
|
||||||
// Before 1.0.0, base_score is saved as a transformed value, and there's no version
|
// Before 1.0.0, base_score is saved as a transformed value, and there's no version
|
||||||
// attribute in the saved model.
|
// attribute (saved a 0) in the saved model.
|
||||||
learner_model_param_ = LearnerModelParam(mparam_, mparam_.base_score);
|
std::string multi{"multi:"};
|
||||||
|
if (!std::equal(multi.cbegin(), multi.cend(), tparam_.objective.cbegin())) {
|
||||||
|
HostDeviceVector<float> t;
|
||||||
|
t.HostVector().resize(1);
|
||||||
|
t.HostVector().at(0) = mparam_.base_score;
|
||||||
|
this->obj_->PredTransform(&t);
|
||||||
|
auto base_score = t.HostVector().at(0);
|
||||||
|
mparam_.base_score = base_score;
|
||||||
|
}
|
||||||
warn_old_model = true;
|
warn_old_model = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
learner_model_param_ =
|
||||||
|
LearnerModelParam(mparam_, obj_->ProbToMargin(mparam_.base_score));
|
||||||
if (attributes_.find("objective") != attributes_.cend()) {
|
if (attributes_.find("objective") != attributes_.cend()) {
|
||||||
auto obj_str = attributes_.at("objective");
|
auto obj_str = attributes_.at("objective");
|
||||||
auto j_obj = Json::Load({obj_str.c_str(), obj_str.size()});
|
auto j_obj = Json::Load({obj_str.c_str(), obj_str.size()});
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ struct RegLossParam : public XGBoostParameter<RegLossParam> {
|
|||||||
template<typename Loss>
|
template<typename Loss>
|
||||||
class RegLossObj : public ObjFunction {
|
class RegLossObj : public ObjFunction {
|
||||||
protected:
|
protected:
|
||||||
HostDeviceVector<int> label_correct_;
|
HostDeviceVector<float> additional_input_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RegLossObj() = default;
|
// 0 - label_correct flag, 1 - scale_pos_weight, 2 - is_null_weight
|
||||||
|
RegLossObj(): additional_input_(3) {}
|
||||||
|
|
||||||
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
||||||
param_.UpdateAllowUnknown(args);
|
param_.UpdateAllowUnknown(args);
|
||||||
@@ -64,8 +65,7 @@ class RegLossObj : public ObjFunction {
|
|||||||
size_t const ndata = preds.Size();
|
size_t const ndata = preds.Size();
|
||||||
out_gpair->Resize(ndata);
|
out_gpair->Resize(ndata);
|
||||||
auto device = tparam_->gpu_id;
|
auto device = tparam_->gpu_id;
|
||||||
label_correct_.Resize(1);
|
additional_input_.HostVector().begin()[0] = 1; // Fill the label_correct flag
|
||||||
label_correct_.Fill(1);
|
|
||||||
|
|
||||||
bool is_null_weight = info.weights_.Size() == 0;
|
bool is_null_weight = info.weights_.Size() == 0;
|
||||||
if (!is_null_weight) {
|
if (!is_null_weight) {
|
||||||
@@ -73,35 +73,37 @@ class RegLossObj : public ObjFunction {
|
|||||||
<< "Number of weights should be equal to number of data points.";
|
<< "Number of weights should be equal to number of data points.";
|
||||||
}
|
}
|
||||||
auto scale_pos_weight = param_.scale_pos_weight;
|
auto scale_pos_weight = param_.scale_pos_weight;
|
||||||
common::Transform<>::Init(
|
additional_input_.HostVector().begin()[1] = scale_pos_weight;
|
||||||
[=] XGBOOST_DEVICE(size_t _idx,
|
additional_input_.HostVector().begin()[2] = is_null_weight;
|
||||||
common::Span<int> _label_correct,
|
|
||||||
|
common::Transform<>::Init([] XGBOOST_DEVICE(size_t _idx,
|
||||||
|
common::Span<float> _additional_input,
|
||||||
common::Span<GradientPair> _out_gpair,
|
common::Span<GradientPair> _out_gpair,
|
||||||
common::Span<const bst_float> _preds,
|
common::Span<const bst_float> _preds,
|
||||||
common::Span<const bst_float> _labels,
|
common::Span<const bst_float> _labels,
|
||||||
common::Span<const bst_float> _weights) {
|
common::Span<const bst_float> _weights) {
|
||||||
|
const float _scale_pos_weight = _additional_input[1];
|
||||||
|
const bool _is_null_weight = _additional_input[2];
|
||||||
|
|
||||||
bst_float p = Loss::PredTransform(_preds[_idx]);
|
bst_float p = Loss::PredTransform(_preds[_idx]);
|
||||||
bst_float w = is_null_weight ? 1.0f : _weights[_idx];
|
bst_float w = _is_null_weight ? 1.0f : _weights[_idx];
|
||||||
bst_float label = _labels[_idx];
|
bst_float label = _labels[_idx];
|
||||||
if (label == 1.0f) {
|
if (label == 1.0f) {
|
||||||
w *= scale_pos_weight;
|
w *= _scale_pos_weight;
|
||||||
}
|
}
|
||||||
if (!Loss::CheckLabel(label)) {
|
if (!Loss::CheckLabel(label)) {
|
||||||
// If there is an incorrect label, the host code will know.
|
// If there is an incorrect label, the host code will know.
|
||||||
_label_correct[0] = 0;
|
_additional_input[0] = 0;
|
||||||
}
|
}
|
||||||
_out_gpair[_idx] = GradientPair(Loss::FirstOrderGradient(p, label) * w,
|
_out_gpair[_idx] = GradientPair(Loss::FirstOrderGradient(p, label) * w,
|
||||||
Loss::SecondOrderGradient(p, label) * w);
|
Loss::SecondOrderGradient(p, label) * w);
|
||||||
},
|
},
|
||||||
common::Range{0, static_cast<int64_t>(ndata)}, device).Eval(
|
common::Range{0, static_cast<int64_t>(ndata)}, device).Eval(
|
||||||
&label_correct_, out_gpair, &preds, &info.labels_, &info.weights_);
|
&additional_input_, out_gpair, &preds, &info.labels_, &info.weights_);
|
||||||
|
|
||||||
// copy "label correct" flags back to host
|
auto const flag = additional_input_.HostVector().begin()[0];
|
||||||
std::vector<int>& label_correct_h = label_correct_.HostVector();
|
if (flag == 0) {
|
||||||
for (auto const flag : label_correct_h) {
|
LOG(FATAL) << Loss::LabelErrorMsg();
|
||||||
if (flag == 0) {
|
|
||||||
LOG(FATAL) << Loss::LabelErrorMsg();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
markers =
|
markers =
|
||||||
mgpu: Mark a test that requires multiple GPUs to run.
|
mgpu: Mark a test that requires multiple GPUs to run.
|
||||||
|
ci: Mark a test that runs only on CI.
|
||||||
@@ -4,6 +4,7 @@ import generate_models as gm
|
|||||||
import json
|
import json
|
||||||
import zipfile
|
import zipfile
|
||||||
import pytest
|
import pytest
|
||||||
|
import copy
|
||||||
|
|
||||||
|
|
||||||
def run_model_param_check(config):
|
def run_model_param_check(config):
|
||||||
@@ -124,6 +125,9 @@ def test_model_compatibility():
|
|||||||
if name.startswith('xgboost-'):
|
if name.startswith('xgboost-'):
|
||||||
booster = xgboost.Booster(model_file=path)
|
booster = xgboost.Booster(model_file=path)
|
||||||
run_booster_check(booster, name)
|
run_booster_check(booster, name)
|
||||||
|
# Do full serialization.
|
||||||
|
booster = copy.copy(booster)
|
||||||
|
run_booster_check(booster, name)
|
||||||
elif name.startswith('xgboost_scikit'):
|
elif name.startswith('xgboost_scikit'):
|
||||||
run_scikit_model_check(name, path)
|
run_scikit_model_check(name, path)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user