<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>machinelearning / Drkcore</title><link>http://blog.kzfmix.com/machinelearning</link><description>Programming, Music, Snowboarding</description><language>ja</language><lastBuildDate>Sun, 04 Apr 2010 17:49:33 +0919</lastBuildDate><item><title>Machine Learning: An Algorithmic Perspective 14,15章</title><link>http://blog.kzfmix.com/entry/1270370946</link><description>&lt;p&gt;MCMCとグラフィカルモデリング&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,700 ()&lt;br /&gt;
在庫あり。&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;この本だけではちょっと理解不足なので、PRMLとかまた読み返そう。&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/4254126573/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41X3B70DJ4L._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;グラフィカルモデリング (統計ライブラリー)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
宮川 雅巳 &lt;br /&gt;
朝倉書店 / ￥ 3,990 ()&lt;br /&gt;
在庫あり。&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/4431100318/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41vr-Ss6KPL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;パターン認識と機械学習 下 - ベイズ理論による統計的予測&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
C. M. ビショップ &lt;br /&gt;
シュプリンガー・ジャパン株式会社 / ￥ 8,190 ()&lt;br /&gt;
在庫あり。&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;
</description><pubDate>Sun, 04 Apr 2010 17:49:33 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Machine Learning: An Algorithmic Perspective 13章</title><link>http://blog.kzfmix.com/entry/1269079822</link><description>&lt;p&gt;強化学習&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,529 ()&lt;br /&gt;
通常2～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sarsa Algorithm&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mikilab.doshisha.ac.jp/dia/research/person/suyara/RL/TD-Learning/QL/Q-Learning.html"&gt;Q-Learning Algorithm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://ja.wikipedia.org/wiki/Q%E5%AD%A6%E7%BF%92"&gt;Q学習&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;いくつかの問題点も指摘されている。例えば Q学習による理論的保証は値の収束性のみであり収束途中の値には具体的な合理性が認められないため学習途中の結果を近似解として用いにくい、パラメータの変化に敏感でありその調整に多くの手間が必要であるなどがある。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="http://www.murata.elec.waseda.ac.jp/mituhiro.seki/openhouse/RL_example3.php"&gt;SarsaとQ-Learningの違い&lt;/a&gt;&lt;/p&gt;
</description><pubDate>Sat, 20 Mar 2010 19:28:13 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Machine Learning: An Algorithmic Perspective 12章</title><link>http://blog.kzfmix.com/entry/1268908138</link><description>&lt;p&gt;遺伝アルゴリズム&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,529 ()&lt;br /&gt;
通常2～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Four Peaks Problemってのがあるらしい。目的関数が&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;最初のビットからの連続した1の長さか最後のビットから連続した０の長さの大きいほう&lt;/li&gt;
&lt;li&gt;但し、両端の1,0の連続した数が10以上の場合は100ポイント獲得する。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;目的関数はこんな感じ。&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python
# -*- encoding:utf-8 -*-

from itertools import takewhile

def o(bits):
   return len(list(takewhile(lambda x: x == 1,bits)))

def z(bits):
       return len(list(takewhile(lambda x: x == 0,reversed(bits))))

def f(bits):
   reward = 100 if o(bits) &amp;gt; 10 and z(bits) &amp;gt; 10 else 0
   return max(o(bits),z(bits)) + reward


