
'''simple docstring'''



from math import pi, sqrt, tan


def A (__lowerCamelCase :float						):
						if side_length < 0:
												raise ValueError("""surface_area_cube() only accepts non-negative values"""						)
						return 6 * side_length**2


def A (__lowerCamelCase :float					,      __lowerCamelCase :float					,      __lowerCamelCase :float						):
						if length < 0 or breadth < 0 or height < 0:
												raise ValueError("""surface_area_cuboid() only accepts non-negative values"""						)
						return 2 * ((length * breadth) + (breadth * height) + (length * height))


def A (__lowerCamelCase :float						):
						if radius < 0:
												raise ValueError("""surface_area_sphere() only accepts non-negative values"""						)
						return 4 * pi * radius**2


def A (__lowerCamelCase :float						):
						if radius < 0:
												raise ValueError("""surface_area_hemisphere() only accepts non-negative values"""						)
						return 3 * pi * radius**2


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if radius < 0 or height < 0:
												raise ValueError("""surface_area_cone() only accepts non-negative values"""						)
						return pi * radius * (radius + (height**2 + radius**2) ** 0.5)


def A (__lowerCamelCase :float					,      __lowerCamelCase :float					,      __lowerCamelCase :float						):
						if radius_a < 0 or radius_a < 0 or height < 0:
												raise ValueError(
												    """surface_area_conical_frustum() only accepts non-negative values"""						)
						_lowerCAmelCase    		=					(height**2 + (radius_a - radius_a) ** 2) ** 0.5
						return pi * ((slant_height * (radius_a + radius_a)) + radius_a**2 + radius_a**2)


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if radius < 0 or height < 0:
												raise ValueError("""surface_area_cylinder() only accepts non-negative values"""						)
						return 2 * pi * radius * (height + radius)


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if torus_radius < 0 or tube_radius < 0:
												raise ValueError("""surface_area_torus() only accepts non-negative values"""						)
						if torus_radius < tube_radius:
												raise ValueError(
												    """surface_area_torus() does not support spindle or self intersecting tori"""						)
						return 4 * pow(__lowerCamelCase					,      2						) * torus_radius * tube_radius


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if length < 0 or width < 0:
												raise ValueError("""area_rectangle() only accepts non-negative values"""						)
						return length * width


def A (__lowerCamelCase :float						):
						if side_length < 0:
												raise ValueError("""area_square() only accepts non-negative values"""						)
						return side_length**2


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if base < 0 or height < 0:
												raise ValueError("""area_triangle() only accepts non-negative values"""						)
						return (base * height) / 2


def A (__lowerCamelCase :float					,      __lowerCamelCase :float					,      __lowerCamelCase :float						):
						if sidea < 0 or sidea < 0 or sidea < 0:
												raise ValueError("""area_triangle_three_sides() only accepts non-negative values"""						)
						elif sidea + sidea < sidea or sidea + sidea < sidea or sidea + sidea < sidea:
												raise ValueError("""Given three sides do not form a triangle"""						)
						_lowerCAmelCase    		=					(sidea + sidea + sidea) / 2
						_lowerCAmelCase    		=					sqrt(
						    semi_perimeter
						    * (semi_perimeter - sidea)
						    * (semi_perimeter - sidea)
						    * (semi_perimeter - sidea)						)
						return area


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if base < 0 or height < 0:
												raise ValueError("""area_parallelogram() only accepts non-negative values"""						)
						return base * height


def A (__lowerCamelCase :float					,      __lowerCamelCase :float					,      __lowerCamelCase :float						):
						if basea < 0 or basea < 0 or height < 0:
												raise ValueError("""area_trapezium() only accepts non-negative values"""						)
						return 1 / 2 * (basea + basea) * height


def A (__lowerCamelCase :float						):
						if radius < 0:
												raise ValueError("""area_circle() only accepts non-negative values"""						)
						return pi * radius**2


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if radius_x < 0 or radius_y < 0:
												raise ValueError("""area_ellipse() only accepts non-negative values"""						)
						return pi * radius_x * radius_y


def A (__lowerCamelCase :float					,      __lowerCamelCase :float						):
						if diagonal_a < 0 or diagonal_a < 0:
												raise ValueError("""area_rhombus() only accepts non-negative values"""						)
						return 1 / 2 * diagonal_a * diagonal_a


def A (__lowerCamelCase :int					,      __lowerCamelCase :float						):
						if not isinstance(__lowerCamelCase					,      __lowerCamelCase						) or sides < 3:
												raise ValueError(
												    """area_reg_polygon() only accepts integers greater than or \
equal to three as number of sides"""						)
						elif length < 0:
												raise ValueError(
												    """area_reg_polygon() only accepts non-negative values as \
length of a side"""						)
						return (sides * length**2) / (4 * tan(pi / sides						))
						return (sides * length**2) / (4 * tan(pi / sides						))


