



import numpy as np
import requests





def 						a__     (						):
			__lowerCamelCase  							=      requests.get(
			    '''https://raw.githubusercontent.com/yashLadha/The_Math_of_Intelligence/'''
			    '''master/Week1/ADRvsRating.csv'''							)
			__lowerCamelCase  							=      response.text.splitlines()
			__lowerCamelCase  							=      []
			for item in lines:
						__lowerCamelCase  							=      item.split(''','''							)
						data.append(_UpperCamelCase							)
			data.pop(0							)  # This is for removing the labels from the list
			__lowerCamelCase  							=      np.matrix(_UpperCamelCase							)
			return dataset





def 						a__     (						_UpperCamelCase     :	List[Any]	,_UpperCamelCase     :	Dict	,_UpperCamelCase     :	Any	,_UpperCamelCase     :	List[Any]	,_UpperCamelCase     :	Any							):
			__lowerCamelCase  							=      len_data

			__lowerCamelCase  							=      np.dot(_UpperCamelCase	,data_x.transpose()							)
			prod -= data_y.transpose()
			__lowerCamelCase  							=      np.dot(_UpperCamelCase	,_UpperCamelCase							)
			__lowerCamelCase  							=      theta - (alpha / n) * sum_grad
			return theta





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





def 						a__     (						_UpperCamelCase     :	List[str]	,_UpperCamelCase     :	Optional[Any]							):
			__lowerCamelCase  							=      10_00_00
			__lowerCamelCase  							=      0.0_001_550

			__lowerCamelCase  							=      data_x.shape[1]
			__lowerCamelCase  							=      data_x.shape[0] - 1

			__lowerCamelCase  							=      np.zeros((1, no_features)							)

			for i in range(0	,_UpperCamelCase							):
						__lowerCamelCase  							=      run_steep_gradient_descent(_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase							)
						__lowerCamelCase  							=      sum_of_square_error(_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase							)
						print(F"""At Iteration {i + 1} - Error is {error:.5f}"""							)

			return theta





def 						a__     (						_UpperCamelCase     :	List[str]	,_UpperCamelCase     :	List[str]							):
			__lowerCamelCase  							=      sum(abs(y - predicted_y[i]							) for i, y in enumerate(_UpperCamelCase							)							)
			return total / len(_UpperCamelCase							)





def 						a__     (						):
			__lowerCamelCase  							=      collect_dataset()

			__lowerCamelCase  							=      data.shape[0]
			__lowerCamelCase  							=      np.c_[np.ones(_UpperCamelCase							), data[:, :-1]].astype(_UpperCamelCase							)
			__lowerCamelCase  							=      data[:, -1].astype(_UpperCamelCase							)

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


if __name__ == "__main__":
		main()











def 						a__     (						_UpperCamelCase     :	int							):
   if not isinstance(_UpperCamelCase	,_UpperCamelCase							):
      __lowerCamelCase  							=      (
          '''operation can not be conducted on a object of type '''
          F"""{type(_UpperCamelCase							).__name__}"""
      )
      raise TypeError(_UpperCamelCase							)
   __lowerCamelCase  							=      ''''''
   for _ in range(0	,32							):
      bit_string += str(number % 2							)
      __lowerCamelCase  							=      number >> 1
   return bit_string





def 						a__     (						_UpperCamelCase     :	int							):
   if number < 0:
      raise ValueError('''the value of input must be positive'''							)
   elif isinstance(_UpperCamelCase	,_UpperCamelCase							):
      raise TypeError('''Input value must be a \'int\' type'''							)
   elif isinstance(_UpperCamelCase	,_UpperCamelCase							):
      raise TypeError('''\'<\' not supported between instances of \'str\' and \'int\''''							)
   __lowerCamelCase  							=      0
   # iterator over [1 to 32],since we are dealing with 32 bit integer
   for _ in range(1	,33							):
      # left shift the bits by unity
      __lowerCamelCase  							=      result << 1
      # get the end bit
      __lowerCamelCase  							=      number % 2
      # right shift the bits by unity
      __lowerCamelCase  							=      number >> 1
      # add that bit to our ans
      __lowerCamelCase  							=      result | end_bit
   return get_reverse_bit_string(_UpperCamelCase							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()






