Skip to content

Instantly share code, notes, and snippets.

@pubis
Created July 20, 2012 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pubis/3151570 to your computer and use it in GitHub Desktop.
Save pubis/3151570 to your computer and use it in GitHub Desktop.
Veritable quickstart
# Based on https://www.priorknowledge.com/docs/quickstart/python
require 'veritable'
API_KEY = ENV['VERITABLE_KEY']
api = Veritable.connect(api_key: API_KEY)
rows = Veritable::Util.read_csv('bank-data.csv')
schema = {
'age' => {'type' => 'count'},
'sex' => {'type' => 'categorical'},
'region' => {'type' => 'categorical'},
'income' => {'type' => 'real'},
'married' => {'type' => 'boolean'},
'children' => {'type' => 'count'},
'car' => {'type' => 'boolean'},
'save_act' => {'type' => 'boolean'},
'current_act' => {'type' => 'boolean'},
'mortgage' => {'type' => 'boolean'},
'pep' => {'type' => 'boolean'}
}
Veritable::Util.clean_data(rows, schema)
api.delete_table('bank-data') if api.has_table?('bank-data')
table = api.create_table('bank-data')
table.batch_upload_rows(rows)
analysis = table.create_analysis(schema, 'my-analysis')
analysis.wait
new_customer = {
'age' => 30,
'married' => false,
'income' => 44892.2,
'save_act' => nil,
'pep' => nil
}
prediction = analysis.predict(new_customer)
puts prediction['pep']
puts prediction['save_act']
puts prediction.uncertainty
puts prediction.distribution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment