code: def var_explained(y_true, y_pred):
      
      y_true, y_pred = _mask_nan(y_true, y_pred)
      var_resid = np.var(y_true - y_pred)
      var_y_true = np.var(y_true)
      return 1 - var_resid / var_y_true
docs: Fraction of variance explained.