





from sklearn.metrics import matthews_corrcoef

import datasets


_UpperCAmelCase							:			List[str]        =							"""
Compute the Matthews correlation coefficient (MCC)

The Matthews correlation coefficient is used in machine learning as a
measure of the quality of binary and multiclass 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]
"""

_UpperCAmelCase							:			Any        =							"""
Args:
    predictions (list of int): Predicted labels, as returned by a model.
    references (list of int): Ground truth labels.
    sample_weight (list of int, float, or bool): Sample weights. Defaults to `None`.
Returns:
    matthews_correlation (dict containing float): Matthews correlation.
Examples:
    Example 1, a basic example with only predictions and references as inputs:
        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")
        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],
        ...                                     predictions=[1, 2, 2, 0, 3, 3])
        >>> print(round(results['matthews_correlation'], 2))
        0.54

    Example 2, the same example as above, but also including sample weights:
        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")
        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],
        ...                                     predictions=[1, 2, 2, 0, 3, 3],
        ...                                     sample_weight=[0.5, 3, 1, 1, 1, 2])
        >>> print(round(results['matthews_correlation'], 2))
        0.1

    Example 3, the same example as above, but with sample weights that cause a negative correlation:
        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")
        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],
        ...                                     predictions=[1, 2, 2, 0, 3, 3],
        ...                                     sample_weight=[0.5, 1, 0, 0, 0, 1])
        >>> print(round(results['matthews_correlation'], 2))
        -0.25
"""

_UpperCAmelCase							:			Union[str, Any]        =							"""\
@article{scikit-learn,
  title={Scikit-learn: Machine Learning in {P}ython},
  author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.
         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.
         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and
         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},
  journal={Journal of Machine Learning Research},
  volume={12},
  pages={2825--2830},
  year={2011}
}
"""

@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION,    _KWARGS_DESCRIPTION     )
class   lowerCAmelCase				(   datasets.Metric     ):
 def 	A_      ( self    : str      )     ->      Optional[int]:
     return datasets.MetricInfo(
         description=_DESCRIPTION     ,	citation=_CITATION     ,	inputs_description=_KWARGS_DESCRIPTION     ,	features=datasets.Features(
             {
                 'predictions': datasets.Value('int32'      ),
                 'references': datasets.Value('int32'      ),
             }      )     ,	reference_urls=[
             'https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html'
         ]     ,	)







 def 	A_      ( self    : str     ,	UpperCAmelCase    : Optional[Any]     ,	UpperCAmelCase    : Optional[Any]     ,	UpperCAmelCase    : List[str]=None      )     ->      Any:
     return {
         "matthews_correlation": float(matthews_corrcoef(UpperCAmelCase     ,	UpperCAmelCase     ,	sample_weight=UpperCAmelCase      )      ),
     }












def 			SCREAMING_SNAKE_CASE (			_UpperCAmelCase					)     ->	str:
    lowerCamelCase__       : Dict   					=						''
    for ch in key:
        if ch == " " or ch not in key_no_dups and ch.isalpha():
            key_no_dups += ch
    return key_no_dups


def 			SCREAMING_SNAKE_CASE (			_UpperCAmelCase					)     ->	dict[str, str]:
    lowerCamelCase__       : List[str]   					=						[chr(i + 65					) for i in range(26					)]
    # Remove duplicate characters from key
    lowerCamelCase__       : Any   					=						remove_duplicates(key.upper()					)
    lowerCamelCase__       : List[Any]   					=						len(_UpperCAmelCase					)
    # First fill cipher with key characters
    lowerCamelCase__       : Optional[int]   					=						{alphabet[i]: char for i, char in enumerate(_UpperCAmelCase					)}
    # Then map remaining characters in alphabet to
    # the alphabet from the beginning
    for i in range(len(_UpperCAmelCase					)		,      26					):
        lowerCamelCase__       : Any   					=						alphabet[i - offset]
        # Ensure we are not mapping letters to letters previously mapped
        while char in key:
            offset -= 1
            lowerCamelCase__       : Union[str, Any]   					=						alphabet[i - offset]
        lowerCamelCase__       : int   					=						char
    return cipher_alphabet


def 			SCREAMING_SNAKE_CASE (			_UpperCAmelCase		,      _UpperCAmelCase					)     ->	str:
    return "".join(cipher_map.get(_UpperCAmelCase		,      _UpperCAmelCase					) for ch in message.upper()					)


def 			SCREAMING_SNAKE_CASE (			_UpperCAmelCase		,      _UpperCAmelCase					)     ->	str:
    lowerCamelCase__       : List[str]   					=						{v: k for k, v in cipher_map.items()}
    return "".join(rev_cipher_map.get(_UpperCAmelCase		,      _UpperCAmelCase					) for ch in message.upper()					)


def 			SCREAMING_SNAKE_CASE (			)     ->	None:
    lowerCamelCase__       : str   					=						input('Enter message to encode or decode: '					).strip()
    lowerCamelCase__       : Union[str, Any]   					=						input('Enter keyword: '					).strip()
    lowerCamelCase__       : Dict   					=						input('Encipher or decipher? E/D:'					).strip()[0].lower()
    try:
        lowerCamelCase__       : Dict   					=						{'e': encipher, 'd': decipher}[option]
    except KeyError:
        raise KeyError('invalid input option'					)
    lowerCamelCase__       : int   					=						create_cipher_map(_UpperCAmelCase					)
    print(func(_UpperCAmelCase		,      _UpperCAmelCase					)					)


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()





