Example #1
0
 def send_extract(self, query):
     f = StringIO()
     query = urllib.unquote(query)
     content = Vlist()
     for (i,sub) in enumerate(query.split(',')):
         r = sub.split('-')
         if len(r)==1:
             if sub.strip()[0].lower()=='t':
                 sub=sub.strip()[1:]
                 content.append(Path(test_data.extract(int(sub)), 'T%s<br>'%sub))
             else:
                 content.append(Path(train_data.extract(int(sub)), '%s<br>'%sub))
         elif len(r)==2:
             test = False
             if r[0].strip()[0].lower()=='t':
                 test = True
                 r[0]=r[0].strip()[1:]
                 if r[1].strip()[0].lower()=='t':
                     r[1]=r[1].strip()[1:]
             for i in xrange(int(r[0]), int(r[1])+1):
                 if test:
                     content.append(Path(test_data.extract(i), 'T%d<br>'%i))
                 else:
                     content.append(Path(train_data.extract(i), '%d<br>'%i))
         elif len(r)>2:
             self.send_error(404, 'File not found')
             return None
     content.write(f)
     length = f.tell()
     f.seek(0)
     self.send_response(200)
     encoding = sys.getfilesystemencoding()
     self.send_header("Content-type", "text/html; charset=%s" % encoding)
     self.send_header("Content-Length", str(length))
     self.end_headers()
     return f
Example #2
0
#!/usr/bin/env python

from data.hdf5 import taxi_it
from visualizer import Vlist, Point

if __name__ == '__main__':
    points = Vlist(heatmap=True)
    for line in taxi_it('test'):
        for (lat, lon) in zip(line['latitude'], line['longitude']):
            points.append(Point(lat, lon))
    points.save('test positions')
Example #3
0
 def send_extract(self, query):
     f = StringIO()
     query = urllib.unquote(query)
     content = Vlist()
     for (i, sub) in enumerate(query.split(',')):
         r = sub.split('-')
         if len(r) == 1:
             if sub.strip()[0].lower() == 't':
                 sub = sub.strip()[1:]
                 content.append(
                     Path(test_data.extract(int(sub)), 'T%s<br>' % sub))
             else:
                 content.append(
                     Path(train_data.extract(int(sub)), '%s<br>' % sub))
         elif len(r) == 2:
             test = False
             if r[0].strip()[0].lower() == 't':
                 test = True
                 r[0] = r[0].strip()[1:]
                 if r[1].strip()[0].lower() == 't':
                     r[1] = r[1].strip()[1:]
             for i in xrange(int(r[0]), int(r[1]) + 1):
                 if test:
                     content.append(
                         Path(test_data.extract(i), 'T%d<br>' % i))
                 else:
                     content.append(
                         Path(train_data.extract(i), '%d<br>' % i))
         elif len(r) > 2:
             self.send_error(404, 'File not found')
             return None
     content.write(f)
     length = f.tell()
     f.seek(0)
     self.send_response(200)
     encoding = sys.getfilesystemencoding()
     self.send_header("Content-type", "text/html; charset=%s" % encoding)
     self.send_header("Content-Length", str(length))
     self.end_headers()
     return f
#!/usr/bin/env python

from data.hdf5 import taxi_it
from visualizer import Vlist, Point

if __name__ == '__main__':
    it = taxi_it('stands')
    next(it)
    points = Vlist()
    for (i, line) in enumerate(it):
        points.append(
            Point(line['stands_latitude'], line['stands_longitude'],
                  'Stand (%d): %s' % (i + 1, line['stands_name'])))
    points.save('stands')
Example #5
0
#!/usr/bin/env python

from data.hdf5 import taxi_it
from visualizer import Vlist, Point


if __name__ == '__main__':
    points = Vlist(heatmap=True)
    for line in taxi_it('test'):
        for (lat, lon) in zip(line['latitude'], line['longitude']):
            points.append(Point(lat, lon))
    points.save('test positions')
Example #6
0
#!/usr/bin/env python

from data.hdf5 import taxi_it
from visualizer import Vlist, Point


if __name__ == '__main__':
    it = taxi_it('stands')
    next(it) # Ignore the "no stand" entry

    points = Vlist()
    for (i, line) in enumerate(it):
        points.append(Point(line['stands_latitude'], line['stands_longitude'], 'Stand (%d): %s' % (i+1, line['stands_name'])))
    points.save('stands')
#!/usr/bin/env python

from data.hdf5 import taxi_it
from visualizer import Vlist, Point
_sample_size = 5000

if __name__ == '__main__':
    points = Vlist(cluster=True)
    for line in taxi_it('train'):
        if len(line['latitude']) > 0:
            points.append(Point(line['latitude'][-1], line['longitude'][-1]))
            if len(points) >= _sample_size:
                break
    points.save('destinations (cluster)')
    points.cluster = False
    points.heatmap = True
    points.save('destinations (heatmap)')
Example #8
0
#!/usr/bin/env python

from data.hdf5 import taxi_it
from visualizer import Vlist, Point


_sample_size = 5000

if __name__ == '__main__':
    points = Vlist(cluster=True)
    for line in taxi_it('train'):
        if len(line['latitude'])>0:
            points.append(Point(line['latitude'][-1], line['longitude'][-1]))
            if len(points) >= _sample_size:
                break
    points.save('destinations (cluster)')
    points.cluster = False
    points.heatmap = True
    points.save('destinations (heatmap)')