"""simple docstring"""







from math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

_UpperCamelCase					      =  6378137.0
_UpperCamelCase					      =  6356752.314245
_UpperCamelCase					      =  6378137

def _a			(		_snake_case				,	_snake_case				,	_snake_case				,	_snake_case							):







      """simple docstring"""






      UpperCAmelCase          =	(AXIS_A - AXIS_B) / AXIS_A
      # Parametric latitudes
      # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
      UpperCAmelCase          =	atan((1 - flattening) * tan(radians(_snake_case							)							)							)
      UpperCAmelCase          =	atan((1 - flattening) * tan(radians(_snake_case							)							)							)

      # Compute central angle between two points
      # using haversine theta. sigma =  haversine_distance / equatorial radius
      UpperCAmelCase          =	haversine_distance(_snake_case				,	_snake_case				,	_snake_case				,	_snake_case							) / EQUATORIAL_RADIUS

      # Intermediate P and Q values
      UpperCAmelCase          =	(b_lata + b_lata) / 2
      UpperCAmelCase          =	(b_lata - b_lata) / 2

      # Intermediate X value
      # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
      UpperCAmelCase          =	(sin(_snake_case							) ** 2) * (cos(_snake_case							) ** 2)
      UpperCAmelCase          =	cos(sigma / 2							) ** 2
      UpperCAmelCase          =	(sigma - sin(_snake_case							)) * (x_numerator / x_demonimator)

      # Intermediate Y value
      # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
      UpperCAmelCase          =	(cos(_snake_case							) ** 2) * (sin(_snake_case							) ** 2)
      UpperCAmelCase          =	sin(sigma / 2							) ** 2
      UpperCAmelCase          =	(sigma + sin(_snake_case							)) * (y_numerator / y_denominator)

      return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
  import doctest

  doctest.testmod()











"""simple docstring"""







import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression

# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split

# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures

# Importing the dataset
_UpperCamelCase					      =  pd.read_csv(
    """https://s3.us-west-2.amazonaws.com/public.gamelab.fun/dataset/"""
    """position_salaries.csv"""
)
_UpperCamelCase					      =  dataset.iloc[:, 1:2].values
_UpperCamelCase					      =  dataset.iloc[:, 2].values


_UpperCamelCase      ,  _UpperCamelCase      ,  _UpperCamelCase      ,  _UpperCamelCase					      =  train_test_split(X, y, test_size=0.2, random_state=0)


_UpperCamelCase					      =  PolynomialFeatures(degree=4)
_UpperCamelCase					      =  poly_reg.fit_transform(X)
_UpperCamelCase					      =  LinearRegression()
pol_reg.fit(X_poly, y)

def _a			(		):







      """simple docstring"""






      plt.scatter(_snake_case				,	_snake_case				,	color="""red"""							)
      plt.plot(_snake_case				,	pol_reg.predict(poly_reg.fit_transform(_snake_case							)							)				,	color="""blue"""							)
      plt.title("""Truth or Bluff (Linear Regression)"""							)
      plt.xlabel("""Position level"""							)
      plt.ylabel("""Salary"""							)
      plt.show()


if __name__ == "__main__":
  viz_polymonial()

  # Predicting a new result with Polymonial Regression
  pol_reg.predict(poly_reg.fit_transform([[5.5]]))
  # output should be 132148.43750003



