Lerot’s documentation¶
Packages¶
lerot.analysis¶
lerot.comparison¶
-
class
lerot.comparison.
BalancedInterleave
(arg_str=None)[source]¶ Bases:
lerot.comparison.AbstractInterleavedComparison.AbstractInterleavedComparison
Interleave and compare rankers using the original balanced interleave method.
-
class
lerot.comparison.
DocumentConstraints
(arg_str='random')[source]¶ Bases:
lerot.comparison.AbstractInterleavedComparison.AbstractInterleavedComparison
Interleave using balanced interleave, compare using document constraints.
-
class
lerot.comparison.
HistBalancedInterleave
(arg_str=None)[source]¶ Bases:
lerot.comparison.AbstractHistInterleavedComparison.AbstractHistInterleavedComparison
Balanced interleave method, applied to historical data.
-
class
lerot.comparison.
HistDocumentConstraints
(arg_str=None)[source]¶ Bases:
lerot.comparison.AbstractHistInterleavedComparison.AbstractHistInterleavedComparison
Document constraints method, applied to historical data.
-
class
lerot.comparison.
HistProbabilisticInterleave
(arg_str=None)[source]¶ Bases:
lerot.comparison.AbstractHistInterleavedComparison.AbstractHistInterleavedComparison
Probabilistic interleaving using historical data
-
class
lerot.comparison.
HistTeamDraft
(arg_str=None)[source]¶ Bases:
lerot.comparison.AbstractHistInterleavedComparison.AbstractHistInterleavedComparison
Team draft method, applied to historical data.
-
class
lerot.comparison.
OptimizedInterleave
(arg_str='')[source]¶ Bases:
lerot.comparison.AbstractInterleavedComparison.AbstractInterleavedComparison
An implementation of Optimized Interleave as described in:
@see: Radlinski, F., & Craswell, N. (2013, February). Optimized interleaving for online retrieval evaluation. In Proceedings of the sixth ACM international conference on Web search and data mining (pp. 245-254).
@author: Anne Schuth @contact: anne.schuth@uva.nl @since: February 2013 @requires: Gurobi from http://www.gurobi.com/
-
perm_given_index
(alist, apermindex)[source]¶ See http://stackoverflow.com/questions/5602488/random-picks-from-permutation-generator
-
-
class
lerot.comparison.
OptimizedInterleaveVa
(arg_str=None)[source]¶ Bases:
lerot.comparison.OptimizedInterleave.OptimizedInterleave
-
class
lerot.comparison.
ProbabilisticInterleave
(arg_str=None)[source]¶ Bases:
lerot.comparison.AbstractInterleavedComparison.AbstractInterleavedComparison
Probabilistic interleaving, marginalizes over assignments
-
class
lerot.comparison.
ProbabilisticInterleaveWithHistory
(arg_str)[source]¶ Bases:
lerot.comparison.ProbabilisticInterleave.ProbabilisticInterleave
Probabilistic interleaving that reuses historic data (with importance sampling).
-
class
lerot.comparison.
StochasticBalancedInterleave
(arg_str)[source]¶ Bases:
lerot.comparison.AbstractInterleavedComparison.AbstractInterleavedComparison
Interleave and compare rankers using the stochastic interleave method introduced in Hofmann et al. ECIR‘11.
lerot.document¶
lerot.evaluation¶
-
class
lerot.evaluation.
AsRbpEval
(alpha=10, beta=0.8)[source]¶ Bases:
lerot.evaluation.AbstractEval.AbstractEval
Compute AS_RBP metric as described in [1].
[1] Zhou, K. et al. 2012. Evaluating aggregated search pages. SIGIR. (2012).
-
class
lerot.evaluation.
DcgEval
[source]¶ Bases:
lerot.evaluation.AbstractEval.AbstractEval
Compute DCG (with gain = 2**rel-1 and log2 discount).
-
evaluate_ranking
(ranking, query, cutoff=-1)[source]¶ Compute DCG for the provided ranking. The ranking is expected to contain document ids in rank order.
-
get_dcg
(ranked_labels, cutoff=-1)[source]¶ Get the dcg value of a list ranking. Does not check if the numer for ranked labels is smaller than cutoff.
-
get_value
(ranking, labels, orientations, cutoff=-1)[source]¶ Compute the value of the metric - ranking contains the list of documents to evaluate - labels are the relevance labels for all the documents, even those
that are not in the ranking; labels[doc.get_id()] is the relevance of doc- orientations contains orientation values for the verticals; orientations[doc.get_type()] is the orientation value for the doc (from 0 to 1).
-
-
class
lerot.evaluation.
NdcgEval
[source]¶ Bases:
lerot.evaluation.DcgEval.DcgEval
Compute NDCG (with gain = 2**rel-1 and log2 discount).
-
class
lerot.evaluation.
LetorNdcgEval
[source]¶ Bases:
lerot.evaluation.NdcgEval.NdcgEval
Compute NDCG as implemented in the Letor toolkit.
-
class
lerot.evaluation.
VSEval
[source]¶ Bases:
lerot.evaluation.AbstractEval.AbstractEval
Simple vertical selection (VS) metric, a.k.a. prec_v.
-
class
lerot.evaluation.
VDEval
[source]¶ Bases:
lerot.evaluation.AbstractEval.AbstractEval
Simple vertical selection (VD) metric, a.k.a. rec_v.
-
class
lerot.evaluation.
ISEval
[source]¶ Bases:
lerot.evaluation.AbstractEval.AbstractEval
Simple vertical selection (IS) metric, a.k.a. mean-prec.
-
class
lerot.evaluation.
RPEval
[source]¶ Bases:
lerot.evaluation.AbstractEval.AbstractEval
Simple vertical selection (RP) metric, a.k.a. corr.
lerot.environment¶
-
class
lerot.environment.
CascadeUserModel
(arg_str)[source]¶ Bases:
lerot.environment.AbstractUserModel.AbstractUserModel
Defines a cascade user model, simulating a user that inspects results starting from the top of a result list.
-
class
lerot.environment.
FederatedClickModel
(arg_str)[source]¶ Bases:
lerot.environment.AbstractUserModel.AbstractUserModel
-
class
lerot.environment.
PositionBasedUserModel
(p)[source]¶ Bases:
lerot.environment.AbstractUserModel.AbstractUserModel
Defines a positions based user model.
-
class
lerot.environment.
RandomClickModel
(p=0.5)[source]¶ Bases:
lerot.environment.AbstractUserModel.AbstractUserModel
Defines a positions based user model.
-
class
lerot.environment.
LivingLabsRealUser
(key, doc_ids)[source]¶ Bases:
lerot.environment.AbstractUserModel.AbstractUserModel
-
KEY
= ''¶
-
get_win
(query, feedback_list, lerot_ranked_list)[source]¶ Used for seznam site which interleaves ranked list with it’s own list Returns ‘ranked list winner’ with number of clicks of each ranker e.g. [0 2] where [lerot_list_score seznam_list_score]
-
runs
= {}¶
-
lerot.experiment¶
-
class
lerot.experiment.
LearningExperiment
(training_queries, test_queries, feature_count, log_fh, args)[source]¶ Bases:
lerot.experiment.AbstractLearningExperiment.AbstractLearningExperiment
Represents an experiment in which a retrieval system learns from implicit user feedback. The experiment is initialized as specified in the provided arguments, or config file.
-
class
lerot.experiment.
PrudentLearningExperiment
(training_queries, test_queries, feature_count, log_fh, args)[source]¶ Bases:
lerot.experiment.AbstractLearningExperiment.AbstractLearningExperiment
Represents an experiment in which a retrieval system learns from implicit user feedback. The experiment is initialized as specified in the provided arguments, or config file.
-
class
lerot.experiment.
HistoricalComparisonExperiment
(queries, feature_count, log_fh, args)[source]¶ Represents an experiment in which rankers are compared using interleaved comparisons with live and historic click data.
-
class
lerot.experiment.
SingleQueryComparisonExperiment
(query_dir, feature_count, log_fh, args)[source]¶ Represents an experiment in which rankers are compared using interleaved comparisons on a single query.
-
class
lerot.experiment.
SyntheticComparisonExperiment
(log_fh, args)[source]¶ Represents an experiment in which synthetic rankers are compared to investigate theoretical properties / guarantees.
-
class
lerot.experiment.
VASyntheticComparisonExperiment
(log_fh, args)[source]¶ Represents an experiment in which synthetic rankers are compared to investigate theoretical properties / guarantees.
-
static
generate_ranking_pair
(result_length, num_relevant, pos_method='beyondten', vert_rel='non-relevant', block_size=3, verticals=None, fixed=False, dominates=<function <lambda>>)[source]¶ Generate pair of synthetic rankings. Appendix A, https://bitbucket.org/varepsilon/tois2013-interleaving
-
static
lerot.ranker¶
-
class
lerot.ranker.
DeterministicRankingFunction
(ranker_arg_str, ties, feature_count, init='random', sample='sample_unit_sphere')[source]¶ Bases:
lerot.ranker.AbstractRankingFunction.AbstractRankingFunction
-
class
lerot.ranker.
ModelRankingFunction
[source]¶ Bases:
lerot.ranker.StatelessRankingFunction.StatelessRankingFunction
-
class
lerot.ranker.
ProbabilisticRankingFunction
(ranker_arg_str, ties, feature_count, init='random', sample='sample_unit_sphere')[source]¶ Bases:
lerot.ranker.AbstractRankingFunction.AbstractRankingFunction
-
class
lerot.ranker.
StatelessRankingFunction
(ranker_arg_str, ties, feature_count, init='random', sample='sample_unit_sphere')[source]¶ Bases:
lerot.ranker.AbstractRankingFunction.AbstractRankingFunction
-
class
lerot.ranker.
SyntheticDeterministicRankingFunction
(synthetic_docs)[source]¶ Bases:
lerot.ranker.StatelessRankingFunction.StatelessRankingFunction
Synthetic deterministic ranker.
-
class
lerot.ranker.
SyntheticProbabilisticRankingFunction
(ranker_arg_str, ties='random')[source]¶ Bases:
lerot.ranker.ProbabilisticRankingFunction.ProbabilisticRankingFunction
Synthetic ranker for use in this experiment only
lerot.retrieval_system¶
-
class
lerot.retrieval_system.
ListwiseLearningSystem
(feature_count, arg_str)[source]¶ Bases:
lerot.retrieval_system.AbstractLearningSystem.AbstractLearningSystem
A retrieval system that learns online from listwise comparisons. The system keeps track of all necessary state variables (current query, weights, etc.) so that comparison and learning classes can be stateless (implement only static / class methods).
-
class
lerot.retrieval_system.
PrudentListwiseLearningSystem
(feature_count, arg_str)[source]¶ Bases:
lerot.retrieval_system.AbstractLearningSystem.AbstractLearningSystem
A retrieval system that learns online from listwise comparisons. The system keeps track of all necessary state variables (current query, weights, etc.) so that comparison and learning classes can be stateless (implement only static / class methods).
-
class
lerot.retrieval_system.
ListwiseLearningSystemWithCandidateSelection
(feature_count, arg_str)[source]¶ Bases:
lerot.retrieval_system.ListwiseLearningSystem.ListwiseLearningSystem
A retrieval system that learns online from listwise comparisons, and pre-selects exploratory rankers using historic data.
-
select_candidate_repeated
(candidates)[source]¶ Selects a ranker in randomized matches. Ranker pairs are sampled uniformly and compared over a number of historical samples. The outcomes observed over these samples are averaged (with / without importance sampling). The worse-performing ranker is removed from the pool. If no preference is found, the ranker to be removed is selected randomly. The final ranker in the pool is returned. This selection method assumes transitivity.
-
select_candidate_simple
(candidates)[source]¶ Selects a ranker in randomized matches. For each historic data point two rankers are randomly selected from the pool and compared. If a ranker loses the comparison, it is removed from the pool. If there is more than one ranker left when the history is exhausted, a ranker is randomly selected from the remaining pool. This selection method assumes transitivity (a ranker that loses against one ranker is assumed to not be the best ranker).
-
-
class
lerot.retrieval_system.
PairwiseLearningSystem
(feature_count, arg_str)[source]¶ Bases:
lerot.retrieval_system.AbstractLearningSystem.AbstractLearningSystem
A retrieval system that learns online from pairwise comparisons. The system keeps track of all necessary state variables (current query, weights, etc.).
-
sample_unit_sphere
(n)[source]¶ See http://mathoverflow.net/questions/24688/efficiently-sampling- points-uniformly-from-the-surface-of-an-n-sphere
-
-
class
lerot.retrieval_system.
SamplerSystem
(feature_count, arg_str, run_count='')[source]¶ Bases:
lerot.retrieval_system.AbstractLearningSystem.AbstractLearningSystem
-
class
lerot.retrieval_system.
PerturbationLearningSystem
(feature_count, arg_str)[source]¶ Bases:
lerot.retrieval_system.AbstractLearningSystem.AbstractLearningSystem
A retrieval system that learns online from pairwise comparisons. The system keeps track of all necessary state variables (current query, weights, etc.) so that comparison and learning classes can be stateless (implement only static / class methods).
lerot.query¶
Interface to query data with functionality for reading queries from svmlight format, both sequentially and in batch mode.
-
class
lerot.query.
Queries
(fh, num_features, preserve_comments=False)[source]¶ a list of queries with some convenience functions
-
class
lerot.query.
QueryStream
(fh, num_features, preserve_comments=False)[source]¶ iterate over a stream of queries, only keeping one query at a time