diff --git a/Makefile b/Makefile index 531676a4e..84636bd71 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -export CC = $(if $(shell which gcc-5),gcc-5,gcc) -export CXX = $(if $(shell which g++-5),g++-5,g++) +export CC = $(if $(shell which gcc-5 2>/dev/null),gcc-5,gcc) +export CXX = $(if $(shell which g++-5 2>/dev/null),g++-5,g++) export MPICXX = mpicxx export LDFLAGS= -pthread -lm diff --git a/doc/model.md b/doc/model.md index 7874a4cfc..dd92cf6dc 100644 --- a/doc/model.md +++ b/doc/model.md @@ -188,7 +188,7 @@ By defining it formally, we can get a better idea of what we are learning, and y Here is the magical part of the derivation. After reformalizing the tree model, we can write the objective value with the ``$ t$``-th tree as: ```math -Obj^{(t)} &\approx \sum_{i=1}^n [g_i w_q(x_i) + \frac{1}{2} h_i w_{q(x_i)}^2] + \gamma T + \frac{1}{2}\lambda \sum_{j=1}^T w_j^2\\ +Obj^{(t)} &\approx \sum_{i=1}^n [g_i w_{q(x_i)} + \frac{1}{2} h_i w_{q(x_i)}^2] + \gamma T + \frac{1}{2}\lambda \sum_{j=1}^T w_j^2\\ &= \sum^T_{j=1} [(\sum_{i\in I_j} g_i) w_j + \frac{1}{2} (\sum_{i\in I_j} h_i + \lambda) w_j^2 ] + \gamma T ``` diff --git a/java/create_wrap.sh b/java/create_wrap.sh index fd8b46add..8462ab7af 100755 --- a/java/create_wrap.sh +++ b/java/create_wrap.sh @@ -1,11 +1,18 @@ +#!/usr/bin/env sh echo "build java wrapper" -dylib="so" + +# cd to script's directory +pushd `dirname $0` > /dev/null + +#settings according to os +dl="so" omp="0" if [ $(uname) == "Darwin" ]; then export JAVA_HOME=$(/usr/libexec/java_home) - dylib="dylib" + dl="dylib" omp="1" fi + cd .. make java no_omp=${omp} cd java @@ -16,7 +23,8 @@ if [ ! -d "$libPath" ]; then mkdir -p "$libPath" fi -rm -f xgboost4j/src/main/resources/lib/libxgboost4j.${dylib} -mv libxgboost4j.so xgboost4j/src/main/resources/lib/libxgboost4j.${dylib} +rm -f xgboost4j/src/main/resources/lib/libxgboost4j.${dl} +mv libxgboost4j.so xgboost4j/src/main/resources/lib/libxgboost4j.${dl} +popd > /dev/null echo "complete" diff --git a/python-package/xgboost/training.py b/python-package/xgboost/training.py index e47db0bc6..fd7565e52 100644 --- a/python-package/xgboost/training.py +++ b/python-package/xgboost/training.py @@ -117,7 +117,7 @@ def train(params, dtrain, num_boost_round=10, evals=(), obj=None, feval=None, evals_result.update(dict([(key, {}) for key in evals_name])) if not early_stopping_rounds: - for i in range(num_boost_round): + for i in range(nboost, nboost + num_boost_round): bst.update(dtrain, i, obj) nboost += 1 if len(evals) != 0: @@ -189,7 +189,7 @@ def train(params, dtrain, num_boost_round=10, evals=(), obj=None, feval=None, if isinstance(learning_rates, list) and len(learning_rates) != num_boost_round: raise ValueError("Length of list 'learning_rates' has to equal 'num_boost_round'.") - for i in range(num_boost_round): + for i in range(nboost, nboost + num_boost_round): if learning_rates is not None: if isinstance(learning_rates, list): bst.set_param({'eta': learning_rates[i]}) @@ -337,7 +337,8 @@ def aggcv(rlist, show_stdv=True, show_progress=None, as_pandas=True, trial=0): if show_progress is None: show_progress = True - if (isinstance(show_progress, int) and trial % show_progress == 0) or (isinstance(show_progress, bool) and show_progress): + if (isinstance(show_progress, int) and show_progress > 0 and trial % show_progress == 0) or \ + (isinstance(show_progress, bool) and show_progress): sys.stderr.write(msg + '\n') sys.stderr.flush() @@ -432,10 +433,10 @@ def cv(params, dtrain, num_boost_round=10, nfold=3, metrics=(), best_score = score best_score_i = i elif i - best_score_i >= early_stopping_rounds: - sys.stderr.write("Stopping. Best iteration: {}\n".format(best_score_i)) results = results[:best_score_i+1] + sys.stderr.write("Stopping. Best iteration: {} (mean: {}, std: {})\n". + format(best_score_i, results[-1][0], results[-1][1])) break - if as_pandas: try: import pandas as pd diff --git a/src/io/dmlc_simple.cpp b/src/io/dmlc_simple.cpp index 3fbf34734..0448bd578 100644 --- a/src/io/dmlc_simple.cpp +++ b/src/io/dmlc_simple.cpp @@ -153,7 +153,7 @@ class StdFile : public dmlc::Stream { return std::fread(ptr, 1, size, fp); } virtual void Write(const void *ptr, size_t size) { - std::fwrite(ptr, size, 1, fp); + Check(std::fwrite(ptr, size, 1, fp) == 1, "StdFile::Write: fwrite error!"); } virtual void Seek(size_t pos) { std::fseek(fp, static_cast(pos), SEEK_SET); // NOLINT(*) diff --git a/src/utils/io.h b/src/utils/io.h index 5b366e51c..1fd09310e 100644 --- a/src/utils/io.h +++ b/src/utils/io.h @@ -33,7 +33,7 @@ class FileStream : public ISeekStream { return std::fread(ptr, size, 1, fp); } virtual void Write(const void *ptr, size_t size) { - std::fwrite(ptr, size, 1, fp); + Check(std::fwrite(ptr, size, 1, fp) == 1, "FileStream::Write: fwrite error!"); } virtual void Seek(size_t pos) { std::fseek(fp, static_cast(pos), SEEK_SET); // NOLINT(*) diff --git a/subtree/rabit/windows/rabit/rabit.vcxproj b/subtree/rabit/windows/rabit/rabit.vcxproj index c9594b182..c670484d2 100644 --- a/subtree/rabit/windows/rabit/rabit.vcxproj +++ b/subtree/rabit/windows/rabit/rabit.vcxproj @@ -24,7 +24,7 @@ - Application + StaticLibrary true MultiByte diff --git a/windows/xgboost/xgboost.vcxproj b/windows/xgboost/xgboost.vcxproj index 00846f36a..8a15eaf61 100644 --- a/windows/xgboost/xgboost.vcxproj +++ b/windows/xgboost/xgboost.vcxproj @@ -25,6 +25,11 @@ + + + {d7b77d06-4f5f-4bd7-b81e-7cc8ebbe684f} + + {19766C3F-7508-49D0-BAAC-0988FCC9970C} xgboost