筋違い角って苦手や。
(角交換)四間飛車にしておけば簡単に防げるから、後手の時にやられて困った。
ダイレクト向かい飛車を読み直す
筋違い角って苦手や。
(角交換)四間飛車にしておけば簡単に防げるから、後手の時にやられて困った。
ダイレクト向かい飛車を読み直す
22092014 Python
kNN, Naibe Bayesm, SVM, (Random Forrest)をScikit-learnでやってみた。データはiPython NotebookでReSTで出力したものをpandocでmarkdown_strictに変換しなおしてblogに貼り付けた。
描画用のヘルパー関数とデータセットの生成
from matplotlib.colors import ListedColormap import Image from numpy import * from pylab import * import pickle def myplot_2D_boundary(X,y): x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1 y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1 xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.02), np.arange(y_min, y_max, 0.02)) Z = clf.predict(np.c_[xx.ravel(), yy.ravel()]) Z = Z.reshape(xx.shape) plt.figure() plt.pcolormesh(xx, yy, Z, cmap=cmap_light) plt.scatter(X[:, 0], X[:, 1], c=y, cmap=cmap_bold) plt.xlim(xx.min(), xx.max()) plt.ylim(yy.min(), yy.max()) plt.show() with open('points_normal.pkl', 'r') as f: class_1 = pickle.load(f) class_2 = pickle.load(f) labels = pickle.load(f) X_normal = np.r_[class_1, class_2] y_normal = labels with open('points_ring.pkl', 'r') as f: class_1 = pickle.load(f) class_2 = pickle.load(f) labels = pickle.load(f) X_ring = np.r_[class_1, class_2] y_ring = labels with open('points_normal_test.pkl', 'r') as f: class_1 = pickle.load(f) class_2 = pickle.load(f) labels = pickle.load(f) X_normal_test = np.r_[class_1, class_2] y_normal_test = labels with open('points_ring_test.pkl', 'r') as f: class_1 = pickle.load(f) class_2 = pickle.load(f) labels = pickle.load(f) X_ring_test = np.r_[class_1, class_2] y_ring_test = labels cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA']) cmap_bold = ListedColormap(['#FF0000', '#00FF00'])
import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap from sklearn import neighbors, datasets clf = neighbors.KNeighborsClassifier(3) clf.fit(X_normal, y_normal) myplot_2D_boundary(X_normal,y_normal)
clf = neighbors.KNeighborsClassifier(3) clf.fit(X_ring, y_ring) myplot_2D_boundary(X_ring,y_ring)
from sklearn.naive_bayes import GaussianNB clf = GaussianNB() clf.fit(X_normal, y_normal) labels_pred = clf.predict(X_normal_test) print "Number of mislabeled points out of a total %d points : %d" % (y_normal_test.shape[0],(y_normal_test != labels_pred).sum()) myplot_2D_boundary(X_normal,y_normal)
clf = GaussianNB() clf.fit(X_ring, y_ring) labels_pred = clf.predict(X_ring_test) print "Number of mislabeled points out of a total %d points : %d" % (y_ring_test.shape[0],(y_ring_test != labels_pred).sum()) myplot_2D_boundary(X_ring,y_ring)
from sklearn import svm clf = svm.SVC() clf.fit(X_normal, y_normal) labels_pred = clf.predict(X_normal_test) print "Number of mislabeled points out of a total %d points : %d" % (y_normal_test.shape[0],(y_normal_test != labels_pred).sum()) myplot_2D_boundary(X_normal, y_normal)
clf = svm.SVC() clf.fit(X_ring, y_ring) labels_pred = clf.predict(X_ring_test) print "Number of mislabeled points out of a total %d points : %d" % (y_ring_test.shape[0],(y_ring_test != labels_pred).sum()) myplot_2D_boundary(X_ring,y_ring)
from sklearn.ensemble import RandomForestClassifier clf = RandomForestClassifier(n_estimators=10) clf.fit(X_normal, y_normal) labels_pred = clf.predict(X_normal_test) print "Number of mislabeled points out of a total %d points : %d" % (y_normal_test.shape[0],(y_normal_test != labels_pred).sum()) myplot_2D_boundary(X_normal,y_normal)
from sklearn.ensemble import RandomForestClassifier clf = RandomForestClassifier(n_estimators=10) clf.fit(X_ring, y_ring) labels_pred = clf.predict(X_ring_test) print "Number of mislabeled points out of a total %d points : %d" % (y_ring_test.shape[0],(y_ring_test != labels_pred).sum()) myplot_2D_boundary(X_ring,y_ring)
22092014 Python
最近ちょっと忙しくて実践コンピュータビジョンの読書会には初参加なのに発表してきたわけだが。
写経以外に務めたことはipython notebookとscikit-learnを推してきたw。あとディープラーニングの話とかしてた。そして少しまじめにディープラーニングを学ぼうと思った。
懇親会は筋肉居酒屋で。
店に入ると鉄アレイ等がお出迎え
塩バターラーメン風パスタ(一人前のハーフサイズw)
久しぶりに参加して楽しかったですね。主催者がいい感じにバトンタッチしつつ、新しい人も程よく入りながら長いこと続いているいい読書会だなぁと思いました。数えてみたらもうちょっとで5年ですね。
次回は島田でやるそうです。
22092014 Python
最近RHEL6を与えられたのだが、Pythonのバージョンが2.6系なので2.7系を入れつつ以下のパッケージを導入したのでメモ
開発環境をrpmで入れておく
yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
あとはPythonをソースからインストールする
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
scipyにはlapack(付きのnumpy)が必要なのだけどyum install blas,lapackは上手くいかないのでソースからインストールした。
wget http://www.netlib.org/lapack/lapack.tgz
tar xzfv lapack.tgz
cd lapack-*/
cp INSTALL/make.inc.gfortran make.inc
meke.incのオプションを修正する -fPICオプションを追加。もし64ビットマシンなら-m64オプションも追加
FORTRAN = gfortran OPTS = -O2 -frecursive -fPIC -m64 DRVOPTS = $(OPTS) NOOPT = -O0 -frecursive -fPIC -m64
書き換えたらmakeする
make blaslib; make lapacklib
出来た*.aを適当なディレクトリに配置して環境変数を設定し、.bashrcとか/etc/profileに追加しておく
export BLAS=/[path]/[to]/librefblas.a export LAPACK=/[path]/[to]/liblapack.a
pip install numpy
インストール出来たらblas,lapackが使われているかどうかを確認するためimport numpyしてnumpy.show_config()で確認しておく。
OKだったらscipyを入れる。
pip install scipy
libpngが必要なのでyumで入れる。それからRHEL6のfreetypeは2.3だがmatplotlib1.4.0でも動くので設定ファイルを書き換えてコンパイルする。
yum install libpng libpng-devel
1.4.0のソースをダウンロード
tar xvfz matplotlib-1.4.0.tar.gz
setupext.pyでfreetypeの2.4以上をチェックしているところを2.3に書き換える
python setup.py install
入れるだけ
pip install scikit-learn pip install pandas pip install patsy pip install ggplot pip install pyzmq pip install jinja2 pip install tornado pip install ipython
1級のヒト
早々に角道を止められて、相手は棒銀メインらしいのでどうしようかなーと。
後手なのに見よう見まねの三間飛車を指してしまい、乱戦にw
112手目の5九金はボケてた
なんとなく粘れたので良しとしよう。最後は打った瞬間に「あっ…」ってなったw
ふんわり感が好き
PyconJP2014に参加しました。運営のヒト、発表者のヒト、参加者の皆様、楽しい時間をありがとうございました。
去年のPyconで発表して燃え尽きた感があったんだけど、今年参加したら再生した感があったというか、コードを書く気力が戻ってきたかなw
今回は科学技術計算系のセッションが多くて非常に楽しめた。
参加したセッション(Keynoteを除く)
Deep Learning for Image Recognition in Python (ja)から。
Decaf使ってみようと思ったらDEPRECATEDになってた。後継のcaffeを使えってことらしい
リファクタリングツールあれこれ (May the force be with you) (ja)から。
データベーススキーマからSQLAlchemyのモデルを自動生成してくれるsqlacodegenが刺さった。コレ使えばpychembldbもっと簡単にかけたんじゃないの?と。
あとは数独を解くソルバの話がとてもおもしろかった。
尚、今週末は実践コンピュータビジョン読書会の画像検索の章なので、参加するといいと思います。
資料作らないトナー
今日は二戦して二勝だったので負け将棋の棋譜はない。
そして角交換四間飛車ばかり指しているが、相手が角道を止める三間飛車とか四間飛車みたいな相振りの時に止めるくらいであとは開けっ放しで、適当なタイミングで交換する事が多い。
角交換四間飛車を指しこなす本を読んでからガイドを読むのがいいかなと思う。徹底ガイドは対居飛車で最新ガイドは相振りです(尚、最新ガイドの方は全然消化できてない)。
相振りの場合は角道を止めちゃうことが多いので「相振り飛車を指しこなす本」を手本に指している感じ。つまり金無双とか平矢倉にしてますね。
1級のヒト。時間が足らなかった
3級のヒト。 序盤良かったのに最後がダメだった。
2級のヒト。序盤が駄目すぎた、というより角交換すべきだった。
50手目すぎくらいから棋神を一度w
53手目の6四歩打なんて思いつかない。詰みを確認して投了