Exemplo n.º 1
0
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

from DatabaseClient import DatabaseClient
client = DatabaseClient(hostname=None)

cmd_list = [
    'DROP PTABLE dha_demo;',
    'CREATE PTABLE dha_demo FROM /home/sgeadmin/tabular_predDB/Examples/dha.csv;',
    'IMPORT SAMPLES dha_samples.pkl.gz INTO dha_demo;',
    'SELECT name, qual_score, ami_score, pymt_p_visit_ratio, ttl_mdcr_spnd, hosp_reimb_ratio, hosp_reimb_p_dcd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo LIMIT 10;',
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo SAVE TO dha_z_matrix.png;',
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo REFERENCING qual_score LIMIT 6;',
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo REFERENCING qual_score WITH CONFIDENCE 0.9;', 
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo REFERENCING pymt_p_md_visit LIMIT 6;',
#    'SELECT name, qual_score, ami_score, pymt_p_visit_ratio, ttl_mdcr_spnd, hosp_reimb_ratio, hosp_reimb_p_dcd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo ORDER BY similarity_to(name=\'Albany NY\') LIMIT 10;',
    'SELECT name, qual_score, ami_score, pymt_p_visit_ratio, ttl_mdcr_spnd, hosp_reimb_ratio, hosp_reimb_p_dcd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo ORDER BY similarity_to(name=\'Albany NY\', qual_score), ami_score  LIMIT 10;',
    'SELECT name, qual_score, ami_score,  pymt_p_visit_ratio, ttl_mdcr_spnd, hosp_reimb_ratio, hosp_reimb_p_dcd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo ORDER BY similarity_to(name=\'Albany NY\', pymt_p_visit_ratio), ttl_mdcr_spnd  LIMIT 10;',
    'SIMULATE name, qual_score, ami_score, pymt_p_visit_ratio, ttl_mdcr_spnd, hosp_reimb_ratio, hosp_reimb_p_dcd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo WHERE ami_score=95.0  TIMES 10;',
    'SIMULATE name, qual_score, ami_score, pymt_p_visit_ratio, ttl_mdcr_spnd, hosp_reimb_ratio, hosp_reimb_p_dcd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo WHERE ttl_mdcr_spnd=50000 TIMES 10;',
Exemplo n.º 2
0
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

from DatabaseClient import DatabaseClient

client = DatabaseClient(hostname=None)
client('drop btable dan_kiva;')
client('create btable dan_kiva from data/kiva.csv;')
client(
    'import samples data/kiva_flat_table_model_500.pkl.gz into dan_kiva iterations 500;'
)
print client('select * from dan_kiva limit 5;')

fields_of_interest = [
    'partner_status',
    'partner_rating',
    'delinquent',
    'default_rate',
    'loan_amount',
    'gender_ratio',
]
Exemplo n.º 3
0
from DatabaseClient import DatabaseClient
client = DatabaseClient(hostname=None)
#print client.execute('start from scratch;')

cmds = []
#cmds.append('drop ptable dha;')
'''
cmds.append('create ptable dha from /home/sgeadmin/tabular_predDB/Examples/dha.csv;')
cmds.append('create 10 models for dha;')
cmds.append('analyze dha for 10 iterations;')
cmds.append('analyze dha for 10 iterations;')
cmds.append('analyze dha for 30 iterations;')
cmds.append('analyze dha for 50 iterations;')
cmds.append('analyze dha for 100 iterations;')
cmds.append('analyze dha for 100 iterations;')
cmds.append('analyze dha for 100 iterations;')
cmds.append('analyze dha for 100 iterations;')
'''
'''
cmds.append('select * from dha limit 5;')
cmds.append('export from dha to dha_samples;')

cmds.append('create ptable dha_loaded from /home/sgeadmin/tabular_predDB/Examples/dha.csv;')
cmds.append('import samples dha_samples.pkl.gz into dha_loaded;')
cmds.append('select * from dha limit 5;')
'''

cmds.append('drop ptable dha_big')
#cmds.append('create ptable dha_big from /home/sgeadmin/tabular_predDB/Examples/demo_data/DHA/DAP_Hosp.dat;')
cmds.append('create ptable dha_big from /home/sgeadmin/tabular_predDB/Examples/dha.csv;')
cmds.append('import samples dha_samples.pkl.gz INTO dha_big;')
Exemplo n.º 4
0
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

from DatabaseClient import DatabaseClient

client = DatabaseClient(hostname=None)
client("drop btable dan_kiva;")
client("create btable dan_kiva from data/kiva.csv;")
client("import samples data/kiva_flat_table_model_500.pkl.gz into dan_kiva iterations 500;")
print client("select * from dan_kiva limit 5;")


fields_of_interest = [
    "due_diligence_type",
    "delinquency_rate",
    "partner_status",
    "partner_rating",
    "delinquent",
    "default_rate",
    "loan_amount",
    "gender_ratio",
Exemplo n.º 5
0
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

from DatabaseClient import DatabaseClient
client = DatabaseClient(hostname=None)
client('drop btable dan_kiva;')
client('create btable dan_kiva from data/kiva.csv;')
client('import samples data/kiva_flat_table_model_500.pkl.gz into dan_kiva iterations 500;')
print client('select * from dan_kiva limit 5;')


fields_of_interest = [
    'partner_status',
    'partner_rating',
    'delinquent',
    'default_rate',
    'loan_amount',
    'gender_ratio',
    ]
fields_str = ', '.join(fields_of_interest)
Exemplo n.º 6
0
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

print
cmd = '>>> from DatabaseClient import DatabaseClient'
print cmd
raw_input()
from DatabaseClient import DatabaseClient
#
cmd = ">>> client = DatabaseClient(hostname='localhost')"
print cmd
raw_input()
client = DatabaseClient(hostname=None)
#


####### New demo ########

# select with ordering by similarity
# infer: nans can't be filled in at one confidence level, but can at another
# simulate

#########################

# #
#  ORDER BY SIMILARITY 
# #
fields_of_interest = [
#! /Users/jon/anaconda3/bin/python3
"""
This file tests the functionality of the DatabaseClient class
It performs the following actions

"""

import random
from DatabaseClient import DatabaseClient

dbClient = DatabaseClient()

print("Resetting the database")
dbClient.reset_database()

print("Adding some data")
dataDict = dict()
types = ["electric", "gas", "wind", "solar"]
datetime = "12:00 10/21/19",
usages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

dataDict['type'] = 'electric'

for i in range(100):
    print("Uploading random data #{}/100".format(i))
    dataDict[i] = dict()
    dataDict[i]['type'] = random.choice(types)
    dataDict[i]['dt'] = datetime
    dataDict[i]['usage'] = random.choice(usages)
    dbClient.add_data_from_dict(dataDict[i])
print("Data has been added")
Exemplo n.º 8
0
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

from DatabaseClient import DatabaseClient

client = DatabaseClient(hostname=None)
client('drop btable dan_kiva;')
client('create btable dan_kiva from data/kiva.csv;')
client(
    'import samples data/kiva_flat_table_model_500.pkl.gz into dan_kiva iterations 500;'
)
print client('select * from dan_kiva limit 5;')

fields_of_interest = [
    'due_diligence_type',
    'delinquency_rate',
    'partner_status',
    'partner_rating',
    'delinquent',
    'default_rate',
    'loan_amount',
Exemplo n.º 9
0
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

from DatabaseClient import DatabaseClient

client = DatabaseClient(hostname=None)

cmd_list = [
    'DROP PTABLE dha_demo;',
    'CREATE PTABLE dha_demo FROM /home/sgeadmin/tabular_predDB/Examples/dha.csv;',
    'IMPORT SAMPLES dha_samples.pkl.gz INTO dha_demo;',
    'SELECT hosp_reimb_ratio, hosp_reimb_p_dcd, mdcr_spnd_inp, ttl_mdcr_spnd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo LIMIT 10;',
    'SELECT hosp_reimb_ratio, hosp_reimb_p_dcd, mdcr_spnd_inp, ttl_mdcr_spnd, md_copay_p_dcd, ttl_copay_p_dcd FROM dha_demo ORDER BY SIMILARITY TO 0 LIMIT 10;',
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo REFERENCING mdcr_spnd_inp LIMIT 6 SAVE TO dha_fz;',
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo REFERENCING mdcr_spnd_inp SAVE TO dha_full_fz;',
    'ESTIMATE DEPENDENCE PROBABILITIES FROM dha_demo REFERENCING mdcr_spnd_inp WITH CONFIDENCE 0.9 SAVE TO dha_fz;',
]

import sys
for cmd in cmd_list:
    sys.stdout.write('>>> %s' % cmd)