Linear regression is the most basic ML algorithm. Building your own from scratch gives an idea of the math behind it and gets you going in ML! Importing all the libraries: We will be using NumPy for setting up the data, model_selection for splitting the dataset into training and testing datasets, and padas for…