Esempio n. 1
0
def makeV2(date_begin, folder):
    frame = pd.read_csv('data/farming.csv')
    frame_final = pd.read_csv(folder + '/' + 'y.csv')
    frame.sort_values(by=['time'], inplace=True)
    item_group = frame.groupby(['province', 'market', 'type', 'name'],
                               as_index=False)

    frame_final = pd.merge(
        frame_final,
        item_group['time'].agg({
            '_last_sell':
            (lambda x: -1
             if len(x) == 0 else tools.time_diff(x.as_matrix()[-1], date_begin)
             ),
            '_first_sell':
            (lambda x: -1
             if len(x) == 0 else tools.time_diff(x.as_matrix()[0], date_begin)
             ),
            # '_has_record': np.size,
        }),
        how='left')
    frame_final = pd.merge(frame_final,
                           item_group['avgprice'].agg(
                               {'_last_price': lambda x: x.as_matrix()[-1]}),
                           how='left')
    frame_final.drop(['y'], axis=1, inplace=True)
    frame_final.to_csv(folder + '/' + 'v2.csv', index=False)
    pass
Esempio n. 2
0
def makeV12(date_begin, folder):
    frame_final = pd.read_csv(folder + '/' + 'y.csv')
    frame_final['time_diff'] = frame_final['time'].apply(
        lambda x: np.log(tools.time_diff(x, date_begin)))
    frame_final.drop(['y'], axis=1, inplace=True)
    frame_final.to_csv(folder + '/' + 'v12.csv', index=False)
    pass
Esempio n. 3
0
    def get_diffs(self, current):
        """Returns list of previous practices expresed as the number
        of seconds that passed between *current* practice and all
        the *previous* practices.

        :param current: Datetime of the current practice.
        :type place: string
        """
        return [
            tools.time_diff(current, prior.inserted)
            for prior in self.practices
        ]
Esempio n. 4
0
    def predict(self, question):
        """Returns probability of correct answer for given question.

        :param question: Asked question.
        :type question: :class:`pandas.Series` or :class:`Question`
        """
        item = self.items[question.user_id, question.place_id]

        if item.practices:
            seconds = tools.time_diff(question.inserted, item.last_inserted)
            time_effect = self.time_effect(seconds)
        else:
            time_effect = 0

        prediction = tools.sigmoid(item.knowledge + time_effect)
        return self.respect_guess(prediction, question.options)