code: def _weighted_pearson(y, y_pred, w):
      """Calculate the weighted Pearson correlation coefficient."""
      with np.errstate(divide="ignore", invalid="ignore"):
          y_pred_demean = y_pred - np.average(y_pred, weights=w)
          y_demean = y - np.average(y, weights=w)
          corr = (
              np.sum(w * y_pred_demean * y_demean) / np.sum(w)
          ) / np.sqrt(
              (
                  np.sum(w * y_pred_demean**2)
                  * np.sum(w * y_demean**2)
              )
              / (np.sum(w) ** 2)
          )
      if np.isfinite(corr):
          return np.abs(corr)
      return 0.0
  
file_path: gplearn/gplearn/fitness.py
imports: import numbers
  import numpy
  from joblib import wrap_non_picklable_objects
  from scipy.stats import rankdata
label_desc: Use image node_id 2 for calling a global function with example usage: _weighted_pearson(y, y_pred, w) and returns: int, np