pyabsa.utils.ensemble_prediction.ensemble_prediction
Module Contents
Classes
- class pyabsa.utils.ensemble_prediction.ensemble_prediction.VoteEnsemblePredictor(predictors: [List, dict], weights: [List, dict] = None, numeric_agg='average', str_agg='max_vote')[source]
- __ensemble(result: dict)[source]
Aggregate prediction results by calling the appropriate aggregation method.
- Parameters:
result – a dictionary containing the prediction results
- Returns:
the aggregated prediction result
- __dict_aggregate(result: dict)[source]
Recursively aggregate a dictionary of prediction results.
- Parameters:
result – a dictionary containing the prediction results
- Returns:
the aggregated prediction result
- predict(text, ignore_error=False, print_result=False)[source]
Predicts on a single text and returns the ensemble result.
- Parameters:
text (str) – The text to perform prediction on
ignore_error (bool) – Whether to ignore any errors that occur during prediction, defaults to False
print_result (bool) – Whether to print the prediction result, defaults to False
- Returns:
The ensemble prediction result
- Return type:
dict
- batch_predict(texts, ignore_error=False, print_result=False)[source]
Predicts on a batch of texts using the ensemble of predictors. :param texts: a list of strings to predict on. :param ignore_error: boolean indicating whether to ignore errors or raise exceptions when prediction fails. :param print_result: boolean indicating whether to print the raw results for each predictor. :return: a list of dictionaries, each dictionary containing the aggregated results of the corresponding text in the input list.