Esempio n. 1
0
    def chart(self, query):        
        result = detect.process(query)

        airlines = {}
        for row in result:
            airline = row[4]
            if airline not in airlines:
                airlines[airline] = 0
            airlines[airline] += 1

        out = {
            'name': 'airports',
            'children': []
        }

        for airline in airlines:
            group = {
                'name': 'flights-for-' + airline,
                'children': [
                    { 'name': airline, 'size': 100*airlines[airline]/len(result) }
                ]
            }
            out['children'].append(group)

        return json.dumps(out)
Esempio n. 2
0
    def chart_large(self, query):        
        result = detect.process(query)

        out = 'price,price2,airline\n'
        for row in result:
            out += row[3] + ',' + str(float(row[3]) + random.random()*250) + ',' + row[4] + '\n'

        return out
Esempio n. 3
0
    def chart_large(self, query):
        result = detect.process(query)

        out = 'price,price2,airline\n'
        for row in result:
            out += row[3] + ',' + str(float(row[3]) + random.random() *
                                      250) + ',' + row[4] + '\n'

        return out
Esempio n. 4
0
    def chart(self, query):
        result = detect.process(query)

        airlines = {}
        for row in result:
            airline = row[4]
            if airline not in airlines:
                airlines[airline] = 0
            airlines[airline] += 1

        out = {'name': 'airports', 'children': []}

        for airline in airlines:
            group = {
                'name':
                'flights-for-' + airline,
                'children': [{
                    'name': airline,
                    'size': 100 * airlines[airline] / len(result)
                }]
            }
            out['children'].append(group)

        return json.dumps(out)
Esempio n. 5
0

	filesNames = listDirectory(options.dirname)

	class_dict = eval(open("../bayes/dictionnary.txt").read())
	haarc = haar.haarInit(os.path.dirname(os.path.realpath(__file__)) + '/../haar/cascade.xml')

	trainData = []

	responses = []
	total = len(filesNames)
	i = 1
	for fileName in filesNames:
		print "{0} / {1}".format(i,total)
		i = i+1
		_,_,densityVect = detect.process(detect.loadSample(fileName),haarc,True)

		if densityVect is None:
			continue

		trainData.append(densityVect)
		responses.append(class_dict[fileName])
 	

	matrixData = np.matrix(trainData).astype('float32')
	matrixResp = np.matrix(responses)

	classifier = cv2.NormalBayesClassifier()

	classifier.train(matrixData,matrixResp)
Esempio n. 6
0
    def process_query(self, query):
        ## do something with the query
        result = detect.process(query)

        return json.dumps(result)
Esempio n. 7
0
    def process_query(self, query):
        ## do something with the query
        result = detect.process(query)

        return json.dumps(result)