




'''simple docstring'''







import numpy as np
import requests



def 					lowerCamelCase__							(			):
     snake_case :			Union[str, Any]					   = requests.get(
         """https://raw.githubusercontent.com/yashLadha/The_Math_of_Intelligence/"""
         """master/Week1/ADRvsRating.csv"""							)
     snake_case :			Dict					   = response.text.splitlines()
     snake_case :			Union[str, Any]					   = []
     for item in lines:
          snake_case :			int					   = item.split(""","""							)
          data.append(__lowercase							)
     data.pop(0							)  # This is for removing the labels from the list
     snake_case :			Optional[int]					   = np.matrix(__lowercase							)
     return dataset



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase							):
     snake_case :			Any					   = len_data

     snake_case :			int					   = np.dot(__lowercase    ,      data_x.transpose()							)
     prod -= data_y.transpose()
     snake_case :			Any					   = np.dot(__lowercase    ,      __lowercase							)
     snake_case :			int					   = theta - (alpha / n) * sum_grad
     return theta



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase							):
     snake_case :			Tuple					   = np.dot(__lowercase    ,      data_x.transpose()							)
     prod -= data_y.transpose()
     snake_case :			int					   = np.sum(np.square(__lowercase							)							)
     snake_case :			List[Any]					   = sum_elem / (2 * len_data)
     return error



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase							):
     snake_case :			int					   = 100_000
     snake_case :			int					   = 0.000_1550

     snake_case :			List[Any]					   = data_x.shape[1]
     snake_case :			Any					   = data_x.shape[0] - 1

     snake_case :			Any					   = np.zeros((1, no_features)							)

     for i in range(0    ,      __lowercase							):
          snake_case :			Optional[int]					   = run_steep_gradient_descent(__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase							)
          snake_case :			Dict					   = sum_of_square_error(__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase							)
          print(F'''At Iteration {i + 1} - Error is {error:.5f}'''							)

     return theta



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase							):
     snake_case :			List[Any]					   = sum(abs(y - predicted_y[i]							) for i, y in enumerate(__lowercase							)							)
     return total / len(__lowercase							)



def 					lowerCamelCase__							(			):
     snake_case :			Optional[int]					   = collect_dataset()

     snake_case :			List[Any]					   = data.shape[0]
     snake_case :			int					   = np.c_[np.ones(__lowercase							), data[:, :-1]].astype(__lowercase							)
     snake_case :			Optional[Any]					   = data[:, -1].astype(__lowercase							)

     snake_case :			List[Any]					   = run_linear_regression(__lowercase    ,      __lowercase							)
     snake_case :			Optional[Any]					   = theta.shape[1]
     print("""Resultant Feature vector : """							)
     for i in range(0    ,      __lowercase							):
          print(F'''{theta[0, i]:.5f}'''							)


if __name__ == "__main__":
      main()









'''simple docstring'''







def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 9 / 5) + 32    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round(float(__lowercase							) + 273.15    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 9 / 5) + 491.67    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) - 32) * 5 / 9    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round(((float(__lowercase							) - 32) * 5 / 9) + 273.15    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round(float(__lowercase							) + 459.67    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round(float(__lowercase							) - 273.15    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round(((float(__lowercase							) - 273.15) * 9 / 5) + 32    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 9 / 5)    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) - 491.67) * 5 / 9    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round(float(__lowercase							) - 459.67    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 5 / 9)    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 1.25 + 273.15)    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 2.25 + 32)    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 1.25)    ,      __lowercase							)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase = 2							):
     return round((float(__lowercase							) * 2.25 + 32 + 459.67)    ,      __lowercase							)


if __name__ == "__main__":
      import doctest

      doctest.testmod()



