Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
917b0a7b46 | ||
|
|
58ebbab979 | ||
|
|
2bc5d8d449 | ||
|
|
7d178cbd25 | ||
|
|
74e2f652de | ||
|
|
e02fff53f2 | ||
|
|
fcb2efbadd | ||
|
|
f4621f09c7 | ||
|
|
bf1b2cbfa2 | ||
|
|
d90e7b3117 | ||
|
|
088c43d666 |
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
project(xgboost LANGUAGES CXX C VERSION 1.0.0)
|
project(xgboost LANGUAGES CXX C VERSION 1.0.2)
|
||||||
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)
|
||||||
|
|||||||
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@@ -273,6 +273,7 @@ def TestPythonCPU() {
|
|||||||
def docker_binary = "docker"
|
def docker_binary = "docker"
|
||||||
sh """
|
sh """
|
||||||
${dockerRun} ${container_type} ${docker_binary} tests/ci_build/test_python.sh cpu
|
${dockerRun} ${container_type} ${docker_binary} tests/ci_build/test_python.sh cpu
|
||||||
|
${dockerRun} ${container_type} ${docker_binary} tests/ci_build/test_python.sh cpu-py35
|
||||||
"""
|
"""
|
||||||
deleteDir()
|
deleteDir()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
@xgboost_VERSION_MAJOR@.@xgboost_VERSION_MINOR@.@xgboost_VERSION_PATCH@rc2
|
@xgboost_VERSION_MAJOR@.@xgboost_VERSION_MINOR@.@xgboost_VERSION_PATCH@
|
||||||
|
|||||||
@@ -195,12 +195,22 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"version": {
|
"version": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"const": [
|
"items": [
|
||||||
1,
|
{
|
||||||
0,
|
"type": "number",
|
||||||
0
|
"const": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"additionalItems": false
|
"minItems": 3,
|
||||||
|
"maxItems": 3
|
||||||
},
|
},
|
||||||
"learner": {
|
"learner": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|||||||
@@ -195,7 +195,9 @@ You can load it back to the model generated by same version of XGBoost by:
|
|||||||
|
|
||||||
bst.load_config(config)
|
bst.load_config(config)
|
||||||
|
|
||||||
This way users can study the internal representation more closely.
|
This way users can study the internal representation more closely. Please note that some
|
||||||
|
JSON generators make use of locale dependent floating point serialization methods, which
|
||||||
|
is not supported by XGBoost.
|
||||||
|
|
||||||
************
|
************
|
||||||
Future Plans
|
Future Plans
|
||||||
|
|||||||
@@ -6,6 +6,6 @@
|
|||||||
|
|
||||||
#define XGBOOST_VER_MAJOR 1
|
#define XGBOOST_VER_MAJOR 1
|
||||||
#define XGBOOST_VER_MINOR 0
|
#define XGBOOST_VER_MINOR 0
|
||||||
#define XGBOOST_VER_PATCH 0
|
#define XGBOOST_VER_PATCH 1
|
||||||
|
|
||||||
#endif // XGBOOST_VERSION_CONFIG_H_
|
#endif // XGBOOST_VERSION_CONFIG_H_
|
||||||
|
|||||||
@@ -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.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j-example_2.12</artifactId>
|
<artifactId>xgboost4j-example_2.12</artifactId>
|
||||||
<version>1.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j-flink_2.12</artifactId>
|
<artifactId>xgboost4j-flink_2.12</artifactId>
|
||||||
<version>1.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</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.0.0-RC2</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j_2.12</artifactId>
|
<artifactId>xgboost4j_2.12</artifactId>
|
||||||
<version>1.0.0-RC2</version>
|
<version>1.0.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0.0rc2
|
1.0.2
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ Contributors: https://github.com/dmlc/xgboost/blob/master/CONTRIBUTORS.md
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
import warnings
|
||||||
|
|
||||||
from .core import DMatrix, Booster
|
from .core import DMatrix, Booster
|
||||||
from .training import train, cv
|
from .training import train, cv
|
||||||
@@ -19,6 +21,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if sys.version_info[:2] == (3, 5):
|
||||||
|
warnings.warn(
|
||||||
|
'Python 3.5 support is deprecated; XGBoost will require Python 3.6+ in the near future. ' +
|
||||||
|
'Consider upgrading to Python 3.6+.',
|
||||||
|
FutureWarning)
|
||||||
|
|
||||||
VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
|
VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
|
||||||
with open(VERSION_FILE) as f:
|
with open(VERSION_FILE) as f:
|
||||||
__version__ = f.read().strip()
|
__version__ = f.read().strip()
|
||||||
|
|||||||
@@ -79,6 +79,14 @@ else:
|
|||||||
# END NUMPY PATHLIB ATTRIBUTION
|
# END NUMPY PATHLIB ATTRIBUTION
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
def lazy_isinstance(instance, module, name):
|
||||||
|
'''Use string representation to identify a type.'''
|
||||||
|
module = type(instance).__module__ == module
|
||||||
|
name = type(instance).__name__ == name
|
||||||
|
return module and name
|
||||||
|
|
||||||
|
|
||||||
# pandas
|
# pandas
|
||||||
try:
|
try:
|
||||||
from pandas import DataFrame, Series
|
from pandas import DataFrame, Series
|
||||||
@@ -95,27 +103,6 @@ except ImportError:
|
|||||||
pandas_concat = None
|
pandas_concat = None
|
||||||
PANDAS_INSTALLED = False
|
PANDAS_INSTALLED = False
|
||||||
|
|
||||||
# dt
|
|
||||||
try:
|
|
||||||
# Workaround for #4473, compatibility with dask
|
|
||||||
if sys.__stdin__ is not None and sys.__stdin__.closed:
|
|
||||||
sys.__stdin__ = None
|
|
||||||
import datatable
|
|
||||||
|
|
||||||
if hasattr(datatable, "Frame"):
|
|
||||||
DataTable = datatable.Frame
|
|
||||||
else:
|
|
||||||
DataTable = datatable.DataTable
|
|
||||||
DT_INSTALLED = True
|
|
||||||
except ImportError:
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
|
||||||
class DataTable(object):
|
|
||||||
""" dummy for datatable.DataTable """
|
|
||||||
|
|
||||||
DT_INSTALLED = False
|
|
||||||
|
|
||||||
|
|
||||||
# cudf
|
# cudf
|
||||||
try:
|
try:
|
||||||
from cudf import DataFrame as CUDF_DataFrame
|
from cudf import DataFrame as CUDF_DataFrame
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ import scipy.sparse
|
|||||||
|
|
||||||
from .compat import (
|
from .compat import (
|
||||||
STRING_TYPES, DataFrame, MultiIndex, Int64Index, py_str,
|
STRING_TYPES, DataFrame, MultiIndex, Int64Index, py_str,
|
||||||
PANDAS_INSTALLED, DataTable,
|
PANDAS_INSTALLED, CUDF_INSTALLED,
|
||||||
CUDF_INSTALLED, CUDF_DataFrame, CUDF_Series, CUDF_MultiIndex,
|
CUDF_DataFrame, CUDF_Series, CUDF_MultiIndex,
|
||||||
os_fspath, os_PathLike)
|
os_fspath, os_PathLike, lazy_isinstance)
|
||||||
from .libpath import find_lib_path
|
from .libpath import find_lib_path
|
||||||
|
|
||||||
# c_bst_ulong corresponds to bst_ulong defined in xgboost/c_api.h
|
# c_bst_ulong corresponds to bst_ulong defined in xgboost/c_api.h
|
||||||
@@ -319,7 +319,8 @@ DT_TYPE_MAPPER2 = {'bool': 'i', 'int': 'int', 'real': 'float'}
|
|||||||
def _maybe_dt_data(data, feature_names, feature_types,
|
def _maybe_dt_data(data, feature_names, feature_types,
|
||||||
meta=None, meta_type=None):
|
meta=None, meta_type=None):
|
||||||
"""Validate feature names and types if data table"""
|
"""Validate feature names and types if data table"""
|
||||||
if not isinstance(data, DataTable):
|
if (not lazy_isinstance(data, 'datatable', 'Frame') and
|
||||||
|
not lazy_isinstance(data, 'datatable', 'DataTable')):
|
||||||
return data, feature_names, feature_types
|
return data, feature_names, feature_types
|
||||||
|
|
||||||
if meta and data.shape[1] > 1:
|
if meta and data.shape[1] > 1:
|
||||||
@@ -470,7 +471,7 @@ class DMatrix(object):
|
|||||||
self._init_from_csc(data)
|
self._init_from_csc(data)
|
||||||
elif isinstance(data, np.ndarray):
|
elif isinstance(data, np.ndarray):
|
||||||
self._init_from_npy2d(data, missing, nthread)
|
self._init_from_npy2d(data, missing, nthread)
|
||||||
elif isinstance(data, DataTable):
|
elif lazy_isinstance(data, 'datatable', 'Frame'):
|
||||||
self._init_from_dt(data, nthread)
|
self._init_from_dt(data, nthread)
|
||||||
elif hasattr(data, "__cuda_array_interface__"):
|
elif hasattr(data, "__cuda_array_interface__"):
|
||||||
self._init_from_array_interface(data, missing, nthread)
|
self._init_from_array_interface(data, missing, nthread)
|
||||||
@@ -1052,7 +1053,7 @@ class Booster(object):
|
|||||||
_check_call(
|
_check_call(
|
||||||
_LIB.XGBoosterUnserializeFromBuffer(self.handle, ptr, length))
|
_LIB.XGBoosterUnserializeFromBuffer(self.handle, ptr, length))
|
||||||
self.__dict__.update(state)
|
self.__dict__.update(state)
|
||||||
elif isinstance(model_file, (STRING_TYPES, os_PathLike)):
|
elif isinstance(model_file, (STRING_TYPES, os_PathLike, bytearray)):
|
||||||
self.load_model(model_file)
|
self.load_model(model_file)
|
||||||
elif model_file is None:
|
elif model_file is None:
|
||||||
pass
|
pass
|
||||||
@@ -1512,7 +1513,8 @@ class Booster(object):
|
|||||||
return ctypes2buffer(cptr, length.value)
|
return ctypes2buffer(cptr, length.value)
|
||||||
|
|
||||||
def load_model(self, fname):
|
def load_model(self, fname):
|
||||||
"""Load the model from a file, local or as URI.
|
"""Load the model from a file or bytearray. Path to file can be local
|
||||||
|
or as an URI.
|
||||||
|
|
||||||
The model is loaded from an XGBoost format which is universal among the
|
The model is loaded from an XGBoost format which is universal among the
|
||||||
various XGBoost interfaces. Auxiliary attributes of the Python Booster
|
various XGBoost interfaces. Auxiliary attributes of the Python Booster
|
||||||
@@ -1530,6 +1532,12 @@ class Booster(object):
|
|||||||
# from URL.
|
# from URL.
|
||||||
_check_call(_LIB.XGBoosterLoadModel(
|
_check_call(_LIB.XGBoosterLoadModel(
|
||||||
self.handle, c_str(os_fspath(fname))))
|
self.handle, c_str(os_fspath(fname))))
|
||||||
|
elif isinstance(fname, bytearray):
|
||||||
|
buf = fname
|
||||||
|
length = c_bst_ulong(len(buf))
|
||||||
|
ptr = (ctypes.c_char * len(buf)).from_buffer(buf)
|
||||||
|
_check_call(_LIB.XGBoosterLoadModelFromBuffer(self.handle, ptr,
|
||||||
|
length))
|
||||||
else:
|
else:
|
||||||
raise TypeError('Unknown file type: ', fname)
|
raise TypeError('Unknown file type: ', fname)
|
||||||
|
|
||||||
|
|||||||
@@ -434,8 +434,8 @@ class XGBModel(XGBModelBase):
|
|||||||
self.classes_ = np.array(v)
|
self.classes_ = np.array(v)
|
||||||
continue
|
continue
|
||||||
if k == 'type' and type(self).__name__ != v:
|
if k == 'type' and type(self).__name__ != v:
|
||||||
msg = f'Current model type: {type(self).__name__}, ' + \
|
msg = 'Current model type: {}, '.format(type(self).__name__) + \
|
||||||
f'type of model in file: {v}'
|
'type of model in file: {}'.format(v)
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
if k == 'type':
|
if k == 'type':
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ def _train_internal(params, dtrain,
|
|||||||
|
|
||||||
_params = dict(params) if isinstance(params, list) else params
|
_params = dict(params) if isinstance(params, list) else params
|
||||||
|
|
||||||
if 'num_parallel_tree' in _params and params[
|
if 'num_parallel_tree' in _params and _params[
|
||||||
'num_parallel_tree'] is not None:
|
'num_parallel_tree'] is not None:
|
||||||
num_parallel_tree = _params['num_parallel_tree']
|
num_parallel_tree = _params['num_parallel_tree']
|
||||||
nboost //= num_parallel_tree
|
nboost //= num_parallel_tree
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* Copyright (c) by Contributors 2019
|
* Copyright (c) by Contributors 2019
|
||||||
*/
|
*/
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <locale>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -692,47 +693,23 @@ Json JsonReader::ParseBoolean() {
|
|||||||
return Json{JsonBoolean{result}};
|
return Json{JsonBoolean{result}};
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is an ad-hoc solution for writing numeric value in standard way. We need to add
|
|
||||||
// a locale independent way of writing stream like `std::{from, to}_chars' from C++-17.
|
|
||||||
// FIXME(trivialfis): Remove this.
|
|
||||||
class GlobalCLocale {
|
|
||||||
std::locale ori_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
GlobalCLocale() : ori_{std::locale()} {
|
|
||||||
std::string const name {"C"};
|
|
||||||
try {
|
|
||||||
std::locale::global(std::locale(name.c_str()));
|
|
||||||
} catch (std::runtime_error const& e) {
|
|
||||||
LOG(FATAL) << "Failed to set locale: " << name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~GlobalCLocale() {
|
|
||||||
std::locale::global(ori_);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Json Json::Load(StringView str) {
|
Json Json::Load(StringView str) {
|
||||||
GlobalCLocale guard;
|
|
||||||
JsonReader reader(str);
|
JsonReader reader(str);
|
||||||
Json json{reader.Load()};
|
Json json{reader.Load()};
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json Json::Load(JsonReader* reader) {
|
Json Json::Load(JsonReader* reader) {
|
||||||
GlobalCLocale guard;
|
|
||||||
Json json{reader->Load()};
|
Json json{reader->Load()};
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Json::Dump(Json json, std::ostream *stream, bool pretty) {
|
void Json::Dump(Json json, std::ostream *stream, bool pretty) {
|
||||||
GlobalCLocale guard;
|
|
||||||
JsonWriter writer(stream, pretty);
|
JsonWriter writer(stream, pretty);
|
||||||
writer.Save(json);
|
writer.Save(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Json::Dump(Json json, std::string* str, bool pretty) {
|
void Json::Dump(Json json, std::string* str, bool pretty) {
|
||||||
GlobalCLocale guard;
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
JsonWriter writer(&ss, pretty);
|
JsonWriter writer(&ss, pretty);
|
||||||
writer.Save(json);
|
writer.Save(json);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ ARG CMAKE_VERSION=3.12
|
|||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
SHELL ["/bin/bash", "-c"] # Use Bash as shell
|
||||||
|
|
||||||
# Install all basic requirements
|
# Install all basic requirements
|
||||||
RUN \
|
RUN \
|
||||||
@@ -19,10 +20,16 @@ ENV PATH=/opt/python/bin:$PATH
|
|||||||
|
|
||||||
ENV GOSU_VERSION 1.10
|
ENV GOSU_VERSION 1.10
|
||||||
|
|
||||||
# Install Python packages
|
# Create new Conda environment with Python 3.5
|
||||||
|
RUN conda create -n py35 python=3.5 && \
|
||||||
|
source activate py35 && \
|
||||||
|
pip install numpy pytest scipy scikit-learn pandas matplotlib wheel kubernetes urllib3 graphviz && \
|
||||||
|
source deactivate
|
||||||
|
|
||||||
|
# Install Python packages in default env
|
||||||
RUN \
|
RUN \
|
||||||
pip install pyyaml cpplint pylint astroid sphinx numpy scipy pandas matplotlib sh \
|
pip install pyyaml cpplint pylint astroid sphinx numpy scipy pandas matplotlib sh \
|
||||||
recommonmark guzzle_sphinx_theme mock breathe matplotlib graphviz \
|
recommonmark guzzle_sphinx_theme mock breathe graphviz \
|
||||||
pytest scikit-learn wheel kubernetes urllib3 jsonschema boto3 && \
|
pytest scikit-learn wheel kubernetes urllib3 jsonschema boto3 && \
|
||||||
pip install https://h2o-release.s3.amazonaws.com/datatable/stable/datatable-0.7.0/datatable-0.7.0-cp37-cp37m-linux_x86_64.whl && \
|
pip install https://h2o-release.s3.amazonaws.com/datatable/stable/datatable-0.7.0/datatable-0.7.0-cp37-cp37m-linux_x86_64.whl && \
|
||||||
pip install "dask[complete]"
|
pip install "dask[complete]"
|
||||||
|
|||||||
@@ -5,31 +5,35 @@ set -x
|
|||||||
suite=$1
|
suite=$1
|
||||||
|
|
||||||
# Install XGBoost Python package
|
# Install XGBoost Python package
|
||||||
wheel_found=0
|
function install_xgboost {
|
||||||
for file in python-package/dist/*.whl
|
wheel_found=0
|
||||||
do
|
for file in python-package/dist/*.whl
|
||||||
if [ -e "${file}" ]
|
do
|
||||||
|
if [ -e "${file}" ]
|
||||||
|
then
|
||||||
|
pip install --user "${file}"
|
||||||
|
wheel_found=1
|
||||||
|
break # need just one
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$wheel_found" -eq 0 ]
|
||||||
then
|
then
|
||||||
pip install --user "${file}"
|
pushd .
|
||||||
wheel_found=1
|
cd python-package
|
||||||
break # need just one
|
python setup.py install --user
|
||||||
|
popd
|
||||||
fi
|
fi
|
||||||
done
|
}
|
||||||
if [ "$wheel_found" -eq 0 ]
|
|
||||||
then
|
|
||||||
pushd .
|
|
||||||
cd python-package
|
|
||||||
python setup.py install --user
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run specified test suite
|
# Run specified test suite
|
||||||
case "$suite" in
|
case "$suite" in
|
||||||
gpu)
|
gpu)
|
||||||
|
install_xgboost
|
||||||
pytest -v -s --fulltrace -m "not mgpu" tests/python-gpu
|
pytest -v -s --fulltrace -m "not mgpu" tests/python-gpu
|
||||||
;;
|
;;
|
||||||
|
|
||||||
mgpu)
|
mgpu)
|
||||||
|
install_xgboost
|
||||||
pytest -v -s --fulltrace -m "mgpu" tests/python-gpu
|
pytest -v -s --fulltrace -m "mgpu" tests/python-gpu
|
||||||
cd tests/distributed
|
cd tests/distributed
|
||||||
./runtests-gpu.sh
|
./runtests-gpu.sh
|
||||||
@@ -39,17 +43,25 @@ case "$suite" in
|
|||||||
|
|
||||||
cudf)
|
cudf)
|
||||||
source activate cudf_test
|
source activate cudf_test
|
||||||
|
install_xgboost
|
||||||
pytest -v -s --fulltrace -m "not mgpu" tests/python-gpu/test_from_columnar.py tests/python-gpu/test_from_cupy.py
|
pytest -v -s --fulltrace -m "not mgpu" tests/python-gpu/test_from_columnar.py tests/python-gpu/test_from_cupy.py
|
||||||
;;
|
;;
|
||||||
|
|
||||||
cpu)
|
cpu)
|
||||||
|
install_xgboost
|
||||||
pytest -v -s --fulltrace tests/python
|
pytest -v -s --fulltrace tests/python
|
||||||
cd tests/distributed
|
cd tests/distributed
|
||||||
./runtests.sh
|
./runtests.sh
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
cpu-py35)
|
||||||
|
source activate py35
|
||||||
|
install_xgboost
|
||||||
|
pytest -v -s --fulltrace tests/python
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {gpu|mgpu|cudf|cpu}"
|
echo "Usage: $0 {gpu|mgpu|cudf|cpu|cpu-py35}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ TEST(Version, Basic) {
|
|||||||
|
|
||||||
ptr = 0;
|
ptr = 0;
|
||||||
v = std::stoi(str, &ptr);
|
v = std::stoi(str, &ptr);
|
||||||
ASSERT_EQ(v, XGBOOST_VER_MINOR) << "patch: " << v;;
|
ASSERT_EQ(v, XGBOOST_VER_PATCH) << "patch: " << v;;
|
||||||
|
|
||||||
str = str.substr(ptr);
|
str = str.substr(ptr);
|
||||||
ASSERT_EQ(str.size(), 0);
|
ASSERT_EQ(str.size(), 0);
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ def captured_output():
|
|||||||
|
|
||||||
|
|
||||||
class TestBasic(unittest.TestCase):
|
class TestBasic(unittest.TestCase):
|
||||||
|
def test_compat(self):
|
||||||
|
from xgboost.compat import lazy_isinstance
|
||||||
|
a = np.array([1, 2, 3])
|
||||||
|
assert lazy_isinstance(a, 'numpy', 'ndarray')
|
||||||
|
assert not lazy_isinstance(a, 'numpy', 'dataframe')
|
||||||
|
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
dtrain = xgb.DMatrix(dpath + 'agaricus.txt.train')
|
dtrain = xgb.DMatrix(dpath + 'agaricus.txt.train')
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
import testing as tm
|
import testing as tm
|
||||||
import pytest
|
import pytest
|
||||||
|
import locale
|
||||||
|
|
||||||
dpath = 'demo/data/'
|
dpath = 'demo/data/'
|
||||||
dtrain = xgb.DMatrix(dpath + 'agaricus.txt.train')
|
dtrain = xgb.DMatrix(dpath + 'agaricus.txt.train')
|
||||||
@@ -299,7 +300,15 @@ class TestModels(unittest.TestCase):
|
|||||||
assert float(config['learner']['objective'][
|
assert float(config['learner']['objective'][
|
||||||
'reg_loss_param']['scale_pos_weight']) == 0.5
|
'reg_loss_param']['scale_pos_weight']) == 0.5
|
||||||
|
|
||||||
|
buf = bst.save_raw()
|
||||||
|
from_raw = xgb.Booster()
|
||||||
|
from_raw.load_model(buf)
|
||||||
|
|
||||||
|
buf_from_raw = from_raw.save_raw()
|
||||||
|
assert buf == buf_from_raw
|
||||||
|
|
||||||
def test_model_json_io(self):
|
def test_model_json_io(self):
|
||||||
|
loc = locale.getpreferredencoding(False)
|
||||||
model_path = 'test_model_json_io.json'
|
model_path = 'test_model_json_io.json'
|
||||||
parameters = {'tree_method': 'hist', 'booster': 'gbtree'}
|
parameters = {'tree_method': 'hist', 'booster': 'gbtree'}
|
||||||
j_model = json_model(model_path, parameters)
|
j_model = json_model(model_path, parameters)
|
||||||
@@ -313,6 +322,7 @@ class TestModels(unittest.TestCase):
|
|||||||
assert isinstance(j_model['learner'], dict)
|
assert isinstance(j_model['learner'], dict)
|
||||||
|
|
||||||
os.remove(model_path)
|
os.remove(model_path)
|
||||||
|
assert locale.getpreferredencoding(False) == loc
|
||||||
|
|
||||||
@pytest.mark.skipif(**tm.no_json_schema())
|
@pytest.mark.skipif(**tm.no_json_schema())
|
||||||
def test_json_schema(self):
|
def test_json_schema(self):
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ def test_binary_classification():
|
|||||||
kf = KFold(n_splits=2, shuffle=True, random_state=rng)
|
kf = KFold(n_splits=2, shuffle=True, random_state=rng)
|
||||||
for cls in (xgb.XGBClassifier, xgb.XGBRFClassifier):
|
for cls in (xgb.XGBClassifier, xgb.XGBRFClassifier):
|
||||||
for train_index, test_index in kf.split(X, y):
|
for train_index, test_index in kf.split(X, y):
|
||||||
xgb_model = cls(random_state=42).fit(X[train_index], y[train_index])
|
clf = cls(random_state=42)
|
||||||
|
xgb_model = clf.fit(X[train_index], y[train_index], eval_metric=['auc', 'logloss'])
|
||||||
preds = xgb_model.predict(X[test_index])
|
preds = xgb_model.predict(X[test_index])
|
||||||
labels = y[test_index]
|
labels = y[test_index]
|
||||||
err = sum(1 for i in range(len(preds))
|
err = sum(1 for i in range(len(preds))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from xgboost.compat import SKLEARN_INSTALLED, PANDAS_INSTALLED, DT_INSTALLED
|
from xgboost.compat import SKLEARN_INSTALLED, PANDAS_INSTALLED
|
||||||
from xgboost.compat import CUDF_INSTALLED, DASK_INSTALLED
|
from xgboost.compat import CUDF_INSTALLED, DASK_INSTALLED
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +19,9 @@ def no_pandas():
|
|||||||
|
|
||||||
|
|
||||||
def no_dt():
|
def no_dt():
|
||||||
return {'condition': not DT_INSTALLED,
|
import importlib.util
|
||||||
|
spec = importlib.util.find_spec('datatable')
|
||||||
|
return {'condition': spec is None,
|
||||||
'reason': 'Datatable is not installed.'}
|
'reason': 'Datatable is not installed.'}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user