def assert_train_error_is_below_threshold()

in sourcecode/scoring/mf_base_scorer.py [0:0]


  def assert_train_error_is_below_threshold(self, ratings, maxTrainError) -> None:
    """
    If we are running a non-test run (number of ratings is above threshold),
    assert that the final training error for the MF ranker is below the threshold.
    """
    testRun = (
      ratings[c.noteIdKey].nunique() < c.minNumNotesForProdData if ratings is not None else False
    )
    if not testRun:
      finalTrainError = self._mfRanker.get_final_train_error()
      if finalTrainError is None:
        raise ValueError("Final train error is None")
      else:
        if finalTrainError > maxTrainError:
          raise ValueError(f"Train error ({finalTrainError}) is above threshold ({maxTrainError})")