zeeguu/core/word_scheduling/arts/tools/algo_parameter_approximator.py
def __run_algorithm_on_bookmarks(self, bookmarks, iterations=200, verbose=True):
        """
        Run the algorithm for amount x of iteration (learning sessions) on the specified list of bookmarks
        In each iteration a new exercise is added based on the AverageBookmarkExercise
        :return: a list of AverageBookmarkExercise
        """
        print('Found ' + str(len(bookmarks)) + ' bookmarks')

        bookmark_exercises = [AverageBookmarkExercise(x) for x in bookmarks]
        # next_bookmark is used to know which bookmark has the highest priority in order to add a new exercise for it
        next_bookmark = bookmark_exercises[0]  # First, we simply choose the first bookmark

        for i in range(0, iterations):
            # generate new exercise
            new_exercise = next_bookmark.append_new_exercise(i)
            if verbose:
                print("{:4} - {:} - {:1}".format(i, next_bookmark.bookmark.id, new_exercise.outcome.correct), end=', ')

            # update priorities
            max_priority = 0
            for bookmark_exercise in bookmark_exercises:
                new_priority = PriorityInfo.MAX_PRIORITY

                last_exercises = bookmark_exercise.exercises[-self.correct_count_limit:]
                if len(last_exercises) != 0:
                    count_correct = math.fsum([x.outcome.correct for x in last_exercises])
                    if count_correct == self.correct_count_limit:
                        new_priority = self.removed_bookmark_priority
                    else:
                        last_exercise = last_exercises[-1:][0]

                        try:
                            new_priority = self.algo_wrapper.calculate(last_exercise, i)
                        except Exception as e:
                            from sentry_sdk import capture_exception
                            capture_exception(e)

                            print('Exception during priority calculation: ' + str(e), e)
                    bookmark_exercise.priorities.append([i, new_priority])

                    if verbose:
                        if new_priority != self.removed_bookmark_priority:
                            print('{:+8.2f}'.format(new_priority), end=', ')
                        else:
                            print('{:8}'.format(''), end=', ')

                if new_priority > max_priority:
                    next_bookmark = bookmark_exercise
                    max_priority = new_priority
            if verbose:
                print('')  # newline
        return bookmark_exercises

        Run the algorithm for amount x of iteration (learning sessions) on the specified list of bookmarks
        In each iteration a new exercise is added based on the AverageBookmarkExercise
        :return: a list of AverageBookmarkExercise
        
Run the algorithm for amount x of iteration (learning sessions) on the specified list of bookmarks
In each iteration a new exercise is added based on the AverageBookmarkExercise
Run the algorithm for amount x of iteration ( learning sessions ) on the specified list of bookmarks In each iteration a new exercise is added based on the AverageBookmarkExercise
def __run_algorithm_on_bookmarks(self, bookmarks, iterations=200, verbose=True):
        print('Found ' + str(len(bookmarks)) + ' bookmarks')
        bookmark_exercises = [AverageBookmarkExercise(x) for x in bookmarks]
        next_bookmark = bookmark_exercises[0]  
        for i in range(0, iterations):
            new_exercise = next_bookmark.append_new_exercise(i)
            if verbose:
                print("{:4} - {:} - {:1}".format(i, next_bookmark.bookmark.id, new_exercise.outcome.correct), end=', ')
            max_priority = 0
            for bookmark_exercise in bookmark_exercises:
                new_priority = PriorityInfo.MAX_PRIORITY
                last_exercises = bookmark_exercise.exercises[-self.correct_count_limit:]
                if len(last_exercises) != 0:
                    count_correct = math.fsum([x.outcome.correct for x in last_exercises])
                    if count_correct == self.correct_count_limit:
                        new_priority = self.removed_bookmark_priority
                    else:
                        last_exercise = last_exercises[-1:][0]
                        try:
                            new_priority = self.algo_wrapper.calculate(last_exercise, i)
                        except Exception as e:
                            from sentry_sdk import capture_exception
                            capture_exception(e)
                            print('Exception during priority calculation: ' + str(e), e)
                    bookmark_exercise.priorities.append([i, new_priority])
                    if verbose:
                        if new_priority != self.removed_bookmark_priority:
                            print('{:+8.2f}'.format(new_priority), end=', ')
                        else:
                            print('{:8}'.format(''), end=', ')
                if new_priority > max_priority:
                    next_bookmark = bookmark_exercise
                    max_priority = new_priority
            if verbose:
                print('')  
        return bookmark_exercises
def __run_algorithm_on_bookmarks ( self , bookmarks , iterations = 200 , verbose = True ) : print ( 'Found ' + str ( len ( bookmarks ) ) + ' bookmarks' ) bookmark_exercises = [ AverageBookmarkExercise ( x ) for x in bookmarks ] next_bookmark = bookmark_exercises [ 0 ] for i in range ( 0 , iterations ) : new_exercise = next_bookmark . append_new_exercise ( i ) if verbose : print ( "{:4} - {:} - {:1}" . format ( i , next_bookmark . bookmark . id , new_exercise . outcome . correct ) , end = ', ' ) max_priority = 0 for bookmark_exercise in bookmark_exercises : new_priority = PriorityInfo . MAX_PRIORITY last_exercises = bookmark_exercise . exercises [ - self . correct_count_limit : ] if len ( last_exercises ) != 0 : count_correct = math . fsum ( [ x . outcome . correct for x in last_exercises ] ) if count_correct == self . correct_count_limit : new_priority = self . removed_bookmark_priority else : last_exercise = last_exercises [ - 1 : ] [ 0 ] try : new_priority = self . algo_wrapper . calculate ( last_exercise , i ) except Exception as e : from sentry_sdk import capture_exception capture_exception ( e ) print ( 'Exception during priority calculation: ' + str ( e ) , e ) bookmark_exercise . priorities . append ( [ i , new_priority ] ) if verbose : if new_priority != self . removed_bookmark_priority : print ( '{:+8.2f}' . format ( new_priority ) , end = ', ' ) else : print ( '{:8}' . format ( '' ) , end = ', ' ) if new_priority > max_priority : next_bookmark = bookmark_exercise max_priority = new_priority if verbose : print ( '' ) return bookmark_exercises
Run the algorithm for amount x of iteration (learning sessions) on the specified list of bookmarks
In each iteration a new exercise is added based on the AverageBookmarkExercise
Run the algorithm for amount x of iteration ( learning sessions ) on the specified list of bookmarks In each iteration a new exercise is added based on the AverageBookmarkExercise
"""
        Run the algorithm for amount x of iteration (learning sessions) on the specified list of bookmarks
        In each iteration a new exercise is added based on the AverageBookmarkExercise
        :return: a list of AverageBookmarkExercise
        """ # next_bookmark is used to know which bookmark has the highest priority in order to add a new exercise for it # First, we simply choose the first bookmark # generate new exercise # update priorities # newline
a list of AverageBookmarkExercise
a list of AverageBookmarkExercise
self
bookmarks
iterations
verbose