merge from dmlc/xgboost

This commit is contained in:
黄子轩 2015-12-29 01:34:06 -08:00
commit 4a301240bd
8 changed files with 29 additions and 15 deletions

View File

@ -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

View File

@ -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
```

View File

@ -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"

View File

@ -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

View File

@ -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<long>(pos), SEEK_SET); // NOLINT(*)

View File

@ -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<long>(pos), SEEK_SET); // NOLINT(*)

View File

@ -24,7 +24,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>

View File

@ -25,6 +25,11 @@
<ClCompile Include="..\..\src\tree\updater.cpp" />
<ClCompile Include="..\..\src\xgboost_main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\subtree\rabit\windows\rabit\rabit.vcxproj">
<Project>{d7b77d06-4f5f-4bd7-b81e-7cc8ebbe684f}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{19766C3F-7508-49D0-BAAC-0988FCC9970C}</ProjectGuid>
<RootNamespace>xgboost</RootNamespace>