
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
A Ruby gem to invoke the IBM Machine Learning service REST API.
Currently supports:
After installing Ruby >= 2.3:
$ gem install ibm-ml
Add this line to your application's Gemfile:
gem 'ibm-ml'
And then execute:
$ bundle install
require 'ibm/ml'
require 'pp'
# input record to score
record = {
GENDER: 'M',
AGEGROUP: '45-54',
EDUCATION: 'Doctorate',
PROFESSION: 'Executive',
INCOME: 200000,
SWITCHER: 0,
LASTPURCHASE: 3,
ANNUAL_SPEND: 1200
}
CLOUD_USERNAME = # WML service username
CLOUD_PASSWORD = # WML service password
CLOUD_INSTANCE_ID = # WML instance ID
DEPLOYMENT_ID = # deployment ID
# Create the service object
ml_service = IBM::ML::Cloud.new(CLOUD_USERNAME, CLOUD_PASSWORD, CLOUD_INSTANCE_ID)
# Fetch an authentication token
pp ml_service.fetch_token
# Query models
pp ml_service.models
pp ml_service.model_by_name('ML Model')
# Query deployments
pp ml_service.deployments
pp ml_service.deployment(DEPLOYMENT_ID) # identify by deployment ID
pp ml_service.deployment_by_name('Deployed ML Model') # OR identify by deployment name
# Get a score for the given deployment and record
score = ml_service.score(DEPLOYMENT_ID, record) # identify by deployment ID
score = ml_service.score_by_name('Deployed ML Model', record) # OR identify by deployment name
LOCAL_HOST = # DSX Local hostname / IP address
LOCAL_USERNAME = # DSX Local username
LOCAL_PASSWORD = # DSX Local password
DEPLOYMENT_ID = # deployment ID
# Create the service object
ml_service = IBM::ML::Local.new(LOCAL_HOST, LOCAL_USERNAME, LOCAL_PASSWORD)
# Fetch an authentication token
pp ml_service.fetch_token
# Get a score for the given deployment and record
score = ml_service.score(DEPLOYMENT_ID, record)
pp score # print full score hash
# extract prediction and probability from score
prediction = ml_service.query_score(score, 'prediction')
probability = ml_service.query_score(score, 'probability')[prediction]
puts
puts "Prediction = #{prediction == 1}" # print binary 1/0 prediction as true/false
puts "Probability = #{(probability * 100).round(1)}%" # print probability value as percentage
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/IBM-DSE/ibm-ml-ruby.
FAQs
Unknown package
We found that ibm-ml 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.