if __name__ == "__main__":
    bits1 = [1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    bits2 = [1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

    for bits in [bits1,bits2]:
        print "score: %d %s" % (f(bits),bits)

#score: 20  [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
#score: 114 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;要するに素直に探索していくとローカルミニマムに落ちるようになっていて、ピークの数が4つあるのでFour Peaks Problem&lt;/p&gt;

&lt;p&gt;連続した1,0の長さでcontour plotを描いた。&lt;/p&gt;

&lt;p&gt;&lt;img src="http://www.kzfmix.com/images/blog/4peaks.png" alt="4-peaks problem" /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python
# -*- encoding:utf-8 -*-

def sim_score():
    for x in range(100):
        for y in range(100):
            if x + y &amp;gt; 100:
                yield 0
            else:
                score = four_peak(x,y)
                yield score

def four_peak(x,y):
    reward = 100 if (x &amp;gt; 10 and y &amp;gt; 10) else 0
    score = max(x,y) + reward
    return score

if __name__ == "__main__":
    from pylab import *

    delta = 1
    x = arange(0, 100, delta)
    y = arange(0, 100, delta)
    X, Y = meshgrid(x, y)
    Z = array([z for z in sim_score()])
    Z.shape = 100,100

    im = imshow(Z,origin='lower' ,alpha=.9)
    colorbar(im)

    cset = contour(X,Y,Z)   
    clabel(cset,inline=1,fmt='%1.1f',fontsize=10)

    hot()
    savefig('4peaks.png')
&lt;/code&gt;&lt;/pre&gt;
</description><pubDate>Thu, 18 Mar 2010 19:38:47 +0919</pubDate><category>Python</category><category>matplotlib</category><category>machinelearning</category></item><item><title>Machine Learning: An Algorithmic Perspective 11章</title><link>http://blog.kzfmix.com/entry/1268564601</link><description>&lt;p&gt;Optimization and Search&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,529 ()&lt;br /&gt;
通常2～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ja.wikipedia.org/wiki/%E5%85%B1%E5%BD%B9%E5%8B%BE%E9%85%8D%E6%B3%95"&gt;共役勾配法&lt;/a&gt;とか。&lt;/p&gt;

&lt;p&gt;章としてはあんまそそられなかった。&lt;/p&gt;
</description><pubDate>Sun, 14 Mar 2010 20:03:21 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Machine Learning: An Algorithmic Perspective 10章</title><link>http://blog.kzfmix.com/entry/1268515123</link><description>&lt;p&gt;次元縮約のアルゴリズム。LDA,PCA,Kernel PCA,ICA,LLE,Isomapあたり。&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,529 ()&lt;br /&gt;
通常2～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;後半部分がちゃんと理解出来ていない。10.2.1でPCAと多層パーセプトロンの関連性を論じているのだけど、そこがよくわからなかった。あとLLE,MDS,Isomapをきちんと理解してないので、ちゃんと読んで一回実装してみる必要がある。&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www1.doshisha.ac.jp/~mjin/R/27.pdf"&gt;Ｒと多次元尺度法&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.tmps.org/index.php?%A5%E2%A1%BC%A5%B7%A5%E7%A5%F3%A5%DE%A5%C3%A5%D4%A5%F3%A5%B0#gbecbca8"&gt;Isomap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.aichi-gakuin.ac.jp/~chino/part-time/handai.pdf"&gt;多次元尺度構成法講義ノート&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.tmps.org/index.php?%A5%E2%A1%BC%A5%B7%A5%E7%A5%F3%A5%DE%A5%C3%A5%D4%A5%F3%A5%B0#x6f08326"&gt;LLE&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description><pubDate>Sun, 14 Mar 2010 06:20:57 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Machine Learning: An Algorithmic Perspective 9章</title><link>http://blog.kzfmix.com/entry/1268109193</link><description>&lt;p&gt;Unsupervised Learning。なかなか面白かった。&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,593 ()&lt;br /&gt;
通常2～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;K-meansの話から入って、K-Meansは一層のニューラルネットで表現することが出来ることを示していく。ニューラルネットで表現されたK-Meansはオンライン更新できるので、入力を一度に読み込まなくて良い(はず)。&lt;/p&gt;

&lt;p&gt;そのあとSOMだったけど、SOMは知ってるので流した。&lt;/p&gt;
</description><pubDate>Tue, 09 Mar 2010 13:33:24 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Machine Learning: An Algorithmic Perspective 8章</title><link>http://blog.kzfmix.com/entry/1267939373</link><description>&lt;p&gt;EM Algorithmとkd-Tree&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,593 ()&lt;br /&gt;
通常2～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://seat.massey.ac.nz/personal/s.r.marsland/Code/8/GMM.py"&gt;混合ガウス分布をEMアルゴリズムで(Python)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;内容はPRMLのほうが詳しい。Machine Leaningのほうはコードを読んで実装を理解するって感じだな。&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/4431100318/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41vr-Ss6KPL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;パターン認識と機械学習 下 - ベイズ理論による統計的予測&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
C. M. ビショップ &lt;br /&gt;
シュプリンガー・ジャパン株式会社 / ￥ 8,190 ()&lt;br /&gt;
在庫あり。&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ja.wikipedia.org/wiki/Kd%E6%9C%A8"&gt;kd-Tree&lt;/a&gt;は使ったことなかったけど、近傍探索はよく使うので、覚えておいて自由に使えるようにしようかな。&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://seat.massey.ac.nz/personal/s.r.marsland/Code/8/kdtree.py"&gt;kd-Tree(Python)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.livedoor.jp/dankogai/archives/51206940.html"&gt;kd-tree(javascript)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.prefield.com/algorithm/geometry/kdtree.html"&gt;kd-tree(C++)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description><pubDate>Sun, 07 Mar 2010 16:18:00 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>RBFネットワーク</title><link>http://blog.kzfmix.com/entry/1257060224</link><description>&lt;p&gt;Machine Learning 4章&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,459 ()&lt;br /&gt;
通常1～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;k-meansで初期値決め&lt;/li&gt;
&lt;li&gt;train
&lt;ul&gt;
&lt;li&gt;パーセプトロンの学習アルゴリズムと大体一緒&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;scipyにはB-splinesが用意されているのでそれを使ってみる&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;from pylab import *
from numpy import *
from scipy.signal import cspline1d, cspline1d_eval
x = arange(-3,10,0.05)
y = 2.5 * exp(-(x)**2/9) + 3.2 * exp(-(x-0.5)**2/4) + random.normal(0.0, 1.0, len(x))
spline = cspline1d(y,100)
xbar = arange(-5,15,0.1)
ybar = cspline1d_eval(spline, xbar, dx=x[1]-x[0], x0=x[0])
plot(x,y,'.')
plot(xbar,ybar)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://www.kzfmix.com/images/blog/spline.png" alt="b-splines" /&gt;&lt;/p&gt;
</description><pubDate>Sun, 01 Nov 2009 16:45:18 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Pythonで多層パーセプトロン</title><link>http://blog.kzfmix.com/entry/1256732835</link><description>&lt;p&gt;Machine Learning 3章&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,459 ()&lt;br /&gt;
通常1～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;要するにbackwars phaseを実装すればいいんでしょ？的な。実際書いてみると逆に誤差を伝播している感がある。&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Code from Chapter 3 of Machine Learning: An Algorithmic Perspective
# by Stephen Marsland (http://seat.massey.ac.nz/personal/s.r.marsland/MLBook.html)

# You are free to use, change, or redistribute the code in any way you wish for
# non-commercial purposes, but please maintain the name of the original author.
# This code comes with no warranty of any kind.

# Stephen Marsland, 2008
# modifiled by kzfm 2009

from numpy import *

inputs = array([[0,0],[0,1],[1,0],[1,1]])
targets = array([[0],[1],[1],[0]])

ndata,nin   = shape(inputs)
nout        = shape(targets)[1]
nhidden     = 2
beta        = 1
momentum    = 0.9
eta         = 0.25
niterations = 10001

weights1 = (random.rand(nin+1,nhidden)-0.5) * 2/sqrt(nin)
weights2 = (random.rand(nhidden+1,nout)-0.5) * 2/sqrt(nhidden)

# train
inputs = concatenate((inputs,-ones((ndata,1))),axis=1)
change = range(ndata)

updatew1 = zeros((shape(weights1)))
updatew2 = zeros((shape(weights2)))

for n in range(niterations):

    hidden = concatenate((1.0/(1.0+exp(-beta * dot(inputs,weights1))), -ones((shape(inputs)[0],1))),axis=1)
    outputs = 1.0 / (1.0+exp(-beta * dot(hidden,weights2)))
    error = 0.5 * sum((targets-outputs)**2)

    if (mod(n,1000)==0): print "Iteration: ",n, " Error: ",error    

    deltao = (targets-outputs) * outputs * (1.0-outputs)            
    deltah = hidden * (1.0-hidden) * (dot(deltao,transpose(weights2)))

    updatew1 = eta*(dot(transpose(inputs),deltah[:,:-1])) + momentum*updatew1
    updatew2 = eta*(dot(transpose(hidden),deltao)) + momentum*updatew2

    weights1 += updatew1
    weights2 += updatew2

    random.shuffle(change)
    inputs = inputs[change,:]
    targets = targets[change,:]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;ちなみに、創薬系でのニューラルネットは論文とかは多いけど、実務ではあんまり使われないと思う(特にケミストよりになればなるほど)。というのは、実務においては&lt;strong&gt;ゴールするためにはこういうロジックで合成すればよろしい&lt;/strong&gt;みたいな指針を提示しないといけないが、ニューラルネットでつくったモデルだとそういう解釈がしづらい。&lt;/p&gt;

&lt;p&gt;なんか物がたくさんあって、フィルタリングしたいという要求には答えられるけど、何をどういう指針に従って創るかみたいな、創造（製造）律速な問題には使いにくい。&lt;/p&gt;

&lt;p&gt;じゃぁ神経系は創造的ではないのかというと、それはまた違うんじゃないかなぁと思ったりもする。モデル化があれなのかなぁとも思うのだけど、、、、&lt;/p&gt;
</description><pubDate>Wed, 28 Oct 2009 22:22:16 +0919</pubDate><category>Python</category><category>machinelearning</category></item><item><title>Pythonでパーセプトロン</title><link>http://blog.kzfmix.com/entry/1256559854</link><description>&lt;p&gt;Machine Learningを読んでいる&lt;/p&gt;

&lt;p&gt;&lt;div class="awsxom"&gt;
&lt;a href="http://www.amazon.co.jp/exec/obidos/ASIN/1420067184/ref=nosim/kaerutyuuihou-22"&gt;
&lt;img src="http://ecx.images-amazon.com/images/I/41G8p6DFoAL._SL160_.jpg" align="left" hspace="5" border="0" alt="ProductName" class="image" /&gt;
&lt;strong&gt;Machine Learning: An Algorithmic Perspective (Chapman &amp; Hall/Crc Machine Learning &amp; Patrtern Recognition)&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Stephen Marsland &lt;br /&gt;
Chapman &amp; Hall / ￥ 6,459 ()&lt;br /&gt;
通常1～3週間以内に発送&lt;br /&gt;
&lt;br clear="all" /&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;numpyでパーセプトロンでORを訓練してみた(なにげにパーセプトロンとかニューラルネットワークの実装は初めてだったりする)。&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;from numpy import *
inputs = array([[0,0],[0,1],[1,0],[1,1]])
targets = array([[0],[1],[1],[1]])

nIterations = 6
eta = 0.25
nData = shape(inputs)[0]
nIn = shape(inputs)[1]
nOut  = shape(targets)[1]
weights = random.rand(nIn+1,nOut)

inputs = concatenate((inputs,-ones((nData,1))),axis=1)

for i in range(nIterations):
    outputs = where(dot(inputs,weights)&amp;gt;0,1,0)
    weights += eta*dot(transpose(inputs),targets-outputs)
    print "Iter: %d" % i
    print weights

print "Final outputs are:"
print where(dot(inputs,weights)&amp;gt;0,1,0) 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;この本は、アルゴリズムに関して説明するのがメインの本らしいので、コードの解説はあんまなくて、&lt;strong&gt;詳しくはサンプルコード読め&lt;/strong&gt;ということらしいが、もう少し読んでみないとわからん。&lt;/p&gt;
</description><pubDate>Mon, 26 Oct 2009 21:27:39 +0919</pubDate><category>Python</category><category>machinelearning</category></item></channel></rss>