sklearn 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. virtualenv=${root}/build/virtualenv/scikit-learn
  5. tools=${root}/tools
  6. third_party=${root}/third_party
  7. if [ $(which python3) ] && [ $(which pip3) ]; then
  8. python="python3"
  9. pip="pip3"
  10. else
  11. python="python"
  12. pip="pip"
  13. fi
  14. bold() {
  15. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  16. }
  17. git_sync() {
  18. mkdir -p "${third_party}"
  19. if [ -d "${third_party}/${1}" ]; then
  20. git -C "${third_party}/${1}" fetch --quiet -p
  21. git -C "${third_party}/${1}" reset --quiet --hard origin/master
  22. else
  23. echo "Clone ${2}..."
  24. git -C "${third_party}" clone --quiet --recursive ${2} ${1}
  25. fi
  26. git -C "${third_party}" submodule update --quiet --init
  27. }
  28. sync() {
  29. bold "sklearn clean"
  30. git_sync numpy https://github.com/numpy/numpy.git
  31. git_sync scikit-learn https://github.com/scikit-learn/scikit-learn.git
  32. git_sync lightgbm https://github.com/Microsoft/LightGBM.git
  33. git_sync xgboost https://github.com/dmlc/xgboost.git
  34. }
  35. install() {
  36. bold "sklearn install"
  37. if [ ! -d "${virtualenv}" ]; then
  38. virtualenv --quiet -p ${python} ${virtualenv}
  39. fi
  40. source ${virtualenv}/bin/activate
  41. ${pip} install --quiet Cython
  42. ${pip} install --quiet numpy
  43. ${pip} install --quiet ${third_party}/scikit-learn
  44. deactivate
  45. }
  46. metadata() {
  47. bold "sklearn metadata"
  48. source ${virtualenv}/bin/activate
  49. pushd ${tools} > /dev/null
  50. ${python} sklearn-script.py
  51. popd > /dev/null
  52. deactivate
  53. }
  54. while [ "$#" != 0 ]; do
  55. command="$1" && shift
  56. case "${command}" in
  57. "sync") sync;;
  58. "install") install;;
  59. "metadata") metadata;;
  60. esac
  61. done