# Define filtros sobre los campos del avaluo (query con la estructura (campo1=value11 or campo1=value12  or ... ) AND (campo2=value21 or campo2=value22  or ... ) 
filters = {"codigo_postal_ubicacion_inmueble": ['03103', '03100', '03104', '03200', '03230', '03240']}
#filters = {"codigo_postal_ubicacion_inmueble": ['03103', '03100', '03104', '03200', '03230', '03240', '03023', '03000','03020', '03023', '03600']}

#filters = {"codigo_postal_ubicacion_inmueble": ['77710', '77712', '77713', '77714', '77716', '77717', '77718', '77720', '77723', '77724', '77725', '77726' ]}
#filters = {"codigo_postal_ubicacion_inmueble": ['77710']}

# Avaluos como una lista de diccionarios
appraisals = data_manager.get_inputs_dicionaries(file_name+'.csv', filters)
num_appraisals = len(appraisals)
generated_ints = random.sample(xrange(0,num_appraisals), num_appraisals)
appraisals_random_sorted = [appraisals[i] for i in generated_ints]

# creacion del mapa de avaluos filtrados
visualizer.dot_infomap_from_appraisals(appraisals, "map_filtered_"+file_name)

# salia a consula del primer avaluo
formated_list = visualizer.list_formated_appraisal(appraisals[0])

print "----------------------"
print "-Ejemplo de avaluo----"
for each_field in formated_list:
	print "Campo: ", each_field
print "----------------------"

# selecciona el 80-20 para entrenamiento y pruebas



# filters = {"codigo_postal_ubicacion_inmueble": ['77710', '77712', '77713', '77714', '77716', '77717', '77718', '77720', '77723', '77724', '77725', '77726' ]}
# filters = {"codigo_postal_ubicacion_inmueble": ['77710']}

# filters = {"codigo_postal_ubicacion_inmueble": ['14410']}


filter_string_msg = "-" + "-".join(filters["codigo_postal_ubicacion_inmueble"])
# Avaluos como una lista de diccionarios
appraisals = data_manager.get_inputs_dicionaries(file_name_examples + ".csv", filters)
num_appraisals = len(appraisals)
generated_ints = random.sample(xrange(0, num_appraisals), num_appraisals)
appraisals_random_sorted = [appraisals[i] for i in generated_ints]

# creacion del mapa de avaluos filtrados
visualizer.dot_infomap_from_appraisals(appraisals, "map_filtered_" + file_name_examples + filter_string_msg)

# salia a consula del primer avaluo
formated_list = visualizer.list_formated_appraisal(appraisals[0])

print "----------------------"
print "-Ejemplo de avaluo----"
for each_field in formated_list:
    print "Campo: ", each_field
print "----------------------"


# Resultados por correlacion cruzada 10-fold-cross-correlation
hidden_size = 50
k = 10
data_slice = num_appraisals // k

















		

file_name = "quintanaroo_abril_2015"
data_dict_avaluos = load_csv(file_name+'.csv')

for i in data_dict_avaluos[:2]:
	print i.keys()


print visualizer.dot_infomap_from_appraisals(data_dict_avaluos, "UVs_map_"+file_name)