alpenglow.cpp package¶
The classes in this module are usually not used directly, but instead through the alpenglow.Getter
class. For more info, read
Note that there are some C++ classes that have no python interface. These are not documented here.
Filters¶
The function of the filter interface is limiting the available set of items. Current filters are whitelist-type filters, implementing alpenglow.cpp.WhitelistFilter
.
To use a filter in an experiment, wrap the model into the filter using alpenglow.cpp.WhitelistFilter2ModelAdapter
.
Example:
class LabelExperiment(prs.OnlineExperiment):
'''Sample experiment illustrating the usage of LabelFilter. The
experiment contains a PopularityModel and a LabelFilter.'''
def _config(self, top_k, seed):
model = ag.PopularityModel()
updater = ag.PopularityModelUpdater()
updater.set_model(model)
label_filter = ag.LabelFilter(**self.parameter_defaults(
label_file_name = ""
))
adapter = ag.WhitelistFilter2ModelAdapter()
adapter.set_model(model)
adapter.set_whitelist_filter(label_filter)
- class alpenglow.cpp.WhitelistFilter¶
Bases:
sip.wrapper
Filter interface for classes that implement white list type filtering.
- active(RecDat* rec_dat)¶
Returns whether the item is active for the user.
- Parameters
rec_dat (RecDat*) – The sample containing the user and the item.
- Returns
Whether the item is available for the user.
- Return type
bool
- get_whitelist(int user)¶
Returns the set of active items for the user.
- Parameters
user (int) – The whitelist will be computed for the given user.
- Returns
The list of allowed items for the given user. The second element of the pair is an upper bound for the score of the item for the given user (or the score itself).
- Return type
std::vector<int,double>
- class alpenglow.cpp.WhitelistFilter2ModelAdapter¶
Bases:
alpenglow.cpp.Model
Adapter class to filter the output of a model.
By chaining the adapter in front of a model, we can filter the output of the model, allowing only items on the whitelist filter to the toplist.
Note that as the currently implemented whitelists contain only a few elements, the adapter interface algorithm is optimized for short whitelists. We ignore the RSI of the model.
- prediction(RecDat*)¶
Returns filtered prediction value. The score of the items that are not on the whitelist is set to 0. Overrides method inherited from
alpenglow.cpp.Model.prediction()
, see also documentation there.- Parameters
rec_dat (RecDat*) – The sample we query the prediction for.
- Returns
The prediction score, modified based on the filter. If the item is not on the whitelist, the returned score is 0, otherwise the score returned by the model.
- Return type
double
- self_test()¶
Tests whether the model and the whitelist filter is set.
- Returns
Whether all necessary objects are set.
- Return type
bool
- set_model(Model* model)¶
Sets model whose output is filtered.
- Parameters
model (Model*) – The model whose output is filtered.
- set_whitelist_filter(WhitelistFilter* whitelist_filter)¶
Sets whitelist filter.
- Parameters
whitelist_filter (WhitelistFilter*) – The whitelist filter we use for filtering the output of the model.
- class alpenglow.cpp.LabelFilterParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.LabelFilter
. See documentation there.- label_file_name¶
- class alpenglow.cpp.LabelFilter¶
Bases:
alpenglow.cpp.WhitelistFilter
,alpenglow.cpp.Updater
White list filter class that allows items having the same label (e.g. artist) as the item that was previously interacted by the user. Requires updates (i.e., add the object to the online experiment as an updater).
Sample usage:
import alpenglow as ag model = ag.PopularityModel() updater = ag.PopularityModelUpdater() updater.set_model(model) label_filter = ag.LabelFilter( label_file_name = "/path/to/file/" ) adapter = ag.WhitelistFilter2ModelAdapter() adapter.set_model(model) adapter.set_whitelist_filter(label_filter)
- active(RecDat*)¶
Implements
alpenglow.cpp.WhitelistFilter.active()
.
- get_whitelist(int user)¶
Implements
alpenglow.cpp.WhitelistFilter.get_whitelist()
.
- self_test()¶
Returns true.
- update(RecDat* rec_dat)¶
Implements
alpenglow.cpp.Updater.update()
.
- class alpenglow.cpp.AvailabilityFilter¶
Bases:
alpenglow.cpp.WhitelistFilter
,alpenglow.cpp.NeedsExperimentEnvironment
This filter filters the set of available items based on (time,itemId,duration) triplets. These have to be preloaded before using this filter.
Sample code
1f = rs.AvailabilityFilter() 2f.add_availability(20,1,10) #item 1 is available in the time interval (20,30)
- active(RecDat* rec_dat)¶
Returns whether the item is active for the user.
- Parameters
rec_dat (RecDat*) – The sample containing the user and the item.
- Returns
Whether the item is available for the user.
- Return type
bool
- add_availability()¶
- get_whitelist(int user)¶
Returns the set of active items for the user.
- Parameters
user (int) – The whitelist will be computed for the given user.
- Returns
The list of allowed items for the given user. The second element of the pair is an upper bound for the score of the item for the given user (or the score itself).
- Return type
std::vector<int,double>
- self_test()¶
Offline evaluators¶
Use offline evaluators in traditional, fixed train/test split style learning.
Check the code of alpenglow.offline.OfflineModel.OfflineModel
descendants for usage examples.
- class alpenglow.cpp.PrecisionRecallEvaluatorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.PrecisionRecallEvaluator
. See documentation there.- cutoff¶
- test_file_name¶
- test_file_type¶
- time¶
- class alpenglow.cpp.PrecisionRecallEvaluator¶
Bases:
alpenglow.cpp.OfflineEvaluator
- evaluate()¶
- self_test()¶
- set_model()¶
- set_train_data()¶
Recommender data¶
This module contains the classes that are responsible for reading in the dataset and serving it to other classes of the experiment.
Interface alpenglow.cpp.RecommenderData
is the anchestor for
classes that read in the dataset. The two most frequently used implementations
are alpenglow.cpp.DataframeData
and
alpenglow.cpp.LegacyRecommenderData
.
Interface alpenglow.cpp.RecommenderDataIterator
is the anchestor
for classes that serve the data to the classes in the online experiment. See
The anatomy of an online experiment for general information. The most
frequently used implementations are alpenglow.cpp.ShuffleIterator
and alpenglow.cpp.SimpleIterator
.
- class alpenglow.cpp.RandomOnlineIteratorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.RandomOnlineIterator
. See documentation there.- seed¶
- class alpenglow.cpp.RandomOnlineIterator¶
Bases:
alpenglow.cpp.RecommenderDataIterator
This RecommenderDataIterator shuffles the samples keeping the timestamps ordered and serves them in a fixed random order. Note that the samples are modified, the nth sample of the random order gets the timestamp of the nth sample of the original data.
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- get(int index)¶
- get_actual()¶
- get_following_timestamp()¶
See
alpenglow.cpp.RecommenderDataIterator.get_following_timestamp()
- get_future(int index)¶
- self_test()¶
Tests if the class is set up correctly.
- class alpenglow.cpp.ShuffleIteratorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.ShuffleIterator
. See documentation there.- seed¶
- class alpenglow.cpp.ShuffleIterator¶
Bases:
alpenglow.cpp.RecommenderDataIterator
- autocalled_initialize()¶
- get(int index)¶
- get_actual()¶
- get_following_timestamp()¶
See
alpenglow.cpp.RecommenderDataIterator.get_following_timestamp()
- get_future(int index)¶
- self_test()¶
Tests if the class is set up correctly.
- class alpenglow.cpp.DataframeData¶
Bases:
alpenglow.cpp.RecommenderData
- add_recdats()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- get()¶
- size()¶
- class alpenglow.cpp.SimpleIterator¶
Bases:
alpenglow.cpp.RecommenderDataIterator
This RecommenderDataIterator serves the samples in the original order.
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- get(int index)¶
- get_actual()¶
- get_following_timestamp()¶
See
alpenglow.cpp.RecommenderDataIterator.get_following_timestamp()
- get_future(int index)¶
- class alpenglow.cpp.RecommenderDataIterator¶
Bases:
alpenglow.cpp.Initializable
Iterator-like interface that serves the dataset as a time series in the online experiment. The class also provides random access to the time series. Implementations assume that the data is already sorted by time.
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- get(int index)¶
This method provides random access to the past samples of the time series. It reaches an error if index is larger than the index of the current sample, i.e. if one tries to access data from the future through this function.
Use
get_counter()
to get the index of the newest available sample. Useget_future()
to get data from the future.- Parameters
index (int) – The index of sample to return.
- Returns
A pointer to the sample.
- Return type
RecDat*
- get_actual()¶
- Returns
A pointer to the actual sample.
- Return type
RecDat*
- get_counter()¶
- Returns
Index of the actual sample.
- Return type
int
- get_following_timestamp()¶
- Returns
The timestamp of the next sample in the future, i.e., when will the next event happen.
- Return type
double
- get_future(int index)¶
This method provides random access to the complete time series, including future.
Use
get()
to safely get data from the past.- Parameters
index (int) – The index of sample to return.
- Returns
A pointer to the sample.
- Return type
RecDat*
- has_next()¶
- Returns
Whether the iterator has’t reached the end of the time series.
- Return type
bool
- next()¶
Advances the iterator and returns a pointer to the following sample.
- Returns
A pointer to the following sample.
- Return type
RecDat*
- restart()¶
Restarts the iterator.
- self_test()¶
Tests if the class is set up correctly.
- set_recommender_data(RecommenderData* data)¶
Sets the dataset that we iterate on.
- Parameters
data (RecommenderData*) – The dataset.
- size()¶
- Returns
The number of the samples.
- Return type
int
- class alpenglow.cpp.RandomIteratorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.RandomIterator
. See documentation there.- seed¶
- shuffle_mode¶
- class alpenglow.cpp.RandomIterator¶
Bases:
alpenglow.cpp.RecommenderDataIterator
RecommenderDataIterator class that completely shuffles data. Note that the timestamps won’t stay in increasing order, that may cause faults in some time-dependent models.
Sample offline usage:
alpenglow.cpp.OfflineIteratingOnlineLearnerWrapper
- autocalled_initialize()¶
- get(int index)¶
- get_actual()¶
- get_following_timestamp()¶
See
alpenglow.cpp.RecommenderDataIterator.get_following_timestamp()
- get_future(int index)¶
- restart()¶
Restarts the iterator. In auto_shuffle mode it also reshuffles the dataset.
- self_test()¶
Tests if the class is set up correctly.
- shuffle()¶
Reshuffles the dataset.
- class alpenglow.cpp.RecDat¶
Bases:
sip.wrapper
Struct representing a training instance.
- category¶
model specific, mostly deprecated
- eval¶
whether this record is to be used for evaluation
- id¶
index of row in DataFrame; 0 based index if missing
- item¶
item id
- score¶
value of score column; 1 if column missing
- time¶
value of time column; 0 based index if missing
- user¶
user id
- class alpenglow.cpp.RecommenderData¶
Bases:
alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- clear()¶
- get()¶
- get_all_items()¶
- get_all_users()¶
- get_full_matrix()¶
- get_items_into()¶
- get_max_item_id()¶
- get_max_user_id()¶
- get_rec_data()¶
- get_users_into()¶
- set_rec_data()¶
- size()¶
- class alpenglow.cpp.LegacyRecommenderDataParameters¶
Bases:
sip.wrapper
- experiment_termination_time¶
- file_name¶
- type¶
- class alpenglow.cpp.LegacyRecommenderData¶
Bases:
alpenglow.cpp.RecommenderData
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- read_from_file()¶
- set_attribute_container()¶
Utils¶
This module contains miscellaneous helper classes.
- class alpenglow.cpp.PeriodComputerParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.PeriodComputer
. See documentation there.- period_length¶
- period_mode¶
- start_time¶
- class alpenglow.cpp.PeriodComputer¶
Bases:
alpenglow.cpp.Updater
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
Helper class to compute periods in the time series, e.g., update a model weekly or log statistics after every 10000th sample.
The class has two modes:
period_mode==”time”: the time is based on the timestamp queried from recommender_data_iterator.
period_mode==”samplenum”: the time is based on the number of calls to
update()
.
The class is notified about the progress of time by calls to the
update()
function.- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- end_of_period()¶
True if the current sample is the last in the current period.
If period_mode==time, the function returns true if the timestamp of the next sample falls into the next timeframe. If period_mode==samplenum, the function returns true if the next call to
update()
will increase the number of the timeframe.- Returns
True if the current sample is the last in the current period.
- Return type
bool
- get_period_num()¶
Returns the number of the current period, i.e. timestamp/period_length+1.
If period_mode==time, timestamp is the time field of the current recdat. If period_mode==samplenum, timestamp is the number of calls to the
update()
function.- Returns
The index of the current period.
- Return type
int
- self_test()¶
Returns true.
- set_parameters()¶
- set_recommender_data_iterator()¶
- update(RecDat*)¶
Notifies the class that time has changed.
If period_mode==samplenum, the time is increased by 1. If period_mode==time, the timestamp of the next sample is queried from recommender_data_iterator. The parameter value is not used at all.
- Parameters
rec_dat (RecDat*) – The current sample. Not used by the implementation.
- class alpenglow.cpp.SpMatrix¶
Bases:
sip.wrapper
Implements a sparse matrix. Obtaining a row is O(1), obtaining a value in a row is logarithmic in the length of the row.
- clear()¶
Deletes all elements and rows from the matrix.
- erase(int row_id, int col_id)¶
Removes the value from (row_id,col_id). If no value exists at that position, nothing happens.
- Parameters
row_id (int) – The index of the row.
col_id (int) – The index of the column.
- get(int row_id, int col_id)¶
Returns the value of (row_id,col_id). If no value exists at that position, returns 0.
- Parameters
row_id (int) – The index of the row.
col_id (int) – The index of the column.
- Returns
The value of (row_id,col_id) or 0 if no value.
- Return type
double
- has_value(int row_id, int col_id)¶
- Parameters
row_id (int) – The index of the row.
col_id (int) – The index of the column.
- Returns
Whether the matrix has value at (row_id,col_id).
- Return type
bool
- increase(int row_id, int col_id, double value)¶
Increases (row_id,col_id) with value or inserts value if (row_id,col_id) doesn’t exist (i.e. not existing value is equivalent to 0 value). The matrix is expanded and the row is created as necessary.
- Parameters
row_id (int) – The index of the row.
col_id (int) – The index of the column.
value (double) – The new value.
- insert(int row_id, int col_id, double value)¶
Inserts value to (row_id,col_id). If the value already exists, the insertion fails silently (the container doesn’t change. The matrix is expanded and the row is created as necessary.
- Parameters
row_id (int) – The index of the row.
col_id (int) – The index of the column.
value (double) – The value to be inserted.
- read_from_file(std::string file_name)¶
Reads matrix from file file_name. Format of the lines of the file is “row_id col_id value” . In case of repeating row_id col_id pairs, the first value will be used. Writes the size of the matrix to stderr. If the file can’t be opened, fails silently not changing the container.
- Parameters
file_name (std::string) – The name of the file to read from.
- resize(int row_id)¶
Expands the matrix to contain at least row_id rows. The matrix won’t be shrunken. Creates an empty row object at index row_id.
- Parameters
row_id (int) – The index of the row.
- row_size(int row_id)¶
Returns the number of the elements of the sparse row row_id. Returns 0 if the row doesn’t exist.
- Parameters
row_id (int) – The index of the row.
- Returns
The size of the row or 0 if the row doesn’t exist.
- Return type
int
- size()¶
- Returns
- Return type
The largest row index.
- update(int row_id, int col_id, double value)¶
Updates (row_id,col_id) to value or inserts value if (row_id,col_id) doesn’t exist. The matrix is expanded and the row is created as necessary.
- Parameters
row_id (int) – The index of the row.
col_id (int) – The index of the column.
value (double) – The new value.
- write_into_file(std::string file_name)¶
Writes matrix into file file_name. Format of the lines of the file is “row_id col_id value” , space separated. If the file can’t be opened, fails silently.
- Parameters
file_name (std::string) – The name of the file to write into.
- class alpenglow.cpp.Random¶
Bases:
sip.wrapper
This class implements a pseudorandom generator.
The next state is computed as state = state*multiplier % mod where multiplier = 48271 and mod = 2147483647.
The initial state value can be set through the parameter of the constructor, or using the
set()
function.Most of the functions are available without the max parameter providing a double value between [0,1) with a similar distribution as the discrete functions.
- get(int max)¶
Get a uniform pseudorandom value between 0 and max-1.
Largest possible value is max-1.
- Parameters
max (int) – The upper bound of the random value.
- Returns
The pseudorandom value.
- Return type
int
- get_arctg(double y, int max)¶
Get a pseudorandom value between 0 and max-1 with decaying distribution.
Probability of smaller values is larger. The largest possible value is max-1.
- Parameters
y (double) – The parameter of the distribution.
max (int) – The upper bound of the random value.
- Returns
The pseudorandom value.
- Return type
double
- get_boolean(double prob)¶
Get a pseudorandom true-or-false value.
- Parameters
prob (double) – The probability of the true value.
- Returns
The pseudorandom value.
- Return type
bool
- get_discrete(std::vector<double>& distribution)¶
Get a pseudorandom value following a given discrete distribution.
The sum of the values in the given vector should be 1. If the sum is more or less, the probability of the largest value(s) will differ from the specified probability. The values should be non-negative.
- Parameters
distribution (std::vector<double>&) – The probability of output value i is distribution[i].
- Returns
The pseudorandom value.
- Return type
int
- get_geometric(double prob, int max)¶
Get a pseudorandom value between 0 and max-1 with geometric distribution.
Probability of smaller values is larger. The largest possible value is max-1. The probability of value i is proportional to (1-prob)*prob^i`.
- Parameters
prob (double) – The parameter of the distribution.
max (int) – The upper bound of the random value.
- Returns
The pseudorandom value.
- Return type
int
- get_linear(int max)¶
Get a pseudorandom value between 0 and max-1 with linear distribution.
Probability of smaller values is smaller. The largest possible value is max-1.
- Parameters
max (int) – The upper bound of the random value.
- Returns
The pseudorandom value.
- Return type
int
- self_test()¶
- set(int seed)¶
Set the state of the random generator.
- class alpenglow.cpp.RankComputerParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.RankComputer
. See documentation there.- exclude_known¶
- random_seed¶
- top_k¶
- class alpenglow.cpp.RankComputer¶
Bases:
alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- get_rank()¶
- self_test()¶
- set_items()¶
- set_model()¶
- set_parameters()¶
- set_top_pop_container()¶
- set_train_matrix()¶
- class alpenglow.cpp.SparseAttributeContainerParameters¶
Bases:
sip.wrapper
- class alpenglow.cpp.FileSparseAttributeContainer¶
Bases:
alpenglow.cpp.SparseAttributeContainer
- load_from_file()¶
- class alpenglow.cpp.PowerLawRecencyParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.PowerLawRecency
. See documentation there.- delta_t¶
- exponent¶
- class alpenglow.cpp.PowerLawRecency¶
Bases:
alpenglow.cpp.Recency
- get()¶
- update()¶
- class alpenglow.cpp.PopContainer¶
Bases:
sip.wrapper
Container for storing the popularity of items.
- clear()¶
Clears the container. After this operations, the popularity of all the items is 0.
- get(int item)¶
Returns the popularity value of the item.
- Parameters
item (int) – The item.
- Returns
The popularity value of the item.
- Return type
int
- increase(int item)¶
Increases the popularity of the item.
- Parameters
item (int) – The item.
- reduce(int item)¶
Reduces the popularity of the item.
- Parameters
item (int) – The item.
- class alpenglow.cpp.TopPopContainer¶
Bases:
sip.wrapper
Helper class for storing the items sorted by popularity.
Sample code
1x = rs.TopPopContainer() 2x.increase(1) 3x.increase(1) 4x.increase(3) 5x.increase(4) 6x.increase(1) 7 8print("The most popular item is") 9print(x.get_item(0)) #returns 1 10print("The second most popular item is") 11print(x.get_item(1)) #returns 3 or 4
- create(int item)¶
Adds an item to the container. The item will have 0 popularity, but will be counted in
size()
.
- get_item(int index)¶
Returns the index’th item from the popularity toplist.
- Parameters
index (int) – Index of the item in the popularity toplist. The index of the most popular item is 0.
- Returns
The appropriate item from the toplist.
- Return type
int
- increase(int item)¶
Increases the popularity of the item.
- class alpenglow.cpp.ToplistCreatorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.ToplistCreator
. See documentation there.- exclude_known¶
- top_k¶
- class alpenglow.cpp.ToplistCreator¶
Bases:
alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run()¶
- self_test()¶
- set_items()¶
- set_model()¶
- set_train_matrix()¶
- class alpenglow.cpp.ToplistCreatorGlobalParameters¶
Bases:
alpenglow.cpp.ToplistCreatorParameters
Constructor parameter struct for
alpenglow.cpp.ToplistCreatorGlobalParameters : public ToplistCreator
. See documentation there.- initial_threshold¶
- class alpenglow.cpp.ToplistCreatorGlobal¶
Bases:
alpenglow.cpp.ToplistCreator
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run()¶
- self_test()¶
- set_filter()¶
- class alpenglow.cpp.ToplistCreatorPersonalizedParameters¶
Bases:
alpenglow.cpp.ToplistCreatorParameters
Constructor parameter struct for
alpenglow.cpp.ToplistCreatorPersonalizedParameters : public ToplistCreator
. See documentation there.
- class alpenglow.cpp.ToplistCreatorPersonalized¶
Bases:
alpenglow.cpp.ToplistCreator
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run()¶
- self_test()¶
Gradient computers¶
This module contains the gradient computer classes that implement gradient
computation necessary in gradient methods. See
alpenglow.experiments.FactorExperiment
for an example.
- class alpenglow.cpp.GradientComputer¶
Bases:
alpenglow.cpp.Updater
- add_gradient_updater()¶
- self_test()¶
Returns true.
- set_model()¶
- class alpenglow.cpp.GradientComputerPointWise¶
Bases:
alpenglow.cpp.GradientComputer
- self_test()¶
Returns true.
- set_objective()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
Objectives¶
This module contains the implementation of objective functions that are
necessary for gradient computation in gradient learning methods. See
alpenglow.experiments.FactorExperiment
for a usage example.
- class alpenglow.cpp.ObjectiveMSE¶
Bases:
alpenglow.cpp.ObjectivePointWise
- get_gradient()¶
General interfaces¶
This module contains the general interfaces that are implemented by classes belonging to different modules.
- class alpenglow.cpp.Initializable¶
Bases:
sip.wrapper
This interface signals that the implementing class has to be initialized by the experiment runner. The experiment runner calls the
initialize()
method, which in return calls the class-specific implementation ofautocalled_initialize()
and sets theis_initialized()
flag if the initialization was successful. Theautocalled_initialize()
method can check whether the neccessary dependencies have been initialized or not before initializing the instance; and should return the success value accordingly.If the initialization was not successful, the experiment runner keeps trying to initialize the not-yet initialized objects, thus resolving dependency chains.
Initializing and inheritance. Assume that class Parent implements Initializable, and the descendant Child needs further initialization. In that case Child has to override
autocalled_initialize()
, and call Parent::autocalled_initialize() in the overriding function first, continuing only if the parent returned true. If the init of the parent was succesful, but the children failed, then the children has to store the success of the parent and omit calling the initialization of the parent later.- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- initialize()¶
- Returns
Whether the initialization was successful.
- Return type
bool
- is_initialized()¶
- Returns
Whether the component has already been initialized.
- Return type
bool
- class alpenglow.cpp.Updater¶
Bases:
sip.wrapper
Interface for updating
alpenglow.cpp.Model
instances or other objects of the simulation. Objects may implement this interface themselves or have one or more associated Updater types.Examples:
alpenglow.cpp.TransitionProbabilityModel
andalpenglow.cpp.TransitionProbabilityModelUpdater
alpenglow.cpp.PopularityModel
has two updating algorithms:
alpenglow.cpp.PopularityTimeframeModelUpdater
alpenglow.cpp.PeriodComputer
implements the Updater interface
In the online experiment, updaters are organized into a chain. See The anatomy of an online experiment for details.
- self_test()¶
Returns true.
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
Negative sample generators¶
All the samples in an implicit dataset are positive samples. To make gradient
methods work, we need to provide negative samples too. This module contains
classes that implement different negative sample generation algorithms. These
classes implement alpenglow.cpp.NegativeSampleGenerator
. The most
frequently used implementation is
alpenglow.cpp.UniformNegativeSampleGenerator
.
- class alpenglow.cpp.UniformNegativeSampleGeneratorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.UniformNegativeSampleGenerator
. See documentation there.- filter_repeats¶
- negative_rate¶
- seed¶
- class alpenglow.cpp.UniformNegativeSampleGenerator¶
Bases:
alpenglow.cpp.NegativeSampleGenerator
,alpenglow.cpp.Initializable
,alpenglow.cpp.NeedsExperimentEnvironment
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- generate()¶
- self_test()¶
Returns true.
- set_items()¶
- set_train_matrix()¶
- class alpenglow.cpp.PooledPositiveSampleGeneratorParameters¶
Bases:
sip.wrapper
- pool_size¶
- positive_rate¶
- seed¶
- class alpenglow.cpp.PooledPositiveSampleGenerator¶
Bases:
alpenglow.cpp.NegativeSampleGenerator
Generates positive samples from a pool.
For details, see:
Frigó, E., Pálovics, R., Kelen, D., Kocsis, L., & Benczúr, A. (2017). Online ranking prediction in non-stationary environments. Section 3.5.
- generate()¶
- get_implicit_train_data()¶
- self_test()¶
Returns true.
- class alpenglow.cpp.NegativeSampleGenerator¶
Bases:
alpenglow.cpp.Updater
- add_updater()¶
- self_test()¶
Returns true.
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
Offline learners¶
Use offline learners in traditional, fixed train/test split style learning.
Check the code of alpenglow.offline.OfflineModel.OfflineModel
descendants for usage examples.
- class alpenglow.cpp.OfflineIteratingOnlineLearnerWrapperParameters¶
Bases:
sip.wrapper
- number_of_iterations¶
- seed¶
- shuffle¶
- class alpenglow.cpp.OfflineIteratingOnlineLearnerWrapper¶
Bases:
alpenglow.cpp.OfflineLearner
- add_early_updater()¶
- add_iterate_updater()¶
- add_updater()¶
- fit()¶
- self_test()¶
- class alpenglow.cpp.OfflineEigenFactorModelALSLearnerParameters¶
Bases:
sip.wrapper
- alpha¶
- clear_before_fit¶
- implicit¶
- number_of_iterations¶
- regularization_lambda¶
- class alpenglow.cpp.OfflineEigenFactorModelALSLearner¶
Bases:
alpenglow.cpp.OfflineLearner
- fit()¶
- iterate()¶
- self_test()¶
- set_copy_from_model()¶
- set_copy_to_model()¶
- set_model()¶
- class alpenglow.cpp.OfflineExternalModelLearnerParameters¶
Bases:
sip.wrapper
- in_name_base¶
- mode¶
- out_name_base¶
- class alpenglow.cpp.OfflineExternalModelLearner¶
Bases:
alpenglow.cpp.OfflineLearner
- fit()¶
- set_model()¶
Loggers¶
Loggers implement evaluators, statistics etc. in the online experiment. These
classes implement interface alpenglow.cpp.Logger
. See
The anatomy of an online experiment for a general view.
- class alpenglow.cpp.PredictionLogger¶
Bases:
alpenglow.cpp.Logger
- get_predictions()¶
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_prediction_creator()¶
- class alpenglow.cpp.MemoryRankingLoggerParameters¶
Bases:
sip.wrapper
- evaluation_start_time¶
- memory_log¶
- out_file¶
- random_seed¶
- top_k¶
- class alpenglow.cpp.MemoryRankingLogger¶
Bases:
alpenglow.cpp.Logger
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- get_ranking_logs()¶
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_items()¶
- set_model()¶
- set_ranking_logs()¶
- set_top_pop_container()¶
- set_train_matrix()¶
- class alpenglow.cpp.ProceedingLogger¶
Bases:
alpenglow.cpp.Logger
,alpenglow.cpp.Initializable
,alpenglow.cpp.NeedsExperimentEnvironment
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_data_iterator()¶
- class alpenglow.cpp.TransitionModelLoggerParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.TransitionModelLogger
. See documentation there.- period_length¶
- timeline_logfile_name¶
- top_k¶
- toplist_length_logfile_basename¶
- class alpenglow.cpp.TransitionModelLogger¶
Bases:
alpenglow.cpp.Logger
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_model()¶
- set_pop_container()¶
- set_train_matrix()¶
- class alpenglow.cpp.Logger¶
Bases:
sip.wrapper
Interface for evaluating the model and logging results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnineExperiment
calls loggers for each sample and at the end of the experiment. Seealpenglow.cpp.OnineExperiment
for details.- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- class alpenglow.cpp.OnlinePredictorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.OnlinePredictor
. See documentation there.- evaluation_start_time¶
- file_name¶
- time_frame¶
- class alpenglow.cpp.OnlinePredictor¶
Bases:
alpenglow.cpp.Logger
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_prediction_creator()¶
- class alpenglow.cpp.MemoryUsageLogger¶
Bases:
alpenglow.cpp.Logger
,alpenglow.cpp.Initializable
,alpenglow.cpp.NeedsExperimentEnvironment
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_data_iterator()¶
- class alpenglow.cpp.InterruptLogger¶
Bases:
alpenglow.cpp.Logger
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.ConditionalMetaLogger¶
Bases:
alpenglow.cpp.Logger
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
- set_logger()¶
- should_run()¶
- class alpenglow.cpp.ListConditionalMetaLoggerParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.ListConditionalMetaLogger
. See documentation there.- should_run_vector¶
- class alpenglow.cpp.ListConditionalMetaLogger¶
Bases:
alpenglow.cpp.ConditionalMetaLogger
- should_run()¶
- class alpenglow.cpp.InputLoggerParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.InputLogger
. See documentation there.- output_file¶
- class alpenglow.cpp.InputLogger¶
Bases:
alpenglow.cpp.Logger
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- run(RecDat* rec_dat)¶
Evaluates the model and logs results, statistics, simulation data, debug info etc.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this method. It is not allowed to modify the model or other simulation objects through this function.- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- self_test()¶
Returns true.
Online experiment¶
The central classes of the online experiments.
- class alpenglow.cpp.OnlineExperimentParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.OnlineExperiment
. See documentation there.- evaluation_start_time¶
- exclude_known¶
- experiment_termination_time¶
- initialize_all¶
- max_item¶
- max_user¶
- random_seed¶
- top_k¶
- class alpenglow.cpp.OnlineExperiment¶
Bases:
sip.wrapper
The central class of the online experiment.
It queries samples from the dataset, then one-by-one for each sample
calls loggers that are set using
add_logger()
,updates the environment and common statistics, see
alpenglow.cpp.ExperimentEnvironment
,calls the updaters that are set using
add_updater()
.
At the end of the experiment, it calls end loggers that are set using
add_end_logger()
.See
alpenglow.OnlineExperiment.OnlineExperiment
for details.- add_end_logger(Logger* logger)¶
Adds a logger instance, that will be called once at the end of the experiment.
- Parameters
logger (Logger*) – Pointer to the logger to be added.
- add_logger(Logger* logger)¶
Adds a logger instance.
- Parameters
logger (Logger*) – Pointer to the logger to be added.
- add_updater(Updater* updater)¶
Adds an updater.
- Parameters
updater (Updater*) – Pointer to the updater to be added.
- inject_experiment_environment_into(NeedsExperimentEnvironment* object)¶
Sets the experiment environment into another object that requires it.
In the online experiment, this method is automatically called with all the objects that implement
alpenglow.cpp.NeedsExperimentEnvironment
, injecting the dependency where it is necessary. See the code ofalpenglow.OnlineExperiment.OnlineExperiment
for details.
- run()¶
Runs the experiment.
- self_test()¶
Tests if the dataset is set.
Furthermore, the test produces a warning message if no loggers are set because in that case the the experiment will produce no output.
- Returns
Whether the tests were successful.
- Return type
bool
- set_recommender_data_iterator(RecommenderDataIterator* recommender_data_iterator)¶
Sets the dataset of the experiment.
- Parameters
recommender_data_iterator (RecommenderDataIterator*) – Pointer to the dataset.
- class alpenglow.cpp.ExperimentEnvironment¶
Bases:
sip.wrapper
Class that stores, updates and serves common simulation data and parameters, e.g. length of the top list, dataset and popularity of the items.
In the online experiment, the central class
alpenglow.cpp.OnlineExperiment
updates this class and the common statistic containers. This class is updated after calling loggers and before calling updaters (for each sample). See details there. Other objects are not allowed to modify this class or the statistic containers, even if they have non-const access (exception: the common Random).- get_evaluation_start_time()¶
- Returns
The beginning timestamp of evaluation. Elements in the time series before that timestamp will not be evaluated. Note that not all evaluator classes consider this value.
- Return type
int
- get_exclude_known()¶
- Returns
Whether each user-item pair should be evaluated only at the first occurrence, i.e., known user-item pairs should not be evaluated at repeated occurrences.
- Return type
bool
- get_experiment_termination_time()¶
- Returns
The last timestamp of evaluation. Elements in the time series after that timestamp will not be evaluated. Note that not all evaluator classes consider this value.
- Return type
int
- get_initialize_all()¶
- Returns
Whether all the users and items exist from the beginning of the experiment, or they appear only when they are mentioned first in a sample. If set, recode the dataset so that the users and items are numbered starting 0 or 1 continuously. Skipped ids are treated as existing too.
- Return type
bool
- get_items()¶
- Returns
A pointer to the list of known items. In the online experiment, the list is updated by this class for each sample after the call of the loggers and before the call to the updaters. If
initialize_all==True
, the list is filled with items at the beginning of the experiment.- Return type
std::vector<int>*
- get_max_item_id()¶
- Returns
The maximal item id int the whole experiment.
- Return type
int
- get_max_user_id()¶
- Returns
The maximal user id int the whole experiment.
- Return type
int
- get_popularity_container()¶
- Returns
A pointer to a container containing the popularity statistics of known items.
- Return type
PopContainer*
- get_popularity_sorted_container()¶
- Returns
A pointer to a container containing the popularity statistics of known items. The items can be acquired in popularity order. The container contains all known items.
- Return type
TopPopContainer*
- get_recommender_data_iterator()¶
- Returns
A pointer to the data iterator containing the time series of the experiment.
- Return type
RecommenderDataIterator*
- get_time()¶
- get_top_k()¶
- Returns
The top list length in the current experiment. Note that not all classes consider this value.
- Return type
int
- get_train_matrix()¶
- Returns
A pointer to the current training data in a sparse matrix form.
- Return type
SpMatrix*
- get_users()¶
- Returns
A pointer to the list of known users. In the online experiment, the list is updated by this class for each sample after the call of the loggers and before the call to the updaters. If
initialize_all==True
, the list is filled with users at the beginning of the experiment.- Return type
std::vector<int>*
- is_first_occurrence_of_item()¶
- Returns
Whether the current item is mentioned for the first time in the current sample. If
initialize_all==False
, equals tois_new_item()
.- Return type
bool
- is_first_occurrence_of_user()¶
- Returns
Whether the current user is mentioned for the first time in the current sample. If
initialize_all==False
, equals tois_new_user()
.- Return type
bool
- is_item_existent()¶
- Returns
Whether the item exists. If
initialize_all==True
, returns constant true value for items<=max_item_id, because all items exsist from the begininning of the experiment. Note that new items come into existence after te call to loggers, before the call to updaters.- Return type
bool
- is_item_new_for_user()¶
- Returns
Whether the current item is new for the current user, i.e., this is the first occurrence of this user-item pair in the time series. Note that the value is updated only when the loggers had been called already.
- Return type
bool
- is_new_item()¶
- Returns
Whether the current item is new, i.e. come to existence with the current sample. If
initialize_all==True
, returns constant false value, because all items exsist from the begininning of the experiment. Note that new items come into existence after te call to loggers, before the call to updaters.- Return type
bool
- is_new_user()¶
- Returns
Whether the current user is new, i.e. come to existence with the current sample. If
initialize_all==True
, returns constant false value, because all users exsist from the begininning of the experiment. Note that new users come into existence after te call to loggers, before the call to updaters.- Return type
bool
- is_user_existing()¶
- Returns
Whether the user exists. If
initialize_all==True
, returns constant true value for users<=max_user_id, because all users exsist from the begininning of the experiment. Note that new users come into existence after te call to loggers, before the call to updaters.- Return type
bool
- self_test()¶
- set_parameters()¶
Sets the parameters of the experiment. Called by
alpenglow.cpp.OnlineExperiment
.
- set_recommender_data_iterator()¶
Sets the dataset (the time series) of the experiment. Called by
alpenglow.cpp.OnlineExperiment
.
- update(RecDat* rec_dat)¶
Updates the container.
In the online experiment,
alpenglow.cpp.OnlineExperiment
calls this function after the call to the loggers and before the call to the updaters. Other classes should not call this function. :param rec_dat: The newest available sample of the experiment. :type rec_dat: RecDat*
Models¶
The prediction models in the experiments. The model interface is
alpenglow.cpp.Model
. See
Rank computation optimization about different evaluation methods.
Factor models¶
This module contains the matrix factorization based models.
- class alpenglow.cpp.EigenFactorModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.EigenFactorModel
. See documentation there.- begin_max¶
- begin_min¶
- dimension¶
- lemp_bucket_size¶
- seed¶
- class alpenglow.cpp.EigenFactorModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.Initializable
- add()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- clear()¶
- prediction()¶
- resize()¶
- self_test()¶
- class alpenglow.cpp.FactorModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.FmModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.FmModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.FmModel
. See documentation there.- begin_max¶
- begin_min¶
- dimension¶
- item_attributes¶
- seed¶
- user_attributes¶
- class alpenglow.cpp.FmModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.Initializable
- add()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- clear()¶
- prediction()¶
- self_test()¶
- class alpenglow.cpp.AsymmetricFactorModelGradientUpdaterParameters¶
Bases:
sip.wrapper
- cumulative_item_updates¶
- learning_rate¶
- class alpenglow.cpp.AsymmetricFactorModelGradientUpdater¶
Bases:
alpenglow.cpp.ModelGradientUpdater
- self_test()¶
- set_model()¶
- update()¶
- class alpenglow.cpp.SvdppModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.FactorModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.FactorModel
. See documentation there.- begin_max¶
- begin_min¶
- dimension¶
- initialize_all¶
- lemp_bucket_size¶
- max_item¶
- max_user¶
- seed¶
- use_item_bias¶
- use_sigmoid¶
- use_user_bias¶
- class alpenglow.cpp.FactorModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.SimilarityModel
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- add()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- clear()¶
- prediction()¶
- self_test()¶
- set_item_recency()¶
- set_user_recency()¶
- similarity()¶
- class alpenglow.cpp.AsymmetricFactorModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.SvdppModelGradientUpdaterParameters¶
Bases:
sip.wrapper
- cumulative_item_updates¶
- learning_rate¶
- class alpenglow.cpp.SvdppModelGradientUpdater¶
Bases:
alpenglow.cpp.ModelGradientUpdater
- self_test()¶
- set_model()¶
- update()¶
- class alpenglow.cpp.FactorModelGlobalRankingScoreIterator¶
Bases:
alpenglow.cpp.GlobalRankingScoreIterator
,alpenglow.cpp.NeedsExperimentEnvironment
- autocalled_initialize()¶
- get_global_items()¶
- get_global_users()¶
- run()¶
- self_test()¶
- set_experiment_environment()¶
- set_items()¶
- set_model()¶
- set_users()¶
- class alpenglow.cpp.SvdppModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.SvdppModel
. See documentation there.- begin_max¶
- begin_min¶
- dimension¶
- gamma¶
- history_weight¶
- initialize_all¶
- max_item¶
- max_user¶
- norm_type¶
- seed¶
- use_sigmoid¶
- user_vector_weight¶
- class alpenglow.cpp.SvdppModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- add()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- clear()¶
- prediction()¶
- self_test()¶
- class alpenglow.cpp.FactorModelGradientUpdaterParameters¶
Bases:
sip.wrapper
- learning_rate¶
- learning_rate_bias¶
- regularization_rate¶
- regularization_rate_bias¶
- turn_off_item_bias_updates¶
- turn_off_item_factor_updates¶
- turn_off_user_bias_updates¶
- turn_off_user_factor_updates¶
- class alpenglow.cpp.FactorModelGradientUpdater¶
Bases:
alpenglow.cpp.ModelGradientUpdater
- self_test()¶
- set_model()¶
- update()¶
- class alpenglow.cpp.AsymmetricFactorModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.AsymmetricFactorModel
. See documentation there.- begin_max¶
- begin_min¶
- dimension¶
- gamma¶
- initialize_all¶
- max_item¶
- norm_type¶
- seed¶
- use_sigmoid¶
- class alpenglow.cpp.AsymmetricFactorModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- add()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- clear()¶
- prediction()¶
- self_test()¶
Baseline models¶
This submodule contains the simple baseline models like nearest neighbor or most popular.
- class alpenglow.cpp.TransitionProbabilityModel¶
Bases:
alpenglow.cpp.Model
- clear()¶
- prediction()¶
- self_test()¶
- class alpenglow.cpp.NearestNeighborModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.NearestNeighborModel
. See documentation there.- direction¶
- gamma¶
- gamma_threshold¶
- norm¶
- num_of_neighbors¶
- class alpenglow.cpp.NearestNeighborModel¶
Bases:
alpenglow.cpp.Model
Item similarity based model.
See source of
alpenglow.experiments.NearestNeighborExperiment
for a usage example.- prediction(RecDat* rec_dat)¶
Implements
alpenglow.cpp.Model.prediction()
.
- self_test()¶
Tests whether the model is assembled appropriately.
- Returns
Whether the model is assembled appropriately.
- Return type
bool
- class alpenglow.cpp.PopularityTimeFrameModelUpdaterParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.PopularityTimeFrameModelUpdater
. See documentation there.- tau¶
- class alpenglow.cpp.PopularityTimeFrameModelUpdater¶
Bases:
alpenglow.cpp.Updater
Time-aware updater for PopularityModel, which only considers the last tau time interval when calculating popularities. Note that the time window ends at the timestamp of the last updating sample. the timestamp of the sample in the prediction call is not considered.
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.PersonalPopularityModel¶
Bases:
alpenglow.cpp.Model
- prediction()¶
- class alpenglow.cpp.PersonalPopularityModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.PopularityModel¶
Bases:
alpenglow.cpp.Model
- prediction()¶
- class alpenglow.cpp.NearestNeighborModelUpdaterParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.NearestNeighborModelUpdater
. See documentation there.- compute_similarity_period¶
- period_mode¶
- class alpenglow.cpp.NearestNeighborModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.TransitionProbabilityModelUpdaterParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.TransitionProbabilityModelUpdater
. See documentation there.- filter_freq_updates¶
- label_file_name¶
- label_transition_mode¶
- mode¶
- class alpenglow.cpp.TransitionProbabilityModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.PopularityModelUpdater¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_model()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
Model combination¶
This module contains the models that combine other models. The most frequently
used class is alpenglow.cpp.CombinedModel
. See
Model combination for a usage example.
- class alpenglow.cpp.ToplistCombinationModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.Initializable
,alpenglow.cpp.NeedsExperimentEnvironment
- add()¶
- add_model()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- inject_wms_into()¶
- prediction()¶
- self_test()¶
- class alpenglow.cpp.WeightedModelStructure¶
Bases:
sip.wrapper
- distribution_¶
- is_initialized()¶
- models_¶
- class alpenglow.cpp.RandomChoosingCombinedModel¶
Bases:
alpenglow.cpp.Model
,alpenglow.cpp.Initializable
- add()¶
- add_model()¶
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- inject_wms_into()¶
- prediction()¶
- self_test()¶
- class alpenglow.cpp.CombinedModelParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.CombinedModel
. See documentation there.- log_file_name¶
- log_frequency¶
- use_user_weights¶
- class alpenglow.cpp.CombinedModel¶
Bases:
alpenglow.cpp.Model
- add()¶
- add_model()¶
- prediction()¶
- class alpenglow.cpp.RandomChoosingCombinedModelExpertUpdaterParameters¶
Bases:
sip.wrapper
- eta¶
- loss_type¶
- top_k¶
- class alpenglow.cpp.RandomChoosingCombinedModelExpertUpdater¶
Bases:
alpenglow.cpp.Updater
,alpenglow.cpp.WMSUpdater
,alpenglow.cpp.Initializable
,alpenglow.cpp.NeedsExperimentEnvironment
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- self_test()¶
Returns true.
- set_experiment_environment()¶
- set_wms()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.CombinedDoubleLayerModelGradientUpdaterParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.CombinedDoubleLayerModelGradientUpdater
. See documentation there.- always_learn¶
- global_learning_rate¶
- global_regularization_rate¶
- learning_rate¶
- regularization_rate¶
- start_combination_learning_time¶
- class alpenglow.cpp.CombinedDoubleLayerModelGradientUpdater¶
Bases:
alpenglow.cpp.ModelGradientUpdater
- self_test()¶
- set_model()¶
- update()¶
- class alpenglow.cpp.Model¶
Bases:
sip.wrapper
- add()¶
- clear()¶
- prediction()¶
- read()¶
- self_test()¶
- write()¶
- class alpenglow.cpp.ExternalModel¶
Bases:
alpenglow.cpp.Model
- add()¶
- clear()¶
- prediction()¶
- read_predictions()¶
- self_test()¶
- class alpenglow.cpp.PythonModel¶
Bases:
alpenglow.cpp.Model
- class alpenglow.cpp.PythonToplistModel¶
Bases:
alpenglow.cpp.PythonModel
,alpenglow.cpp.TopListRecommender
- class alpenglow.cpp.PythonRankingIteratorModel¶
Bases:
alpenglow.cpp.PythonModel
,alpenglow.cpp.RankingScoreIteratorProvider
- iterator_get_next_()¶
- iterator_has_next_()¶
- class alpenglow.cpp.RankingScoreIteratorProvider¶
Bases:
sip.wrapper
Data generators¶
The classes in this module are responsible for generating data subsets from the
past. This is necessary for embedding offline models into the online
framework, that needs to be updated in a batch. See
alpenglow.experiments.BatchFactorExperiment
for a usage example.
- class alpenglow.cpp.SamplingDataGeneratorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.SamplingDataGenerator
. See documentation there.- distribution¶
- geometric_param¶
- number_of_samples¶
- seed¶
- y¶
- class alpenglow.cpp.SamplingDataGenerator¶
Bases:
alpenglow.cpp.DataGenerator
,alpenglow.cpp.Initializable
,alpenglow.cpp.NeedsExperimentEnvironment
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- generate_recommender_data()¶
- self_test()¶
- set_recommender_data_iterator()¶
- class alpenglow.cpp.CompletePastDataGenerator¶
Bases:
alpenglow.cpp.DataGenerator
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- generate_recommender_data()¶
- self_test()¶
- set_recommender_data_iterator()¶
- class alpenglow.cpp.TimeframeDataGeneratorParameters¶
Bases:
sip.wrapper
Constructor parameter struct for
alpenglow.cpp.TimeframeDataGenerator
. See documentation there.- timeframe_length¶
- class alpenglow.cpp.TimeframeDataGenerator¶
Bases:
alpenglow.cpp.DataGenerator
,alpenglow.cpp.NeedsExperimentEnvironment
,alpenglow.cpp.Initializable
- autocalled_initialize()¶
Has to be implemented by the component.
- Returns
Whether the initialization was successful.
- Return type
bool
- generate_recommender_data()¶
- self_test()¶
- set_recommender_data_iterator()¶
Online learners¶
This module contains classes that modifiy the learning process, e.g. delay the samples or feed them in a batch into offline learning methods.
- class alpenglow.cpp.LearnerPeriodicDelayedWrapper¶
Bases:
alpenglow.cpp.Updater
- self_test()¶
Returns true.
- set_wrapped_learner()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.
- class alpenglow.cpp.PeriodicOfflineLearnerWrapperParameters¶
Bases:
sip.wrapper
- base_in_file_name¶
- base_out_file_name¶
- clear_model¶
- learn¶
- read_model¶
- write_model¶
- class alpenglow.cpp.PeriodicOfflineLearnerWrapper¶
Bases:
alpenglow.cpp.Updater
- add_offline_learner()¶
- self_test()¶
Returns true.
- set_data_generator()¶
- set_model()¶
- set_period_computer()¶
- update(RecDat* rec_dat)¶
Updates the associated model or other object of the simulation.
- Parameters
rec_dat (RecDat*) – The newest available sample of the experiment.