スペシャルサンクス
下の記事に大きく影響を受けて、作成しました。
素敵な記事を紹介頂き、ありがとうございます!
https://qiita.com/ishizakiiii/items/3b894b6e987fdf87093e
目的
機械学習を学び、(まずは)趣味へ活かす
10分でできるから、余った20分で自習しよう!
目標
紳士達の予想メソッドを聞く
評価方式を定める
実装する
目標1
まずは、1位を当てることを目標にして、
隣の席の先輩に聞いてみた。
下の評価軸で、だいたいいいんじゃない?とコメント頂いた。
評価軸 |
---|
頭数 |
獲得賞金金額 |
順位 |
レースの長さ |
人気 |
体重 |
タイム(秒) |
馬場状態が良 |
馬場状態が稍重 |
馬場状態が重 |
馬場状態が不良 |
サーバの構築
まずは、GCP 上にVM を環境構築。
今回は、CentOS7 を選択。
Docker の導入
作っては壊しをしているので、コンテナで作業する
https://mseeeen.msen.jp/activate-docker-and-start-centos7/
yum -y install docker net-tools
systemctl start docker
systemctl enable docker
docker pull centos:centos7
docker run --privileged -d --name TEST centos:centos7 /sbin/init
docker exec -it TEST /bin/bash
以降は、特筆無い限り、コンテナ TES 内の作業
前提ソフトの導入
ここを参照
https://qiita.com/hatakkkk/items/910f336e95fc95c4a160
yum -y groupinstall "Development Tools"
yum -y install wget zlib-devel
wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
tar vfx git-2.9.5.tar.gz
cd git-2.9.5
make configure
./configure --prefix=/usr
make all
sudo make install
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone git://github.com/yyuu/pyenv-virtualenv.git ./.pyenv/plugins/pyenv-virtualenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ./.pyenv/plugins/pyenv-virtualenvwrapper
ウェブスクレイピング の実装
sudo pip install beautifulsoup4
curl -LO https://raw.githubusercontent.com/HaHatake/beautifulsoup2018/master/tastingsoup.py
python tastingsoup.py
Yahoo! JAPAN
Keras(Tensorflow)の環境構築
下のサイトを参照。ありがとう!
https://qiita.com/agumon/items/4d7826c2c39d0af868bd
pyenv install anaconda3-4.3.1
pyenv global anaconda3-4.3.1
echo 'PATH="$PYENV_ROOT/versions/anaconda3-4.3.1/bin:$PATH"' >> ~/.bash_profile
source .bash_profile
仮想環境の作成
conda create -n py36 python=3.6 anaconda
source activate py36
tensorflow のインストール
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
curl -LO https://raw.githubusercontent.com/HaHatake/tensorflow/master/tensorflowhello.py
python tensorflowhello.py
Tips
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.1-py3-none-any.whl
curl -LO https://raw.githubusercontent.com/HaHatake/tensorflow/master/tensorflowhello.py
python tensorflowhello.py
Traceback (most recent call last):
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/init.py", line 61, in
from tensorflow.python import pywrap_tensorflow
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in
pywrap_tensorflow = swig_import_helper()
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tensorflowhello.py", line 1, in
import tensorflow
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/init.py", line 24, in
from tensorflow.python import *
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/init.py", line 72, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/init_.py", line 61, in
from tensorflow.python import pywrap_tensorflow
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in
_pywrap_tensorflow = swig_import_helper()
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/h1d34h4t/.pyenv/versions/anaconda3-4.3.1/envs/py36/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
失敗した。。。mac 版のTF をインストールしてた。
また明日やり直す。
下のものを入れるべきだったようだ。
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
下だとなんか違う。
```ruby:install-pyenv
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source .bash_profile
pyenv install 3.6.6
pyenv rehash
pyenv global 3.6.6
python --version
```
出力結果が以下ならOK
Python 3.6.6
下のサイトを参照して、再度トライすることにした。
https://qiita.com/Leonhard/items/188690df29fd91717c92
python は入ってるので、pip install を試験。
-bash: pip: command not found
ダメだ。。。
ここで勉強
https://qiita.com/itkr/items/513318a9b5b92bd56185
pip をインストールする。
https://pip.pypa.io/en/stable/installing/
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py