Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Artificial Intelligence and Machine Learning Programs in Ruby (http://www.velocityreviews.com/forums/t812193-artificial-intelligence-and-machine-learning-programs-in-ruby.html)

Ryosuke Kadoi 11-28-2003 06:37 PM

Artificial Intelligence and Machine Learning Programs in Ruby
 
Hi All,

Does anyone know artificial intelligence and machine learning programs
implemented in Ruby? I'm trying to implement either a hidden markov or
artificial neural network in Ruby? But I would like to know anyone who has
done this before. These kinds of programs usually are implememented in C++
or Java though. If you know any information regarding this matter, please
let me know any examples or websites (English or Japanese websites).

Also, if you are interested in bioinformatics from machine learning
standpoint with Ruby, please let me know any information.

Thanks,

Ryosuke



Simon Strandgaard 11-28-2003 06:43 PM

Re: Artificial Intelligence and Machine Learning Programs in Ruby
 
On Sat, 29 Nov 2003 03:37:47 +0900, Ryosuke Kadoi wrote:

> Does anyone know artificial intelligence and machine learning programs
> implemented in Ruby?


There seems to be 8 AI-ruby projects:
http://raa.ruby-lang.org/cat.rhtml?c...egory_minor=AI


I don't know if this is useful?
http://raa.ruby-lang.org/cat.rhtml?c...gory_minor=Bio

--
Simon Strandgaard

Michael Neumann 11-28-2003 07:14 PM

Re: Artificial Intelligence and Machine Learning Programs in Ruby
 
On Sat, Nov 29, 2003 at 03:37:47AM +0900, Ryosuke Kadoi wrote:
> Hi All,
>
> Does anyone know artificial intelligence and machine learning programs
> implemented in Ruby? I'm trying to implement either a hidden markov or
> artificial neural network in Ruby? But I would like to know anyone who has
> done this before. These kinds of programs usually are implememented in C++
> or Java though. If you know any information regarding this matter, please
> let me know any examples or websites (English or Japanese websites).


There's libneural and rbsnns:

http://raa.ruby-lang.org/list.rhtml?name=libneural
http://raa.ruby-lang.org/list.rhtml?name=rbsnns

But they are interfaces to C libraries. Maybe that's not what you want.

Regards,

Michael



Akimichi Tatsukawa 11-29-2003 03:56 PM

Re: Artificial Intelligence and Machine Learning Programs in Ruby
 
Hi

kadoism> Does anyone know artificial intelligence and machine learning programs
kadoism> implemented in Ruby? I'm trying to implement either a hidden markov or
kadoism> artificial neural network in Ruby? But I would like to know anyone who has

How about LibNeural?
It is implemented in C++ and wrapped by swing, not a pure ruby script, though.

Regards,
Aki
--------------------------------------------------------
Name: 立川察理 Akimichi Tatsukawa
Email: akimichi@mbox.co.jp
Web: http://akimichi.homeunix.net/~emile/



Kenta MURATA 11-30-2003 08:36 AM

Re: Artificial Intelligence and Machine Learning Programs in Ruby
 
Hi, Ryosuke

In message <BAY8-DAV57nO9lTXeo6000029f9@hotmail.com> at Sat, 29 Nov 2003 03:37:47 +0900,
"Ryosuke Kadoi" <kadoism@hotmail.com> wrote:
> Also, if you are interested in bioinformatics from machine learning
> standpoint with Ruby, please let me know any information.


I try to write Sarsa in Ruby. Follwing code is implementation
''Example 6.5'' of Section 6.4 in [1].

----
#! /usr/bin/env ruby

WIND = [ 0, 0, 0, 1, 1, 1, 2, 2, 1, 0 ]
N = 1000
EPSILON = 0.1
ALPHA = 0.1
GAMMA = 1.0

# action-value function table
class Q
def [](state, a)
@table[[state, a]]
end

def []=(state, a, v)
@table[[state, a]] = v
end

def state_collect(state)
ary = @table.collect{|k, v| k[0] == state ? [k[1], v] : nil }
ary.compact!
ary
end

def initialize(v=0.0)
@table = {}
(0..6).each do |y|
(0..9).each do |x|
[ :up, :down, :right, :left ].each do |a|
@table[[[x, y], a]] = v
end
end
end
end
end

# epsilon-greedy policy function
def epsilon_greedy(q, state, epsilon=EPSILON)
ary = q.state_collect(state)
if epsilon >= rand then
## search
ary[rand(ary.length)][0]
else
## greedy
ary.max{|a, b| a[1] <=> b[1]}[0]
end
end

# environment
def do_action(state, action)
state = state.dup
case action
when :up
state[1] -= 1
when :down
state[1] += 1
when :left
state[0] -= 1
when :right
state[0] += 1
end
state[1] -= WIND[state[0]] if 0 <= state[0] and state[0] <= 9
state[0] = [[0, state[0]].max, 9].min
state[1] = [[0, state[1]].max, 6].min
return [state, -1]
end

q = Q.new
N.times do |n|
state = [0, 3]

step = 0
action = epsilon_greedy(q, state)
until state == [7, 3] do
next_state, reward = do_action(state, action)
next_action = epsilon_greedy(q, next_state)
q[state, action] += ALPHA*(reward + GAMMA*q[next_state, next_action] - q[state, action])
state = next_state
action = next_action
step += 1
end

puts "#{n} #{step}" # output the count of episode and time-step
STDOUT.flush
end

# greedy (for evaluate action-value function)
step = 0
state = [0, 3]
action = epsilon_greedy(q, state, 0.0)
until state == [7, 3] do
next_state, reward = do_action(state, action)
next_action = epsilon_greedy(q, next_state, 0.0)
state = next_state
action = next_action
step += 1
end
puts "# greedy policy #{step}"
STDOUT.flush
----

If very well, I would like to move to ruby-list because I'm
not good at English. Maybe I'm good for you if use Japanese.

[1] Richard S. Sutton and Andrew G. Barto, Reinforcement
Learning: An Introduction, MIT Press, Cambridge, MA, 1998,
http://www-anw.cs.umass.edu/~rich/book/the-book.html.

--
1024D/2A3FDBE6 2001-08-26 Kenta MURATA (muraken) <muraken2@nifty.com>
Key fingerprint = 622A 61D3 280F 4991 4833 5724 8E2D C5E1 2A3F DBE6


Tom Copeland 12-01-2003 07:18 PM

Re: Artificial Intelligence and Machine Learning Programs in Ruby
 
On Fri, 2003-11-28 at 13:37, Ryosuke Kadoi wrote:
> Hi All,
>
> Does anyone know artificial intelligence and machine learning programs
> implemented in Ruby? I'm trying to implement either a hidden markov or
> artificial neural network in Ruby? But I would like to know anyone who has
> done this before. These kinds of programs usually are implememented in C++
> or Java though. If you know any information regarding this matter, please
> let me know any examples or websites (English or Japanese websites).


You might find this interesting:

http://ai-app-prog.rubyforge.org/

It's a translation of the C examples in M. Tim Jones' "AI Application
Programming" to Ruby.

Yours,

tom




All times are GMT. The time now is 09:25 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.