Created
July 20, 2012 16:03
-
-
Save pubis/3151570 to your computer and use it in GitHub Desktop.
Veritable quickstart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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