Exemplo n.º 1
0
def LeeCliP(telefono):
    bd = DB(nombrebd="textos")

    rows = bd.Ejecuta("select * from cli where telefono='%s'" % telefono)
    if not rows:
        bd.Ejecuta("insert into cli (telefono) values ('%s')" % telefono)
        bd.commit()
        rows = bd.Ejecuta("select * from cli where telefono='%s'" % telefono)

    if rows:
        response = {}
        response['cli'] = rows[0]
        response['prov'] = bd.Ejecuta(
            "select *, id as ID from prov where activo=1 order by nombre")
        return response

    bd.cierra()
Exemplo n.º 2
0
def train_district(district):
    district_id = district["district_id"]
    db = DB("didi")
    save_case(district_id, [1])
    save_l(district_id, 0)
    save_score(district_id, 1)
    print "train_district", district_id
    for n in xrange(0, 3):
        list_cases(district, 20, db)
        clean_case(district, db)
    print
    score = testdist("results_test_roma", district_id, db) # 0.47167 es con 1, 0.471369268265
    cases = read_case(district_id)
    db.exe("update districts set score=%s, cases='%s', complex=%s where district_id=%s" 
        % (score, cases, len(cases), district_id))
    db.commit()
    print "#### Final score ####"
    print district_id, score
Exemplo n.º 3
0
def train_district(district):
    coment = "con 1, days 14, prom"
    district_id = district["district_id"]
    db = DB("didi")
    table_results = read_table("results_test_roma", district_id, db)
    table_test = read_table("diditest.gaps", district_id, db)
    table_source = read_table("gaps", district_id, db)
    
    save_case(district_id, [1])
    save_l(district_id, 0)
    save_score(district_id, 1)
    print "train_district", district_id
    for n in xrange(0, 20):
        list_cases(district, table_results, table_source, table_test, 50)
        clean_case(district, table_results, table_source, table_test)

    score = testdist(table_results, table_test)# 0.47167 es con 1, 0.471369268265    
    cases = read_case(district_id)
    db.exe("insert into districts_score (district_id, score, cases, coment) values (%s, %s, '%s', '%s')"
            % (district_id, score, cases, coment))
    db.commit()
    print "#### Final score ####"
    print district_id, score
Exemplo n.º 4
0
'''
from apiDB import DB

db = DB("didi")
rows = db.exe("select * from results_send")
for row in rows:
    if row["date"]=="2016-01-30":
        date = "2016-01-16"
    else:
        dt = row["date"].split("-")
        m = "00%s" % (int(dt[2]) - 7)
        date = "%s-%s-%s" % (dt[0], dt[1], m[-2:])  
    
    g = db.exe("select gap from gaps where district_id=%s and date='%s' and slot=%s"
               % (row["district_id"], date, row["slot"]) )


#     if row["date"]=="2016-01-30":
#         pass
#     print row
    
    gap = 1
    if g:
        if g[0]["gap"] > gap:
            gap = g[0]["gap"]
    
    db.exe("update results_send set gap=%s where district_id=%s and date='%s' and slot=%s"
            % (gap, row["district_id"], row["date"], row["slot"]) )
    db.commit()
    
print "end"    
Exemplo n.º 5
0
'''
Created on 14/09/2016

@author: botpi
'''
import numpy as np
import scipy.io
import os
from apiDB import DB

group = "train_1"
directory = "c:/concursos/epilepsia/%s/" % group

db = DB()
db.exe("truncate table pat1_1")
for file in os.listdir(directory):
    mat = scipy.io.loadmat(directory + file)
    print file
    data = mat['dataStruct'][0][0][0]
    name = file.split(".")[0]
    for t in range(240000):
        for channel in range(16):
            db.exe(
                "insert into pat1_1 (IDchannel, time, val) values (%s, %s, %s)"
                % (channel, t, data[t][channel]))
        db.commit()

db.close()