simpletransformers/seq2seq/seq2seq_model.py
def eval_model(self, eval_data, output_dir=None, verbose=True, silent=False, **kwargs):
        """
        Evaluates the model on eval_data. Saves results to output_dir.

        Args:
            eval_data: Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.
                        - `input_text`: The input text sequence.
                        - `target_text`: The target text sequence.
            output_dir: The directory where model files will be saved. If not given, self.args.output_dir will be used.
            verbose: If verbose, results will be printed to the console on completion of evaluation.
            silent: If silent, tqdm progress bars will be hidden.
            **kwargs: Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).
                        A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs
                        will be lists of strings. Note that this will slow down evaluation significantly as the predicted sequences need to be generated.
        Returns:
            results: Dictionary containing evaluation results.
        """  # noqa: ignore flake8"

        if not output_dir:
            output_dir = self.args.output_dir

        self._move_model_to_device()

        eval_dataset = self.load_and_cache_examples(eval_data, evaluate=True, verbose=verbose, silent=silent)
        os.makedirs(output_dir, exist_ok=True)

        result = self.evaluate(eval_dataset, output_dir, verbose=verbose, silent=silent, **kwargs)
        self.results.update(result)

        if self.args.evaluate_generated_text:
            # to_predict = eval_data["input_text"].tolist()
            preds = self.predict(eval_data, output_dir='eval/')


            result = self.compute_metrics(eval_data["target_text"].tolist(), preds, **kwargs)
            self.results.update(result)

        if verbose:
            logger.info(self.results)

        return self.results

        Evaluates the model on eval_data. Saves results to output_dir.

        Args:
            eval_data: Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.
                        - `input_text`: The input text sequence.
                        - `target_text`: The target text sequence.
            output_dir: The directory where model files will be saved. If not given, self.args.output_dir will be used.
            verbose: If verbose, results will be printed to the console on completion of evaluation.
            silent: If silent, tqdm progress bars will be hidden.
            **kwargs: Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).
                        A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs
                        will be lists of strings. Note that this will slow down evaluation significantly as the predicted sequences need to be generated.
        Returns:
            results: Dictionary containing evaluation results.
        
Evaluates the model on eval_data. Saves results to output_dir.
Evaluates the model on eval_data . Saves results to output_dir .
def eval_model(self, eval_data, output_dir=None, verbose=True, silent=False, **kwargs):
        if not output_dir:
            output_dir = self.args.output_dir
        self._move_model_to_device()
        eval_dataset = self.load_and_cache_examples(eval_data, evaluate=True, verbose=verbose, silent=silent)
        os.makedirs(output_dir, exist_ok=True)
        result = self.evaluate(eval_dataset, output_dir, verbose=verbose, silent=silent, **kwargs)
        self.results.update(result)
        if self.args.evaluate_generated_text:
            preds = self.predict(eval_data, output_dir='eval/')
            result = self.compute_metrics(eval_data["target_text"].tolist(), preds, **kwargs)
            self.results.update(result)
        if verbose:
            logger.info(self.results)
        return self.results
def eval_model ( self , eval_data , output_dir = None , verbose = True , silent = False , ** kwargs ) : if not output_dir : output_dir = self . args . output_dir self . _move_model_to_device ( ) eval_dataset = self . load_and_cache_examples ( eval_data , evaluate = True , verbose = verbose , silent = silent ) os . makedirs ( output_dir , exist_ok = True ) result = self . evaluate ( eval_dataset , output_dir , verbose = verbose , silent = silent , ** kwargs ) self . results . update ( result ) if self . args . evaluate_generated_text : preds = self . predict ( eval_data , output_dir = 'eval/' ) result = self . compute_metrics ( eval_data [ "target_text" ] . tolist ( ) , preds , ** kwargs ) self . results . update ( result ) if verbose : logger . info ( self . results ) return self . results
Evaluates the model on eval_data.
Evaluates the model on eval_data .
"""
        Evaluates the model on eval_data. Saves results to output_dir.

        Args:
            eval_data: Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.
                        - `input_text`: The input text sequence.
                        - `target_text`: The target text sequence.
            output_dir: The directory where model files will be saved. If not given, self.args.output_dir will be used.
            verbose: If verbose, results will be printed to the console on completion of evaluation.
            silent: If silent, tqdm progress bars will be hidden.
            **kwargs: Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).
                        A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs
                        will be lists of strings. Note that this will slow down evaluation significantly as the predicted sequences need to be generated.
        Returns:
            results: Dictionary containing evaluation results.
        """ # noqa: ignore flake8" # to_predict = eval_data["input_text"].tolist()
Dictionary containing evaluation results.
Dictionary containing evaluation results .
results
self
eval_data
Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.
`input_text`: The input text sequence.
`target_text`: The target text sequence.
Pandas DataFrame containing the 2 columns - ` input_text ` ` target_text ` . ` input_text ` : The input text sequence . ` target_text ` : The target text sequence .
output_dir
The directory where model files will be saved. If not given, self.args.output_dir will be used.
The directory where model files will be saved . If not given self . args . output_dir will be used .
verbose
If verbose, results will be printed to the console on completion of evaluation.
If verbose results will be printed to the console on completion of evaluation .
silent
If silent, tqdm progress bars will be hidden.
If silent tqdm progress bars will be hidden .
**kwargs
Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).
A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs
will be lists of strings. Note that this will slow down evaluation significantly as the predicted sequences need to be generated.
Additional metrics that should be used . Pass in the metrics as keyword arguments ( name of metric : function to use ) . A metric function should take in two parameters . The first parameter will be the true labels and the second parameter will be the predictions . Both inputs will be lists of strings . Note that this will slow down evaluation significantly as the predicted sequences need to be generated .