
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Mopti is a multivariate optimization library in Ruby. Mopti supports Nelder-Mead simplex method and Scaled Conjugate Gradient.
Add this line to your application's Gemfile:
gem 'mopti'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install mopti
Example 1. Linear Regression with Nelder-Mead simplex method
require 'numo/narray'
require 'numo/gnuplot'
require 'mopti'
# Define objective function.
obj_fnc = proc do |w, x, y|
n_samples = x.shape[0]
((y - x.dot(w))**2).sum.fdiv(n_samples)
end
# Explanatory variables.
x = Numo::DFloat[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Dependent variables.
y = 3 * x + 2
# Extend variable for intercept.
xb = Numo::DFloat.vstack([x, [1] * x.size]).transpose.dup
# Optimize parameter vectors.
res = Mopti::minimize(algorithm: 'Nelder-Mead', fnc: obj_fnc, x_init: Numo::DFloat.zeros(2), args: [xb, y])
# Output result.
pp res
a, b = res[:x].to_a
Numo.gnuplot do
set(terminal: 'png')
set(output: 'example1.png')
plot [[0, 10], [a * x[0] + b, a * x[-1] + b], w: :lines, lw: 1, t: 'parameters'],
[x, y, pt: 6, ps: 2, t: 'data']
end
$ brew install gnuplot
$ gem install mopti numo-narray numo-gnuplot
$ ruby example1.rb
{:x=>Numo::DFloat(view)#shape=[2]
[3, 2],
:n_fev=>177,
:n_iter=>91,
:fnc=>2.290874014308807e-13}
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/mopti. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
Everyone interacting in the Mopti project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that mopti demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.