예제 #1
0
파일: app.py 프로젝트: jzellman/keras
def total_ranges():
    return (
        ("prev_year", utils.prev_year_range()),
        ("this_year", utils.year_range()),
        ("prev_month", utils.prev_month_range()),
        ("this_month", utils.month_range()),
        ("prev_week", utils.prev_week_range()),
        ("this_week", utils.week_range()),
        ("this_day", utils.day_range()),
        ("prev_day", utils.prev_day_range()))
예제 #2
0
파일: tests.py 프로젝트: jzellman/keras
 def test_week_range(self):
     d = datetime(2010, 4, 16, 23, 3)
     start, end = utils.week_range(d)
     self.assertEqual(datetime(2010, 4, 11), start)
     self.assertEqual(datetime(2010, 4, 17, 23, 59, 59, 999999), end)
예제 #3
0
    hours = db.list_hours()
    servers = db.list_servers()

    result = Result()
    default_bandwidth = db.get_bandwidth_avg()
    default_max_user = db.get_max_user_avg()
    result.set_default(default_bandwidth, default_max_user)

    total_iteration = len(weekdays) * len(hours) * len(servers)

    print('Train...')
    pbar = tqdm(total=total_iteration)
    for weekday, hour, server in itertools.product(weekdays, hours, servers):
        pbar.update(1)

        dates_train = list(week_range(start_date_train, end_date_train, weekday))
        
        data = db.filter(UPDATE_TIME=dates_train, HOUR_ID=hour, SERVER_NAME=server)
        if len(data) == 0:
            continue

        x_train = [row['UPDATE_TIME'] for row in data]
        y1_train = [row['BANDWIDTH_TOTAL'] for row in data]
        y2_train = [row['MAX_USER'] for row in data]
        dates_predict = list(week_range(start_date_predict, end_date_predict, weekday))

        model = Model()
        model.fit(x_train, y1_train, y2_train)
        y1_predict, y2_predict = model.predict(dates_predict)

        for date, y1, y2 in zip(dates_predict, y1_predict, y2_predict):