Class RetrieverEvaluation<TCase extends DataObject>
java.lang.Object
de.uni_trier.wi2.procake.utils.eval.RetrieverEvaluation<TCase>
- Direct Known Subclasses:
MACFACRetrieverEvaluation
Can be used to evaluate different retrievers or differently configured retrievers. Hence, some
parameters can be specified in order to control the evaluation.
- Author:
- Maximilian Hoffmann
-
Field Summary
Modifier and TypeFieldDescriptionprotected DecimalFormat
Specifies the decimal format for the csv output.protected List<SimpleSimilarityResult>
The ground-truth similarities are stored as a list of simple similarity results that come from retrievals.protected Integer
Specifies the number of cases to inspect beginning with the most similar case.protected final org.slf4j.Logger
protected Map<RetrieverMetricKeyPair,
Double> Map containing the retrievers and the metrics asRetrieverMetricKeyPair
and the corresponding metric values.protected final List<EvalMetric>
All metrics that are to computed during the evaluation.Map containing the names of the retrievers and the times required for each.The list of retrievers to evaluate.protected Map<CasePair,
Collection<RetrieverSimilarityPair>> Map containing a case pair and a list of predictions from all retrievers for this pair.protected boolean
Tracks and prints the detailed pairwise similarities computed by every retriever.protected TrainingObjectPool<TCase>
The training object pool, that contains training case base, i.e., the case base to retrieve from, and testing case base, i.e., the case base to extract queries from. -
Constructor Summary
ConstructorDescriptionRetrieverEvaluation
(WriteableObjectPool<TCase> trainCaseBase, WriteableObjectPool<TCase> testCaseBase) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMetricsToEvaluate
(Collection<EvalMetric> metrics) Adds metrics to compute during evaluation.void
addMetricToEvaluate
(EvalMetric metric) Adds a metric to compute during evaluation.void
Adds retrievers to evaluate.void
addRetrieverToEvaluate
(String uniqueRetrieverName, Retriever<TCase, Query> retriever) Adds a retriever to evaluate.getK()
Writes metric results as CSV to a string.Writes similarity results as CSV to a string.void
importGroundTruthSimilarities
(String pathGroundTruthSimilarities) Loads the ground-truth similarities and tests them.Main method for performing the evaluation of the given retrievers according to the specified parameters.void
Writes metric results as ASCII table to standard output.void
setDecimalFormat
(DecimalFormat decimalFormat) Change theDecimalFormat
for a csv output.void
setGroundTruthSimilarities
(List<SimpleSimilarityResult> gtSimilarities) Set the ground-truth similarities that are loaded outside of the evaluation.void
void
setTrainTestCaseBase
(WriteableObjectPool<TCase> trainCaseBase, WriteableObjectPool<TCase> testCaseBase) Method used to store the training case base and the testing case base in the retriever evaluation, if this has not been done in the constructor.void
Tracks and prints the detailed pairwise similarities computed by every retriever.writeMetricResultsAsCSV
(OutputStream outputStream) Writes metric results as CSV file to an output stream.writeMetricResultsAsCSV
(String exportPathExportResults) Writes metric results as CSV file to file system.writeSimilarityResultsAsCSV
(OutputStream outputStream) Writes similarity results as CSV file to an output stream.writeSimilarityResultsAsCSV
(String exportPathExportResults) Writes similarity results as CSV file to file system.
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
retrievers
The list of retrievers to evaluate. -
metrics
All metrics that are to computed during the evaluation. -
trainingObjectPool
The training object pool, that contains training case base, i.e., the case base to retrieve from, and testing case base, i.e., the case base to extract queries from. -
groundTruthSimilarities
The ground-truth similarities are stored as a list of simple similarity results that come from retrievals. -
k
Specifies the number of cases to inspect beginning with the most similar case. Metrics can use this constant for their computations. -
metricResults
Map containing the retrievers and the metrics asRetrieverMetricKeyPair
and the corresponding metric values. -
similarityResults
Map containing a case pair and a list of predictions from all retrievers for this pair. This data can be used to compare the predictions of all retrievers for each case pair. -
retrievalTimeResultMap
Map containing the names of the retrievers and the times required for each. -
decimalFormat
Specifies the decimal format for the csv output. -
trackSimilarityResults
protected boolean trackSimilarityResultsTracks and prints the detailed pairwise similarities computed by every retriever. Enable this if you want to analyze this data later on. Be cautious since this can use a large amount of memory.
-
-
Constructor Details
-
RetrieverEvaluation
public RetrieverEvaluation() -
RetrieverEvaluation
public RetrieverEvaluation(WriteableObjectPool<TCase> trainCaseBase, WriteableObjectPool<TCase> testCaseBase)
-
-
Method Details
-
performEvaluation
Main method for performing the evaluation of the given retrievers according to the specified parameters. Assumes that ProCAKE was already started (CakeInstance.start()
).- Returns:
- the evaluation results as a map with a
RetrieverMetricKeyPair
as key and a double as value. - Throws:
RetrieverEvaluationException
- if something goes wrong while evaluating
-
setGroundTruthSimilarities
Set the ground-truth similarities that are loaded outside of the evaluation.- Parameters:
gtSimilarities
- list of simple similarity results where each entry represents a single retrieval
-
addRetrieverToEvaluate
Adds a retriever to evaluate.- Parameters:
uniqueRetrieverName
- a unique retriever name to identify it in the resultsretriever
- the pre-configured retriever
-
addMetricToEvaluate
Adds a metric to compute during evaluation. Besides these metrics, the avg. retrieval time is always computed.- Parameters:
metric
- the metric to compute during evaluation
-
setTrainTestCaseBase
public void setTrainTestCaseBase(WriteableObjectPool<TCase> trainCaseBase, WriteableObjectPool<TCase> testCaseBase) Method used to store the training case base and the testing case base in the retriever evaluation, if this has not been done in the constructor. In the background, these are stored in aTrainingObjectPool
.- Parameters:
trainCaseBase
- The training case base, i.e., the case base to retrieve from.testCaseBase
- The testing case base, i.e., the case base to extract queries from.
-
getK
-
setK
-
setDecimalFormat
Change theDecimalFormat
for a csv output.- Parameters:
decimalFormat
- The desired decimal format.
-
addRetrieversToEvaluate
Adds retrievers to evaluate.- Parameters:
retrieverMap
- A map consisting of a unique retriever name to identify it in the results and the pre-configured retrievers.
-
addMetricsToEvaluate
Adds metrics to compute during evaluation. Besides these metrics, the avg. retrieval time is always computed.- Parameters:
metrics
- Collection of the metrics to compute during evaluation
-
importGroundTruthSimilarities
Loads the ground-truth similarities and tests them.- Parameters:
pathGroundTruthSimilarities
- The path to load the ground-truth similarities from.
-
writeSimilarityResultsAsCSV
Writes similarity results as CSV file to file system.- Parameters:
exportPathExportResults
- the path to write the results to- Returns:
- the evaluation results as a CSV string
- Throws:
IOException
- if something goes wrong during export. Ignore if you do not want to export any values.
-
getSimilarityResultsAsCSVString
Writes similarity results as CSV to a string.- Returns:
- the evaluation results as a CSV string
- Throws:
IOException
RetrieverEvaluationException
-
writeSimilarityResultsAsCSV
Writes similarity results as CSV file to an output stream. The calling method is responsible for closing the stream afterwards!- Parameters:
outputStream
- the stream to write the results to- Returns:
- the evaluation results as a CSV string
- Throws:
IOException
- if something goes wrong during export. Ignore if you do not want to export any values.
-
writeMetricResultsAsCSV
public String writeMetricResultsAsCSV(String exportPathExportResults) throws IOException, RetrieverEvaluationException Writes metric results as CSV file to file system.- Parameters:
exportPathExportResults
- the path to write the results to- Returns:
- the evaluation results as a CSV string
- Throws:
IOException
- if something goes wrong during export. Ignore if you do not want to export any values.RetrieverEvaluationException
- if something goes wrong while evaluating
-
getMetricResultsAsCSVString
Writes metric results as CSV to a string.- Returns:
- the evaluation results as a CSV string
- Throws:
IOException
RetrieverEvaluationException
-
writeMetricResultsAsCSV
public String writeMetricResultsAsCSV(OutputStream outputStream) throws IOException, RetrieverEvaluationException Writes metric results as CSV file to an output stream. The calling method is responsible for closing the stream afterwards!- Parameters:
outputStream
- the stream to write the results to- Returns:
- the evaluation results as a CSV string
- Throws:
IOException
- if something goes wrong during export. Ignore if you do not want to export any values.RetrieverEvaluationException
- if something goes wrong while evaluating
-
printMetricResultsAsASCIITable
public void printMetricResultsAsASCIITable()Writes metric results as ASCII table to standard output. -
trackSimilarityResults
public void trackSimilarityResults()Tracks and prints the detailed pairwise similarities computed by every retriever. Enable this if you want to analyze this data later on. Be cautious since this can use a large amount of memory. -
getSimilarityResults
-