Several fixes (#2572)

* repared serialization after update process; fixes #2545

* non-stratified folds in python could omit some data instances

* Makefile: fixes for older makes on windows; clean R-package too

* make cub to be a shallow submodule

* improve $(MAKE) recovery
This commit is contained in:
Vadim Khotilovich 2017-08-06 13:03:50 -05:00 committed by GitHub
parent 70b65a282c
commit 2b3a4318c5
4 changed files with 22 additions and 10 deletions

1
.gitmodules vendored
View File

@ -10,3 +10,4 @@
[submodule "cub"] [submodule "cub"]
path = cub path = cub
url = https://github.com/NVlabs/cub url = https://github.com/NVlabs/cub
shallow = true

View File

@ -16,6 +16,20 @@ endif
ROOTDIR = $(CURDIR) ROOTDIR = $(CURDIR)
# workarounds for some buggy old make & msys2 versions seen in windows
ifeq (NA, $(shell test ! -d "$(ROOTDIR)" && echo NA ))
$(warning Attempting to fix non-existing ROOTDIR [$(ROOTDIR)])
ROOTDIR := $(shell pwd)
$(warning New ROOTDIR [$(ROOTDIR)] $(shell test -d "$(ROOTDIR)" && echo " is OK" ))
endif
MAKE_OK := $(shell "$(MAKE)" -v 2> /dev/null)
ifndef MAKE_OK
$(warning Attempting to recover non-functional MAKE [$(MAKE)])
MAKE := $(shell which make 2> /dev/null)
MAKE_OK := $(shell "$(MAKE)" -v 2> /dev/null)
endif
$(warning MAKE [$(MAKE)] - $(if $(MAKE_OK),checked OK,PROBLEM))
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
UNAME="Windows" UNAME="Windows"
else else
@ -215,6 +229,7 @@ endif
clean: clean:
$(RM) -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o #xgboost $(RM) -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o #xgboost
$(RM) -rf build_tests *.gcov tests/cpp/xgboost_test $(RM) -rf build_tests *.gcov tests/cpp/xgboost_test
cd R-package/src; $(RM) -rf rabit src include dmlc-core amalgamation *.so *.dll; cd $(ROOTDIR)
clean_all: clean clean_all: clean
cd $(DMLC_CORE); $(MAKE) clean; cd $(ROOTDIR) cd $(DMLC_CORE); $(MAKE) clean; cd $(ROOTDIR)
@ -229,8 +244,7 @@ pypack: ${XGBOOST_DYLIB}
cd python-package; tar cf xgboost.tar xgboost; cd .. cd python-package; tar cf xgboost.tar xgboost; cd ..
# create pip installation pack for PyPI # create pip installation pack for PyPI
pippack: pippack: clean_all
$(MAKE) clean_all
rm -rf xgboost-python rm -rf xgboost-python
cp -r python-package xgboost-python cp -r python-package xgboost-python
cp -r Makefile xgboost-python/xgboost/ cp -r Makefile xgboost-python/xgboost/
@ -241,8 +255,7 @@ pippack:
cp -r rabit xgboost-python/xgboost/ cp -r rabit xgboost-python/xgboost/
# Script to make a clean installable R package. # Script to make a clean installable R package.
Rpack: Rpack: clean_all
$(MAKE) clean_all
rm -rf xgboost xgboost*.tar.gz rm -rf xgboost xgboost*.tar.gz
cp -r R-package xgboost cp -r R-package xgboost
rm -rf xgboost/src/*.o xgboost/src/*.so xgboost/src/*.dll rm -rf xgboost/src/*.o xgboost/src/*.so xgboost/src/*.dll
@ -264,13 +277,11 @@ Rpack:
cp xgboost/src/Makevars.in xgboost/src/Makevars.win cp xgboost/src/Makevars.in xgboost/src/Makevars.win
sed -i -e 's/@OPENMP_CXXFLAGS@/$$\(SHLIB_OPENMP_CFLAGS\)/g' xgboost/src/Makevars.win sed -i -e 's/@OPENMP_CXXFLAGS@/$$\(SHLIB_OPENMP_CFLAGS\)/g' xgboost/src/Makevars.win
Rbuild: Rbuild: Rpack
$(MAKE) Rpack
R CMD build --no-build-vignettes xgboost R CMD build --no-build-vignettes xgboost
rm -rf xgboost rm -rf xgboost
Rcheck: Rcheck: Rbuild
$(MAKE) Rbuild
R CMD check xgboost*.tar.gz R CMD check xgboost*.tar.gz
-include build/*.d -include build/*.d

View File

@ -235,8 +235,7 @@ def mknfold(dall, nfold, param, seed, evals=(), fpreproc=None, stratified=False,
idx = np.random.permutation(dall.num_row()) idx = np.random.permutation(dall.num_row())
else: else:
idx = np.arange(dall.num_row()) idx = np.arange(dall.num_row())
kstep = int(len(idx) / nfold) idset = np.array_split(idx, nfold)
idset = [idx[(i * kstep): min(len(idx), (i + 1) * kstep)] for i in range(nfold)]
elif folds is not None and isinstance(folds, list): elif folds is not None and isinstance(folds, list):
idset = [x[1] for x in folds] idset = [x[1] for x in folds]
nfold = len(idset) nfold = len(idset)

View File

@ -75,6 +75,7 @@ struct GBTreeModel {
} }
trees.clear(); trees.clear();
param.num_trees = 0; param.num_trees = 0;
tree_info.clear();
} }
} }