def should_add_up(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            b_ = b.bins()

            expect(b[0] + b[1] + b[2] + b[3] + b[4] + b[5]).to.equal(2)
            expect(b_[0] + b_[1] + b_[2] + b_[3] + b_[4] + b_[5]).to.equal(2)
        def should_add_up(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            b_ = b.bins()

            expect(b[0] + b[1] + b[2] + b[3] + b[4] + b[5]).to.equal(2)
            expect(b_[0] + b_[1] + b_[2] + b_[3] + b_[4] + b_[5]).to.equal(2)
class DumbModel(Model):
    def __init__(self, start_time_range=(0,23.75,), day_of_week_range=(0,6,)):
        self.start_time_range = start_time_range
        self.day_of_week_range = day_of_week_range

        schedule = Schedule()

        lower_limit_start_time, upper_limit_start_time = start_time_range
        lower_limit_day_of_week, upper_limit_day_of_week = day_of_week_range

        for i in np.linspace(lower_limit_start_time, upper_limit_start_time, 96):
            for j in range(lower_limit_day_of_week, upper_limit_day_of_week + 1):
                schedule.add_lesson( WeeklyLesson(start_time=i, day_of_week=j))

        self.bins = Bins(schedule=schedule).bins()

    def fit(self, training_data):
        pass

    def generate_sample_schedule(self, business_forecast):
        schedule = Schedule()

        for i in business_forecast:
            for j in range(0, int(i['frequency'] * i['schedule_type'])):
                schedule.add_lesson(\
                        RandomWeeklyLesson(\
                        start_time_range=self.start_time_range,
                        day_of_week_range=self.day_of_week_range))

        return schedule

    def predict(self, business_forecast, training_data=pd.DataFrame()):
        return self.bins / self.bins.sum() * \
                self.num_business_forecast_lessons(business_forecast)
    def __init__(self, start_time_range=(0,23.75,), day_of_week_range=(0,6,)):
        self.start_time_range = start_time_range
        self.day_of_week_range = day_of_week_range

        schedule = Schedule()

        lower_limit_start_time, upper_limit_start_time = start_time_range
        lower_limit_day_of_week, upper_limit_day_of_week = day_of_week_range

        for i in np.linspace(lower_limit_start_time, upper_limit_start_time, 96):
            for j in range(lower_limit_day_of_week, upper_limit_day_of_week + 1):
                schedule.add_lesson( WeeklyLesson(start_time=i, day_of_week=j))

        self.bins = Bins(schedule=schedule).bins()
示例#5
0
 def bins(self):
     return Bins(schedule=self._schedule).bins()
        def by_default_should_be_6(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.num_bins()).to.equal(6)
        def it_should_aggregate_the_lesson_requests_per_bin(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.sum().sum()).to.equal(1)
        def it_should_aggregate_the_lesson_requests_per_bin(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.sum().sum()).to.equal(1)
        def by_default_should_be_6(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.num_bins()).to.equal(6)