Exemple #1
0
    def fireAlarm(self):
        self._getFiftenMiniutesPhotos()  #get current_value
        cur_hour = datetime.utcfromtimestamp(float(self.cur_time)).hour
        #print 'cur_hour = ',cur_hour, 'time = ',self.cur_time
        mu = self.means[cur_hour] / 4.0
        std = self.stds[cur_hour] / 4.0
        #print 'mu is ',mu, 'std is ',std, 'cur_value = ',self.current_value
        zscore = (self.current_value - mu) * 1.0 / std

        if zscore > 3 and self.current_value >= 8:
            e = Event()
            e.setPredictedValues(mu, std)
            e.setZscore(zscore)
            e.setRegion(self.region)
            e.setCreatedTime(self.cur_time)
            e.setActualValue(self.current_value)

            for p in self.photos:
                e.addPhoto(p)

            ei = EventInterface()
            ei.setCollection(self.candidate_collection)
            #print datetime.utcfromtimestamp(float(e.getEarliestPhotoTime())), datetime.utcfromtimestamp(float(e.getLatestPhotoTime()))
            #print e.getEarliestPhotoTime(),e.getLatestPhotoTime()
            #print e.toJSON()['region']
            ei.addEvent(e)
Exemple #2
0
    def fireAlarm(self):
        prediction = self.getNearestPrediction()

        self._getFiftenMiniutesPhotos()
        if prediction is None:
            print 'None data for this region: details as follow'
            self.region.display()
            print 'time:', self.cur_time
            return
        mu = float(prediction['mu']) / 4.0
        std = float(prediction['std']) / 4.0
        time_stamp = prediction['time']

        zscore = (self.current_value - mu) * 1.0 / std

        if zscore > 3:
            e = Event()
            e.setPredictedValues(mu, std)
            e.setZscore(zscore)
            e.setRegion(self.region)
            e.setCreatedTime(self.cur_time)
            e.setActualValue(self.current_value)

            for p in self.photos:
                e.addPhoto(p)
            #print 'current value ',4.0*self.current_value, ' predict = ',mu*4.0,' std = ',std*4.0

            ei = EventInterface()
            ei.setCollection(self.candidate_collection)
            print e.getEarliestPhotoTime(), e.getLatestPhotoTime()
            #print e.toJSON()['region']
            #ei.addEvent(e)
            ei.addEventWithoutMerge(e)
Exemple #3
0
    def __init__(self):
        self.ei = EventInterface()
        self.ei.setDB('AmazonMT')
        self.ei.setCollection('candidate_event_25by25_merged')
        self.representor = Representor()
        #self.ei.setDB('citybeat')
        #self.ei.setCollection('next_week_candidate_event_25by25_merged')
        #self.ei.setCollection('online_candidate')

        self._loadCrowdFlowerCode()
Exemple #4
0
    def __init__(self):
        self.ei = EventInterface()
        #self.ei.setDB('AmazonMT')
        #self.ei.setCollection('candidate_event_25by25_merged')

        self.ei.setDB('citybeat')
        #self.ei.setCollection('next_week_candidate_event_25by25_merged')
        self.ei.setCollection('online_candidate')

        #collection = 'candidate_event_25by25_merged'
        #self.c = Corpus()
        #self.c.buildCorpusOnDB('AmazonMT', collection)

        #collection = 'candidate_event_25by25_merged'
        #self.c = Corpus()
        #self.c.buildCorpusOnDB('citybeat', 'online_candidate')

        self._loadCrowdFlowerCode()

        self.cache_events = {}
        self.cache_photos = {}
Exemple #5
0
from utility.event_interface import EventInterface

ei = EventInterface()
ei.setDB('citybeat')
ei.setCollection('baseline_candidate_events')
p = ei.getPhotoDistributionArray()
print p