Mac build fix
This commit is contained in:
parent
48ac946d9f
commit
6063d243eb
@ -5,15 +5,3 @@ if [ ${TRAVIS_OS_NAME} != "osx" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
brew update
|
brew update
|
||||||
|
|
||||||
if [ ${TASK} == "python-package" ]; then
|
|
||||||
brew install python git graphviz
|
|
||||||
easy_install pip
|
|
||||||
pip install numpy scipy matplotlib nose
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${TASK} == "python-package3" ]; then
|
|
||||||
brew install python3 git graphviz
|
|
||||||
sudo pip3 install --upgrade setuptools
|
|
||||||
pip3 install numpy scipy matplotlib nose graphviz
|
|
||||||
fi
|
|
||||||
|
|||||||
@ -33,30 +33,44 @@ if [ ${TASK} == "R-package" ]; then
|
|||||||
scripts/travis_R_script.sh || exit -1
|
scripts/travis_R_script.sh || exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${TASK} == "python-package" ]; then
|
if [ ${TASK} == "python-package" -o ${TASK} == "python-package3" ]; then
|
||||||
sudo apt-get install graphviz
|
|
||||||
sudo apt-get install python-numpy python-scipy python-matplotlib python-nose
|
|
||||||
sudo python -m pip install graphviz
|
|
||||||
make all CXX=${CXX} || exit -1
|
|
||||||
nosetests tests/python || exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${TASK} == "python-package3" ]; then
|
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
|
||||||
sudo apt-get install graphviz
|
brew install graphviz
|
||||||
# python3-matplotlib is unavailale on Ubuntu 12.04
|
if [ ${TASK} == "python-package3" ]; then
|
||||||
sudo apt-get install python3-dev
|
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
|
||||||
sudo apt-get install python3-numpy python3-scipy python3-nose python3-setuptools
|
else
|
||||||
|
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh
|
||||||
make all CXX=${CXX} || exit -1
|
fi
|
||||||
|
|
||||||
if [ ${TRAVIS_OS_NAME} != "osx" ]; then
|
|
||||||
sudo easy_install3 pip
|
|
||||||
sudo easy_install3 -U distribute
|
|
||||||
sudo pip install graphviz matplotlib
|
|
||||||
nosetests3 tests/python || exit -1
|
|
||||||
else
|
else
|
||||||
nosetests tests/python || exit -1
|
sudo apt-get install graphviz
|
||||||
|
if [ ${TASK} == "python-package3" ]; then
|
||||||
|
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
|
||||||
|
else
|
||||||
|
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
bash conda.sh -b -p $HOME/miniconda
|
||||||
|
export PATH="$HOME/miniconda/bin:$PATH"
|
||||||
|
hash -r
|
||||||
|
conda config --set always_yes yes --set changeps1 no
|
||||||
|
conda update -q conda
|
||||||
|
# Useful for debugging any issues with conda
|
||||||
|
conda info -a
|
||||||
|
|
||||||
|
if [ ${TASK} == "python-package3" ]; then
|
||||||
|
conda create -n myenv python=3.4
|
||||||
|
else
|
||||||
|
conda create -n myenv python=2.7
|
||||||
|
fi
|
||||||
|
source activate myenv
|
||||||
|
conda install numpy scipy matplotlib nose
|
||||||
|
python -m pip install graphviz
|
||||||
|
|
||||||
|
make all CXX=${CXX} || exit -1
|
||||||
|
|
||||||
|
python -m nose tests/python || exit -1
|
||||||
|
python --version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only test java under linux for now
|
# only test java under linux for now
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import xgboost as xgb
|
import xgboost as xgb
|
||||||
|
|
||||||
@ -33,21 +34,25 @@ def test_feature_names():
|
|||||||
data = np.random.randn(100, 5)
|
data = np.random.randn(100, 5)
|
||||||
target = np.array([0, 1] * 50)
|
target = np.array([0, 1] * 50)
|
||||||
|
|
||||||
features = ['Feature1', 'Feature2', 'Feature3', 'Feature4', 'Feature5']
|
cases = [['Feature1', 'Feature2', 'Feature3', 'Feature4', 'Feature5'],
|
||||||
dm = xgb.DMatrix(data, label=target,
|
[u'要因1', u'要因2', u'要因3', u'要因4', u'要因5']]
|
||||||
feature_names=features)
|
|
||||||
assert dm.feature_names == features
|
|
||||||
assert dm.num_row() == 100
|
|
||||||
assert dm.num_col() == 5
|
|
||||||
|
|
||||||
params={'objective': 'multi:softprob',
|
for features in cases:
|
||||||
'eval_metric': 'mlogloss',
|
dm = xgb.DMatrix(data, label=target,
|
||||||
'eta': 0.3,
|
feature_names=features)
|
||||||
'num_class': 3}
|
assert dm.feature_names == features
|
||||||
|
assert dm.num_row() == 100
|
||||||
|
assert dm.num_col() == 5
|
||||||
|
|
||||||
|
params={'objective': 'multi:softprob',
|
||||||
|
'eval_metric': 'mlogloss',
|
||||||
|
'eta': 0.3,
|
||||||
|
'num_class': 3}
|
||||||
|
|
||||||
|
bst = xgb.train(params, dm, num_boost_round=10)
|
||||||
|
scores = bst.get_fscore()
|
||||||
|
assert list(sorted(k for k in scores)) == features
|
||||||
|
|
||||||
bst = xgb.train(params, dm, num_boost_round=10)
|
|
||||||
scores = bst.get_fscore()
|
|
||||||
assert list(sorted(k for k in scores)) == features
|
|
||||||
|
|
||||||
def test_plotting():
|
def test_plotting():
|
||||||
bst2 = xgb.Booster(model_file='xgb.model')
|
bst2 = xgb.Booster(model_file='xgb.model')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user