Omoikane (思金) is a Shinto god of wisdom and intelligence, who is always called upon to "ponder" and give good counsel in deliberations of the heavenly deities. (from the Shin Megami Tensei wiki)

Omoikane is also a library for Machine Learning in Ruby based on NMatrix and other SciRuby's gems. It is intended for real-life usage in data mining and research.


You need to get NMatrix installed before installing Omoikane. On OSX, you'll need to make some symlinks. The process is a bit more involved on Linux, but the instructions on NMatrix's wiki should be enough.

After making sure you're able to install NMatrix:

$ [sudo] gem install omoikane


To use k-means clustering:

require 'omoikane'

dataset = NMatrix.load_matlab_file("my_data.mat") # Or use CSV.

# Find 3 (k = 3) clusters via the k-means clustering algorithm with random initial clusters.
c =, 3, :initial => :random)
p c.clusters


  1. Fork it ([my-github-username]/omoikane/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request