Esempio n. 1
0
 def testAccuracyRlai(self):
     #Test if hour when max people in room is 7pm ie 19hr for 14 feb 2019
     r = Reinforcement('2019-02-14.csv', True)
     sen_files = r.get_sensor_original_file()
     r.parse_file(sen_files)
     out = r.q_learning()
     self.assertEqual(out, "19")
Esempio n. 2
0
def update_humidity_graph(selcted_date):
    file_name = file_download_csv(selcted_date)
    df = pd.read_csv(file_name, sep=',', parse_dates=['Time'])
    df = df.sort_values(by='Time')
    r = Reinforcement(file_name, False)
    sen_files = r.get_sensor_original_file()
    r.parse_file(sen_files)
    out = r.q_learning()
    time = selcted_date + " " + str(out) + ":00:00"
    qdate = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
    endtime = selcted_date + " " + str(int(out) + 1) + ":00:00"
    endtime = datetime.strptime(endtime, "%Y-%m-%d %H:%M:%S")
    df1 = df[(df.Time > qdate) & (df.Time < endtime)]
    return {
        'data': [{
            'x': df.Time,
            'y': df.Humidity,
            'name': 'Humidity',
            'scatter': {
                'width': 1
            }
        }, {
            'x': df1.Time,
            'y': df1.Humidity,
            'name': 'Max people',
            'scatter': {
                'width': 1
            }
        }],
        'layout': {
            'title': 'Humidity',
            'xaxis': {
                'title': 'Time'
            },
            'yaxis': {
                'title': 'Humidity'
            }
        }
    }
Esempio n. 3
0
def update_temp_graph(selcted_date, tab):
    file_name = file_download_csv(selcted_date)
    df = pd.read_csv(file_name, sep=',', parse_dates=['Time'])
    df = df.sort_values(by='Time')
    r = Reinforcement(file_name, True)
    sen_files = r.get_sensor_original_file()
    result = r.parse_file(sen_files)
    if result:
        out = r.q_learning()
        time = selcted_date + " " + str(out) + ":00:00"
        qdate = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
        endtime = selcted_date + " " + str(int(out) + 1) + ":00:00"
        endtime = datetime.strptime(endtime, "%Y-%m-%d %H:%M:%S")
        df1 = df[(df.Time > qdate) & (df.Time < endtime)]
        if tab == 'tab-1':
            return html.Div([
                dcc.Graph(id='graph-1-tabs',
                          figure={
                              'data': [{
                                  'x': df.Time,
                                  'y': df.Temperature,
                                  'scatter': {
                                      'width': 1,
                                      'shape': 'spline'
                                  }
                              }],
                              'layout': {
                                  'xaxis': {
                                      'title': 'Time'
                                  },
                                  'yaxis': {
                                      'title': 'Temperature'
                                  }
                              }
                          })
            ])
        elif tab == 'tab-2':
            return html.Div([
                dcc.Graph(id='graph-2-tabs',
                          figure={
                              'data': [{
                                  'x': df.Time,
                                  'y': df.Humidity,
                                  'name': 'Humidity',
                                  'scatter': {
                                      'width': 1
                                  }
                              }, {
                                  'x': df1.Time,
                                  'y': df1.Humidity,
                                  'name': 'Max people',
                                  'scatter': {
                                      'width': 1
                                  }
                              }],
                              'layout': {
                                  'xaxis': {
                                      'title': 'Time'
                                  },
                                  'yaxis': {
                                      'title': 'Humidity'
                                  }
                              }
                          })
            ])
        elif tab == 'tab-3':
            return html.Div([
                dcc.Graph(id='graph-1-tabs',
                          figure={
                              'data': [{
                                  'x': df.Time,
                                  'y': df.Pressure,
                                  'line': {
                                      'width': 1,
                                      'shape': 'spline'
                                  }
                              }],
                              'layout': {
                                  'xaxis': {
                                      'title': 'Time'
                                  },
                                  'yaxis': {
                                      'title': 'Pressure'
                                  }
                              }
                          })
            ])