def mae(self):
    """Get MAE (Mean Absolute Error) for regression model evaluation results.

    Returns:
      the MAE float number.

    Raises:
      Exception if the CSV headers do not include 'target' or 'predicted', or BigQuery
      does not return 'target' or 'predicted' column, or if target or predicted is not
      number.
    """

    if self._input_csv_files:
      df = self._get_data_from_csv_files()
      if 'target' not in df or 'predicted' not in df:
        raise ValueError('Cannot find "target" or "predicted" column')

      df = df[['target', 'predicted']].apply(pd.to_numeric)
      mae = mean_absolute_error(df['target'], df['predicted'])
      return mae
    elif self._bigquery:
      query = bq.Query("""
        SELECT
          SUM(ABS(predicted-target)) / COUNT(*) as mae
        FROM
          %s""" % self._bigquery)
      df = self._get_data_from_bigquery([query])
      if df.empty:
        return None
      return df['mae'][0]
def mae ( self ) : if self . _input_csv_files : df = self . _get_data_from_csv_files ( ) if 'target' not in df or 'predicted' not in df : raise ValueError ( 'Cannot find "target" or "predicted" column' ) df = df [ [ 'target' , 'predicted' ] ] . apply ( pd . to_numeric ) mae = mean_absolute_error ( df [ 'target' ] , df [ 'predicted' ] ) return mae elif self . _bigquery : query = bq . Query ( """
        SELECT
          SUM(ABS(predicted-target)) / COUNT(*) as mae
        FROM
          %s""" % self . _bigquery ) df = self . _get_data_from_bigquery ( [ query ] ) if df . empty : return None return df [ 'mae' ] [ 0 ]
Get MAE (Mean Absolute Error) for regression model evaluation results.

    Returns:
      the MAE float number.

    Raises:
      Exception if the CSV headers do not include 'target' or 'predicted', or BigQuery
      does not return 'target' or 'predicted' column, or if target or predicted is not
      number.