if __name__ == "__main__":
						import doctest

						doctest.testmod(verbose=True)  # verbose so we can see methods missing tests

						print("""[DEMO] Areas of various geometric shapes: \n""")
						print(F"""Rectangle: {area_rectangle(10, 20) = }""")
						print(F"""Square: {area_square(10) = }""")
						print(F"""Triangle: {area_triangle(10, 10) = }""")
						print(F"""Triangle: {area_triangle_three_sides(5, 12, 13) = }""")
						print(F"""Parallelogram: {area_parallelogram(10, 20) = }""")
						print(F"""Rhombus: {area_rhombus(10, 20) = }""")
						print(F"""Trapezium: {area_trapezium(10, 20, 30) = }""")
						print(F"""Circle: {area_circle(20) = }""")
						print(F"""Ellipse: {area_ellipse(10, 20) = }""")
						print("""\nSurface Areas of various geometric shapes: \n""")
						print(F"""Cube: {surface_area_cube(20) = }""")
						print(F"""Cuboid: {surface_area_cuboid(10, 20, 30) = }""")
						print(F"""Sphere: {surface_area_sphere(20) = }""")
						print(F"""Hemisphere: {surface_area_hemisphere(20) = }""")
						print(F"""Cone: {surface_area_cone(10, 20) = }""")
						print(F"""Conical Frustum: {surface_area_conical_frustum(10, 20, 30) = }""")
						print(F"""Cylinder: {surface_area_cylinder(10, 20) = }""")
						print(F"""Torus: {surface_area_torus(20, 10) = }""")
						print(F"""Equilateral Triangle: {area_reg_polygon(3, 10) = }""")
						print(F"""Square: {area_reg_polygon(4, 10) = }""")
						print(F"""Reqular Pentagon: {area_reg_polygon(5, 10) = }""")


'''simple docstring'''



from sklearn.metrics import mean_squared_error

import datasets


_lowercase          =						"""\
@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}
}
"""

_lowercase          =						"""\
Mean Squared Error(MSE) is the average of the square of difference between the predicted
and actual values.
"""


_lowercase          =						"""
Args:
    predictions: array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.
    references: array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.
    sample_weight: array-like of shape (n_samples,), default=None
        Sample weights.
    multioutput: {\"raw_values\", \"uniform_average\"} or array-like of shape (n_outputs,), default=\"uniform_average\"
        Defines aggregating of multiple output values. Array-like value defines weights used to average errors.

        \"raw_values\" : Returns a full set of errors in case of multioutput input.

        \"uniform_average\" : Errors of all outputs are averaged with uniform weight.

    squared : bool, default=True
        If True returns MSE value, if False returns RMSE (Root Mean Squared Error) value.

Returns:
    mse : mean squared error.
Examples:

    >>> mse_metric = datasets.load_metric(\"mse\")
    >>> predictions = [2.5, 0.0, 2, 8]
    >>> references = [3, -0.5, 2, 7]
    >>> results = mse_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'mse': 0.375}
    >>> rmse_result = mse_metric.compute(predictions=predictions, references=references, squared=False)
    >>> print(rmse_result)
    {'mse': 0.6123724356957945}

    If you're using multi-dimensional lists, then set the config as follows :

    >>> mse_metric = datasets.load_metric(\"mse\", \"multilist\")
    >>> predictions = [[0.5, 1], [-1, 1], [7, -6]]
    >>> references = [[0, 2], [-1, 2], [8, -5]]
    >>> results = mse_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'mse': 0.7083333333333334}
    >>> results = mse_metric.compute(predictions=predictions, references=references, multioutput='raw_values')
    >>> print(results) # doctest: +NORMALIZE_WHITESPACE
    {'mse': array([0.41666667, 1. ])}
"""




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






						'''simple docstring'''






						def    _lowercase      (   self ):

												"""simple docstring"""



												return datasets.MetricInfo(
												    description=_DESCRIPTION       ,  citation=_CITATION       ,  inputs_description=_KWARGS_DESCRIPTION       ,  features=datasets.Features(self._get_feature_types() )       ,  reference_urls=[
												        """https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html"""
												    ]       ,  )




						def    _lowercase      (   self ):

												"""simple docstring"""



												if self.config_name == "multilist":
																		return {
																		    "predictions": datasets.Sequence(datasets.Value("""float""" ) ),
																		    "references": datasets.Sequence(datasets.Value("""float""" ) ),
																		}
												else:
																		return {
																		    "predictions": datasets.Value("""float""" ),
																		    "references": datasets.Value("""float""" ),
																		}




						def    _lowercase      (   self       ,  _lowercase       ,  _lowercase       ,  _lowercase=None       ,  _lowercase="uniform_average"       ,  _lowercase=True ):

												"""simple docstring"""



												_lowerCAmelCase    		=					mean_squared_error(
												    _lowercase       ,  _lowercase       ,  sample_weight=_lowercase       ,  multioutput=_lowercase       ,  squared=_lowercase )

												return {"mse": mse}
