code: def matthews_corrcoef(y_true, y_pred, sample_weight=None):
      """Compute the Matthews correlation coefficient (MCC) for binary classes
  
      The Matthews correlation coefficient is used in machine learning as a
      measure of the quality of binary (two-class) classifications. It takes into
      account true and false positives and negatives and is generally regarded as
      a balanced measure which can be used even if the classes are of very
      different sizes. The MCC is in essence a correlation coefficient value
      between -1 and +1. A coefficient of +1 represents a perfect prediction, 0
      an average random prediction and -1 an inverse prediction.  The statistic
      is also known as the phi coefficient. [source: Wikipedia]
  
      Only in the binary case does this relate to information about true and
      false positives and negatives. See references below.
  
      Read more in the :ref:`User Guide <matthews_corrcoef>`.
  
      Parameters
      ----------
      y_true : array, shape = [n_samples]
          Ground truth (correct) target values.
  
      y_pred : array, shape = [n_samples]
          Estimated targets as returned by a classifier.
  
      sample_weight : array-like of shape = [n_samples], default None
          Sample weights.
  
      Returns
      -------
      mcc : float
          The Matthews correlation coefficient (+1 represents a perfect
          prediction, 0 an average random prediction and -1 and inverse
          prediction).
  
      References
      ----------
      .. [1] `Baldi, Brunak, Chauvin, Andersen and Nielsen, (2000). Assessing the
         accuracy of prediction algorithms for classification: an overview
         <http://dx.doi.org/10.1093/bioinformatics/16.5.412>`_
  
      .. [2] `Wikipedia entry for the Matthews Correlation Coefficient
         <https://en.wikipedia.org/wiki/Matthews_correlation_coefficient>`_
  
      Examples
      --------
      >>> from sklearn.metrics import matthews_corrcoef
      >>> y_true = [+1, +1, +1, -1]
      >>> y_pred = [+1, -1, +1, +1]
      >>> matthews_corrcoef(y_true, y_pred)  # doctest: +ELLIPSIS
      -0.33...
  
      """
      y_type, y_true, y_pred = _check_targets(y_true, y_pred)
  
      if y_type != "binary":
          raise ValueError("%s is not supported" % y_type)
  
      lb = LabelEncoder()
      lb.fit(np.hstack([y_true, y_pred]))
      y_true = lb.transform(y_true)
      y_pred = lb.transform(y_pred)
      mean_yt = np.average(y_true, weights=sample_weight)
      mean_yp = np.average(y_pred, weights=sample_weight)
  
      y_true_u_cent = y_true - mean_yt
      y_pred_u_cent = y_pred - mean_yp
  
      cov_ytyp = np.average(
          y_true_u_cent * y_pred_u_cent, weights=sample_weight
      )
      var_yt = np.average(y_true_u_cent**2, weights=sample_weight)
      var_yp = np.average(y_pred_u_cent**2, weights=sample_weight)
  
      mcc = cov_ytyp / np.sqrt(var_yt * var_yp)
  
      if np.isnan(mcc):
          return 0.0
      else:
          return mcc
  
imports: from __future__ import division
  import warnings
  import numpy
  from scipy.sparse import coo_matrix
  from scipy.sparse import csr_matrix
  from ..preprocessing import LabelBinarizer, label_binarize
  from ..preprocessing import LabelEncoder
  from ..utils import assert_all_finite
  from ..utils import check_array
  from ..utils import check_consistent_length
  from ..utils import column_or_1d
  from ..utils.multiclass import unique_labels
  from ..utils.multiclass import type_of_target
  from ..utils.validation import _num_samples
  from ..utils.sparsefuncs import count_nonzero
  from ..utils.fixes import bincount
  from ..exceptions import UndefinedMetricWarning
label_desc: Use image node_id 7 for calling a global function with example usage: matthews_corrcoef(y_true, y_pred, sample_weight) and returns: int, mcc