예제 #1
0
파일: evmaker.py 프로젝트: lerosua/gmcore
 def on_bt_time_add_clicked(self, widget):
     if self.time_mark == "A":
         astr = self.label_A.get_text()
         a = utils.string_to_time(astr)
         a = a+1
         self.label_A.set_text(utils.time_to_string(a))
     elif self.time_mark == "B":
         astr = self.label_B.get_text()
         b = utils.string_to_time(astr)
         b = b+1
         self.label_B.set_text(utils.time_to_string(b))
예제 #2
0
파일: evmaker.py 프로젝트: lerosua/gmcore
 def on_bt_time_sub_clicked(self, widget):
     if self.time_mark == "A":
         astr = self.label_A.get_text()
         a = utils.string_to_time(astr)
         a = a-1
         if a< 0 :
             a = 0
         self.label_A.set_text(utils.time_to_string(a))
     elif self.time_mark == "B":
         astr = self.label_B.get_text()
         b = utils.string_to_time(astr)
         b = b-1
         if b < 0:
             b=0
         self.label_B.set_text(utils.time_to_string(b))
예제 #3
0
 def list(self, tid=None):
     '''
   list all records whose parent is tid
 '''
     R = Query()
     Records = self._DB.search(R['status'] != "DONE" and R['parent'] == tid)
     Records.sort(key=lambda R: utils.string_to_time(R['eta']))
     return Records
예제 #4
0
def predict_time_instance(time, date, model):
    """
    Predict the state of the light at a given time, based on previous collected data

    Input:
    
        time: time the prediction needs to be made. Given in string format "HH:MM"
        date: date of the prediction. Given in format "%yyyy-%mm-%dd"
        model: the trained model
        
    Returns:

        prediction: prediction of the state of the light (1 or 0).
    """
    year, month, day = (int(x) for x in date.split('-'))
    day = datetime(year, month, day).strftime("%A")
    time = u.string_to_time(time) / TOTAL_TIME
    predict_vector = pd.DataFrame(np.array([time]), columns=[date])
    predict_vector = u.day_of_week_one_hot(predict_vector)
    prediction = model.predict(predict_vector.values)
    prediction_class = tf.nn.sigmoid(prediction).numpy()[0, 0]
    return int(round(prediction_class))