Veritable

This add-on is operated by Prior Knowledge

The predictive database

Veritable

Last Updated: 19 March 2014

The Veritable add-on is currently in beta.

Table of Contents

Veritable is an add-on for the predictive database service developed by Prior Knowledge

With Veritable, you can quickly and easily integrate data-backed insights and predictions into applications without machine-learning expertise or complex data science infrastructure.

Veritable is accessible via a REST API and has supported client libraries for Ruby and Python.

Provisioning the add-on

Veritable can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:add veritable
-----> Adding veritable to sharp-mountain-4005... done, v18 (free)

Once veritable has been added, VERITABLE_URL and VERITABLE_KEY settings will be available in the app configuration and will contain the url and key used to access the REST API. This can be confirmed using the heroku config command.

$ heroku config | grep VERITABLE
VERITABLE_URL    => https://api.priorknowledge.com
VERITABLE_KEY    => 65d155423c810f145d5622b524282d8be0e8e3d2d928aba0982b9be6b4576261

After installing Veritable, the application should be configured to fully integrate with the add-on.

Local setup

Environment setup

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the service.

Though less portable it’s also possible to set local environment variables using export VERITABLE_URL and export VERITABLE_KEY

Use Foreman to configure, run and manage process types specified in your app’s Procfile. Foreman reads configuration variables from an .env file. Use the following command to add the VERITABLE values retrieved from heroku config to .env.

$ heroku config -s | grep VERITABLE >> .env
$ more .env

Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: echo .env >> .gitignore.

Using with Ruby

Prior Knowledge offers a fully supported native Ruby client for Veritable.

Ruby applications should have the following entry added to their Gemfile specifying the Veritable client library.

gem 'veritable'

Update application dependencies with bundler.

$ bundle install

The following example will test your Veritable configuration and connection.

require 'veritable' # don't forget to put gem 'veritable' in your Gemfile
api = Veritable.connect() # connects to the API
print api.tables.to_a # prints an array of existing tables, empty array for new accounts

You should walk through the Veritable Ruby Quickstart for a quick introduction to loading data and running an analysis.

Once an analysis is complete, making predictions, finding related features and rows, and extracting other insights from your data is simple.

Let’s say you want to implement targeted ads for an online automotive store. Veritable can use the customer data to predict the most likely gender and type of vehicle given other information you know about a customer:

analysis = api.tables('customers').analyses('analysis')
original_row = { 'age' => 24,
                 'gender' => nil,
                 'vehicle' => nil,
                 'income' => 60000 }
predicted_row = analysis.predict(original_row)
print predicted_row['gender'], predicted_row['vehicle']

Let’s say you want to implement a music recommendation system. Veritable can use ratings information to find more songs given a particular song a user likes:

analysis = api.tables('music_ratings').analyses('analysis')
target_song = { '_id' => 'Call Me Maybe' }
analysis.similar_to(target_song, 'rating').each { |recommended_song|
    print recommended_song
}

Using with Python

Prior Knowledge offers a fully supported native Python client for Veritable.

Python applications should have the following entry added to their requirements.txt specifying the Veritable client library.

veritable

Update application dependencies with pip.

$ pip install -Ur requirements.txt

The following example will test your Veritable configuration and connection.

import veritable # don't forget to put veritable in your requirements.txt
api = veritable.connect() # connects to the API
print(list(api.get_tables())) # prints a list of existing tables, empty list for new accounts

You should walk through the Veritable Python Quickstart for a quick introduction to loading data and running an analysis.

Once an analysis is complete, making predictions, finding related features and rows, and extracting other insights from your data is simple.

Let’s say you want to implement targeted ads for an online automotive store. Veritable can use the customer data to predict the most likely gender and type of vehicle given other information you know about a customer:

analysis = api.get_table('customers').get_analysis('analysis')
original_row = { 'age': 24,
                 'gender': None,
                 'vehicle': None,
                 'income': 60000 }
predicted_row = analysis.predict(original_row)
print predicted_row['gender'], predicted_row['vehicle']

Let’s say you want to implement a music recommendation system. Veritable can use ratings information to find more songs given a particular song a user likes:

analysis = api.get_table('music_ratings').get_analysis('analysis')
target_song = { '_id': 'Call Me Maybe' }
for recommended_song in analysis.similar_to(target_song, 'rating'):
    print recommended_song

Migrating between plans

Application owners should carefully manage the migration timing to ensure proper application function during the migration process.

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade veritable:cloud
-----> Upgrading veritable:cloud to sharp-mountain-4005... done, v18 (pay as you go)
       Your plan has been updated to: veritable:cloud

Removing the add-on

Veritable can be removed via the CLI.

This will destroy all associated tables and analyses, and cannot be undone!

$ heroku addons:remove veritable
-----> Removing veritable from sharp-mountain-4005... done, v20 (free)

Support

All Veritable support and runtime issues should be logged with Heroku Support at https://support.heroku.com. Any non-support related issues or product feedback is welcome at support@priorknowledge.com or via Twitter @prior_k.

Additional resources

Additional resources, documentation, and examples are available at: