





'''simple docstring'''






class  _A :

		def __init__(   self					:   str			)					->    List[Any]:


					"""simple docstring"""

					__snake_case					:      Optional[Any]							      =     0
					__snake_case					:      List[Any]							      =     0
					__snake_case					:      List[Any]							      =     {}

		def 	lowercase__     (   self					:   List[str]  ,      __magic_name__					:   List[Any]			)					->    Dict:


					"""simple docstring"""

					if vertex not in self.adjacency:
								__snake_case					:      List[str]							      =     {}
								self.num_vertices += 1

		def 	lowercase__     (   self					:   List[Any]  ,      __magic_name__					:   Optional[Any]  ,      __magic_name__					:   Optional[Any]  ,      __magic_name__					:   int			)					->    int:


					"""simple docstring"""

					self.add_vertex(__magic_name__			)
					self.add_vertex(__magic_name__			)

					if head == tail:
								return

					__snake_case					:      Tuple							      =     weight
					__snake_case					:      Optional[Any]							      =     weight

		def 	lowercase__     (   self					:   Optional[int]			)					->    Optional[Any]:


					"""simple docstring"""

					__snake_case					:      Any							      =     self.get_edges()
					for edge in edges:
								__snake_case      ,     __snake_case      ,     __snake_case					:      Union[str, Any]							      =     edge
								edges.remove((tail, head, weight)			)
					for i in range(len(__magic_name__			)			):
								__snake_case					:      Optional[int]							      =     list(edges[i]			)

					edges.sort(key=lambda __magic_name__			: e[2]			)
					for i in range(len(__magic_name__			) - 1			):
								if edges[i][2] >= edges[i + 1][2]:
											__snake_case					:      Optional[Any]							      =     edges[i][2] + 1
					for edge in edges:
								__snake_case      ,     __snake_case      ,     __snake_case					:      Union[str, Any]							      =     edge
								__snake_case					:      List[Any]							      =     weight
								__snake_case					:      Dict							      =     weight

		def __str__(   self					:   Optional[Any]			)					->    Optional[int]:


					"""simple docstring"""

					__snake_case					:      int							      =     """"""
					for tail in self.adjacency:
								for head in self.adjacency[tail]:
											__snake_case					:      Union[str, Any]							      =     self.adjacency[head][tail]
											string += f'''{head} -> {tail} == {weight}\n'''
					return string.rstrip("""\n"""			)

		def 	lowercase__     (   self					:   int			)					->    List[str]:


					"""simple docstring"""

					__snake_case					:      int							      =     []
					for tail in self.adjacency:
								for head in self.adjacency[tail]:
											output.append((tail, head, self.adjacency[head][tail])			)
					return output

		def 	lowercase__     (   self					:   Union[str, Any]			)					->    str:


					"""simple docstring"""

					return self.adjacency.keys()

		@staticmethod
		def 	lowercase__     (   __magic_name__					:   int=None  ,      __magic_name__					:   List[str]=None			)					->    Tuple:


					"""simple docstring"""

					__snake_case					:      Dict							      =     Graph()
					if vertices is None:
								__snake_case					:      Tuple							      =     []
					if edges is None:
								__snake_case					:      Optional[Any]							      =     []
					for vertex in vertices:
								g.add_vertex(__magic_name__			)
					for edge in edges:
								g.add_edge(*__magic_name__			)
					return g




		class  _A :

				def __init__(   self					:   int			)					->    Tuple:


							"""simple docstring"""

							__snake_case					:      Optional[int]							      =     {}
							__snake_case					:      Union[str, Any]							      =     {}

				def __len__(   self					:   Tuple			)					->    Optional[int]:


							"""simple docstring"""

							return len(self.parent			)

				def 	lowercase__     (   self					:   str  ,      __magic_name__					:   int			)					->    Optional[Any]:


							"""simple docstring"""

							if item in self.parent:
										return self.find(__magic_name__			)

							__snake_case					:      Any							      =     item
							__snake_case					:      str							      =     0
							return item

				def 	lowercase__     (   self					:   List[Any]  ,      __magic_name__					:   str			)					->    List[Any]:


							"""simple docstring"""

							if item not in self.parent:
										return self.make_set(__magic_name__			)
							if item != self.parent[item]:
										__snake_case					:      int							      =     self.find(self.parent[item]			)
							return self.parent[item]

				def 	lowercase__     (   self					:   List[str]  ,      __magic_name__					:   Dict  ,      __magic_name__					:   Optional[int]			)					->    List[str]:


							"""simple docstring"""

							__snake_case					:      List[str]							      =     self.find(__magic_name__			)
							__snake_case					:      List[str]							      =     self.find(__magic_name__			)

							if roota == roota:
										return roota

							if self.rank[roota] > self.rank[roota]:
										__snake_case					:      int							      =     roota
										return roota

							if self.rank[roota] < self.rank[roota]:
										__snake_case					:      Union[str, Any]							      =     roota
										return roota

							if self.rank[roota] == self.rank[roota]:
										self.rank[roota] += 1
										__snake_case					:      Union[str, Any]							      =     roota
										return roota
							return None





		@staticmethod
		def 	lowercase__     (   __magic_name__					:   int			)					->    Union[str, Any]:


					"""simple docstring"""

					__snake_case					:      Any							      =     graph.num_vertices

					__snake_case					:      Dict							      =     Graph.UnionFind()
					__snake_case					:      Dict							      =     []
					while num_components > 1:
								__snake_case					:      Optional[int]							      =     {}
								for vertex in graph.get_vertices():
											__snake_case					:      Union[str, Any]							      =     -1

								__snake_case					:      Optional[Any]							      =     graph.get_edges()
								for edge in edges:
											__snake_case      ,     __snake_case      ,     __snake_case					:      Union[str, Any]							      =     edge
											edges.remove((tail, head, weight)			)
								for edge in edges:
											__snake_case      ,     __snake_case      ,     __snake_case					:      Optional[Any]							      =     edge
											__snake_case					:      List[Any]							      =     union_find.find(__magic_name__			)
											__snake_case					:      Union[str, Any]							      =     union_find.find(__magic_name__			)
											if seta != seta:
														if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																	__snake_case					:      str							      =     [head, tail, weight]

														if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																	__snake_case					:      Optional[int]							      =     [head, tail, weight]
								for vertex in cheap_edge:
											if cheap_edge[vertex] != -1:
														__snake_case      ,     __snake_case      ,     __snake_case					:      Any							      =     cheap_edge[vertex]
														if union_find.find(__magic_name__			) != union_find.find(__magic_name__			):
																	union_find.union(__magic_name__  ,      __magic_name__			)
																	mst_edges.append(cheap_edge[vertex]			)
																	__snake_case					:      int							      =     num_components - 1
					__snake_case					:      Optional[int]							      =     Graph.build(edges=__magic_name__			)
					return mst









'''simple docstring'''






from sklearn.metrics import matthews_corrcoef

import datasets


__UpperCamelCase					    =	"\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true and false positives and negatives and is generally\nregarded as a balanced measure which can be used even if the classes are of\nvery different sizes. The MCC is in essence a correlation coefficient value\nbetween -1 and +1. A coefficient of +1 represents a perfect prediction, 0\nan average random prediction and -1 an inverse prediction.  The statistic\nis also known as the phi coefficient. [source: Wikipedia]\n"

__UpperCamelCase					    =	"\nArgs:\n    predictions (list of int): Predicted labels, as returned by a model.\n    references (list of int): Ground truth labels.\n    sample_weight (list of int, float, or bool): Sample weights. Defaults to `None`.\nReturns:\n    matthews_correlation (dict containing float): Matthews correlation.\nExamples:\n    Example 1, a basic example with only predictions and references as inputs:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3])\n        >>> print(round(results['matthews_correlation'], 2))\n        0.54\n\n    Example 2, the same example as above, but also including sample weights:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3],\n        ...                                     sample_weight=[0.5, 3, 1, 1, 1, 2])\n        >>> print(round(results['matthews_correlation'], 2))\n        0.1\n\n    Example 3, the same example as above, but with sample weights that cause a negative correlation:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3],\n        ...                                     sample_weight=[0.5, 1, 0, 0, 0, 1])\n        >>> print(round(results['matthews_correlation'], 2))\n        -0.25\n"

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




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION						,					_KWARGS_DESCRIPTION		)
class  _A (					datasets.Metric		):

		def 	lowercase__     (   self					:   Tuple			)					->    Dict:


					"""simple docstring"""

					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 	lowercase__     (   self					:   List[Any]  ,      __magic_name__					:   Tuple  ,      __magic_name__					:   List[Any]  ,      __magic_name__					:   Union[str, Any]=None			)					->    Optional[int]:


					"""simple docstring"""

					return {
					    "matthews_correlation": float(matthews_corrcoef(__magic_name__  ,      __magic_name__  ,      sample_weight=__magic_name__			)			),
					}


