CFP last date
20 May 2024
Reseach Article

Implementation of Linear Regression using Least Squares and Gradient Descent in Python

by Ahmad Farhan AlShammari
International Journal of Computer Applications
Foundation of Computer Science (FCS), NY, USA
Volume 186 - Number 9
Year of Publication: 2024
Authors: Ahmad Farhan AlShammari
10.5120/ijca2024923446

Ahmad Farhan AlShammari . Implementation of Linear Regression using Least Squares and Gradient Descent in Python. International Journal of Computer Applications. 186, 9 ( Feb 2024), 52-57. DOI=10.5120/ijca2024923446

@article{ 10.5120/ijca2024923446,
author = { Ahmad Farhan AlShammari },
title = { Implementation of Linear Regression using Least Squares and Gradient Descent in Python },
journal = { International Journal of Computer Applications },
issue_date = { Feb 2024 },
volume = { 186 },
number = { 9 },
month = { Feb },
year = { 2024 },
issn = { 0975-8887 },
pages = { 52-57 },
numpages = {9},
url = { https://ijcaonline.org/archives/volume186/number9/implementation-of-linear-regression-using-least-squares-and-gradient-descent-in-python/ },
doi = { 10.5120/ijca2024923446 },
publisher = {Foundation of Computer Science (FCS), NY, USA},
address = {New York, USA}
}
%0 Journal Article
%1 2024-02-29T03:28:39+05:30
%A Ahmad Farhan AlShammari
%T Implementation of Linear Regression using Least Squares and Gradient Descent in Python
%J International Journal of Computer Applications
%@ 0975-8887
%V 186
%N 9
%P 52-57
%D 2024
%I Foundation of Computer Science (FCS), NY, USA
Abstract

The goal of this research is to develop a linear regression program using least squares and gradient descent in Python. Linear regression helps to find the line that best fits to the data points. The linear regression model is based on a linear polynomial of slope (m) and intercept (c). Least squares is used to minimize the error between the observed and predicted points. Gradient descent is used to find the optimal solution that provides the minimum value of error function. The basic steps of linear regression using least squares and gradient descent are explained: preparing observed points, initializing slope and intercept, computing predicted points, computing partial derivatives, updating slope and intercept, computing error function, making equation of line, and plotting predicted line. The developed program was tested on an experimental dataset from Kaggle. The program successfully performed the basic steps of linear regression and provided the required results.

References
  1. Sammut, C., & Webb, G. I. (2011). "Encyclopedia of Machine Learning". Springer Science & Business Media.
  2. Jung, A. (2022). "Machine Learning: The Basics". Singapore: Springer.
  3. Kubat, M. (2021). "An Introduction to Machine Learning". Cham, Switzerland: Springer International Publishing.
  4. Dey, A. (2016). "Machine Learning Algorithms: A Review". International Journal of Computer Science and Information Technologies, 7 (3), 1174-1179.
  5. Jordan, M. I., & Mitchell, T. M. (2015). "Machine Learning: Trends, Perspectives, and Prospects". Science, 349 (6245), 255-260.
  6. Forsyth, D. (2019). "Applied Machine Learning". Cham: Springer International Publishing.
  7. Chopra, D., & Khurana, R. (2023). "Introduction to Machine Learning with Python". Bentham Science Publishers.
  8. Sarker, I. H. (2021). "Machine Learning: Algorithms, Real-world Applications and Research Directions". SN Computer Science, 2(3), 160.
  9. Das, S., Dey, A., Pal, A., & Roy, N. (2015). "Applications of Artificial Intelligence in Machine Learning: Review and Prospect". International Journal of Computer Applications, 115(9), 31-41.
  10. Dhall, D., Kaur, R., & Juneja, M. (2020). "Machine Learning: A Review of the Algorithms and its Applications". Proceedings of ICRIC 2019: Recent Innovations in Computing, 47-63.
  11. Raschka, S. (2015). "Python Machine Learning". Packt Publishing.
  12. Müller, A. C., & Guido, S. (2016). "Introduction to Machine Learning with Python: A Guide for Data Scientists". O'Reilly Media.
  13. Swamynathan, M. (2019). "Mastering Machine Learning with Python in Six Steps: A Practical Implementation Guide to Predictive Data Analytics using Python". Apress.
  14. Brandt, S. (2014). "Data Analysis: Statistical and Computational Methods for Scientists and Engineers". Springer.
  15. VanderPlas, J. (2017). "Python Data Science Handbook: Essential Tools for Working with Data". O'Reilly Media.
  16. Atkinson, K. (1989). "An Introduction to Numerical Analysis". John Wiley & Sons.
  17. Chapra, S. C. (2010). "Numerical Methods for Engineers". McGraw-Hill.
  18. Gray, J.B. (2002). "Introduction to Linear Regression Analysis". Technometrics, 44, 191-192.
  19. Groß, J. (2003). "Linear Regression". Springer Science & Business Media.
  20. Olive, D. J. (2017). "Linear Regression". Berlin: Springer International Publishing.
  21. Yan, X., & Su, X. (2009). "Linear Regression Analysis: Theory and Computing". World Scientific.
  22. Su, X., Yan, X., & Tsai, C. L. (2012). "Linear Regression". Wiley Interdisciplinary Reviews: Computational Statistics, 4(3), 275-294.
  23. Montgomery, D.C., Peck, E.A., Vining G. G. (20012). "Introduction to Linear Regression Analysis". Wiley Series in Probability and Statistics: John Wiley & Sons.
  24. Kutner, N., Nachtsheim, C., & Neter, J. (2004). "Applied Linear Regression Models". McGraw-Hill/Irwin Series: Operations and Decision Sciences.
  25. Leemis, L.M. (1991). "Applied Linear Regression Models". Journal of Quality Technology, 23, 76-77.
  26. Seber, G. A., & Lee, A. J. (2003). "Linear Regression Analysis". John Wiley & Sons.
  27. Neter, J., Wasserman, W., & Kutner, M. H. (1983). "Applied Linear Regression Models". Irwin.
  28. Weisberg, S. (2005). "Applied Linear Regression". John Wiley & Sons.
  29. Malik, M.B. (2005). "Applied Linear Regression". Technometrics, 47, 371-372.
  30. Maulud, D., & Abdulazeez, A. M. (2020). "A Review on Linear Regression Comprehensive in Machine Learning". Journal of Applied Science and Technology Trends, 1(4), 140-147.
  31. Stigler, Stephen M. (1981). "Gauss and the Invention of Least Squares". The Annals of Statistics. 9 (3): 465–474.
  32. Python: https://www.python.org
  33. Numpy: https://www.numpy.org
  34. Pandas: https:// pandas.pydata.org
  35. Matplotlib: https://www. matplotlib.org
  36. NLTK: https://www.nltk.org
  37. SciPy: https://scipy.org
  38. SK Learn: https://scikit-learn.org
  39. Kaggle: https://www.kaggle.com
Index Terms

Computer Science
Information Sciences

Keywords

Artificial Intelligence Machine Learning Linear Regression Least Squares Mean Squared Error Gradient Descent Python Programming