import sqlite3
from random import randint, choice
import numpy as np


conn = sqlite3.connect('ej.db')

c = conn.cursor()

#OBTENIENDO TAMAnOS MAXIMOS MINIMOS Y PROMEDIO#
c.execute('SELECT MAX(alto) FROM features')
resultado = c.fetchone()
if resultado:
    altoMax = resultado[0]

c.execute('SELECT MIN(alto) FROM features')
resultado = c.fetchone()
if resultado:
    altoMin = resultado[0]

altoProm = abs((altoMax + altoMin) / 2)

#print altoMax , altoProm , altoMin
arrAlto = [altoMax , altoProm , altoMin]

c.execute('SELECT MAX(ancho) FROM features')
resultado = c.fetchone()
if resultado:
    anchoMax = resultado[0]

c.execute('SELECT MIN(ancho) FROM features')
resultado = c.fetchone()
if resultado:
    anchoMin = resultado[0]

anchoProm = abs((anchoMax + anchoMin) / 2)

anchoMaxProm = abs((anchoMax + anchoProm) / 2)

anchoMinProm = abs((anchoMin + anchoProm) / 2)

arrAncho = [anchoMax, anchoMaxProm, anchoProm, anchoMinProm, anchoMin]

####  CREANDO CLASES NEGATIVAS



for i in range(0,3):
    for j in range(0,5):
        for _ in range(10):
            negAncho = arrAncho[j]
            negAlto = arrAlto[i]
            rand_alto_max = int(negAlto * 1.5)
            rand_alto_min = int(negAlto * 0.5)
            r3 = rand_alto_max * 2

            rand_ancho_max = int(negAncho*1.5)
            rand_ancho_min = int(negAncho*0.5)
            r33 = rand_ancho_max * 2

            f1 = choice([np.random.randint(1, rand_alto_min), np.random.randint(rand_alto_max, r3)])
            f2 = choice([np.random.randint(1, rand_ancho_min), np.random.randint(rand_ancho_max, r33)])

            c.execute("insert into features (ancho, alto, area, clase) values (?, ?, ?, ?)",
                      (f2, f1, f2*f1, 0))





conn.commit()



conn.close()
[((6, 7, 6, 31), 'sqlite3.connect', 'sqlite3.connect', ({(6, 23, 6, 30): '"""ej.db"""'}, {}), "('ej.db')", False, 'import sqlite3\n'), ((61, 25, 61, 60), 'numpy.random.randint', 'np.random.randint', ({(61, 43, 61, 44): '1', (61, 46, 61, 59): 'rand_alto_min'}, {}), '(1, rand_alto_min)', True, 'import numpy as np\n'), ((61, 62, 61, 98), 'numpy.random.randint', 'np.random.randint', ({(61, 80, 61, 93): 'rand_alto_max', (61, 95, 61, 97): 'r3'}, {}), '(rand_alto_max, r3)', True, 'import numpy as np\n'), ((62, 25, 62, 61), 'numpy.random.randint', 'np.random.randint', ({(62, 43, 62, 44): '1', (62, 46, 62, 60): 'rand_ancho_min'}, {}), '(1, rand_ancho_min)', True, 'import numpy as np\n'), ((62, 63, 62, 101), 'numpy.random.randint', 'np.random.randint', ({(62, 81, 62, 95): 'rand_ancho_max', (62, 97, 62, 100): 'r33'}, {}), '(rand_ancho_max, r33)', True, 'import numpy as np\n')]