class_docstr: Calculates and returns regression results from model outputs.
class_docstr_tok: ["Calculates","and","returns","regression","results","from","model","outputs","."]
code: def run(  # pytype: disable=signature-mismatch  # overriding-parameter-type-checks
      self,
      inputs: list[JsonDict],
      model: lit_model.Model,
      dataset: lit_dataset.IndexedDataset,
      model_outputs: Optional[list[JsonDict]] = None,
      config: Optional[JsonDict] = None,
  ):
      # Find the prediction field key in the model output to use for calculations.
      output_spec = model.output_spec()
      supported_keys = self._find_supported_pred_keys(output_spec)
  
      results: list[dict[str, dtypes.RegressionResult]] = []
  
      # Run prediction if needed:
      if model_outputs is None:
          model_outputs = list(model.predict(inputs))
  
      for i, inp in enumerate(inputs):
          input_result: dict[str, dtypes.RegressionResult] = {}
          for key in supported_keys:
              field_spec = cast(types.RegressionScore, output_spec[key])
              score = model_outputs[i][key]
              error = None
              sq_error = None
              # If there is ground truth information, calculate error and squared
              # error.
              if field_spec.parent and field_spec.parent in inp:
                  ground_truth = inp[field_spec.parent]
                  error = score - ground_truth
                  sq_error = error * error
  
              result = dtypes.RegressionResult(score, error, sq_error)
              input_result[key] = result
          results.append(input_result)
      return results
  
file_path: lit/lit_nlp/components/regression_results.py
imports: from typing import cast, Optional
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import dtypes
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import utils
label_desc: Use image node_id 1 for calling the RegressionInterpreter obj's underlying member method code with example usage: obj.run(inputs, model, dataset, model_outputs, config) and returns: results