Stock Price Prediction Website Using Linear Regression - A Machine Learning Algorithm

. The most valuable indicator of a company's success is its stock price, which can rise in tandem with the price of a single share. For that reason, businesses advertise their stocks to their customers in an effort to get them to buy them. The volatility of stock prices makes it difficult for clients or stockholding companies to forecast the future value of a single stock. Therefore, stock market forecasting has emerged as the most well-liked topic in the corporate sector, and hence solving this problem has become so important for the betterment of the investors and buyers as many a times they have to face loss in their investment and this problem can be solve by various Machine learning algorithms .To solve this problem we are developing one stock price prediction website using Python and Linear Regression which is one of the best Machine Learning statistical method for predictive analysis. We are using historical Data for the prediction. Finding a method to use linear regression models to obtain more precise values is the major goal. To acquire more precise results from the linear regression models, it is possible to change the dataset that will be used to train the models. The purpose of this paper is to demonstrate that linear regression is the most appropriate and effective method for forecasting stock market analysis.


1.Introduction
The stock market is a regulated marketplace where investors can buy or sell stocks publicly or privately. Companies often turn to the stock market to raise capital for business expansion, making it a popular investment option for investors. To make informed investment decisions, many investors rely on predictions based on past market trends. In recent years, the stock market has changed significantly, making it crucial to anticipate its future value or price given how dynamic the market is. Predictive analysis is frequently carried out using linear regression, a mathematical technique and supervised machine learning method. The linear regression model, which generates linear correlations between independent and dependent variables, is largely consistent with the continuous/real values of mathematical variables. The algorithm makes the predictions in accordance with the guidance provided in the training data set after first training with it. The other tools and technology used in the given website are html and CSS which are used for frontend. The library named scikit learn is used as it has all machine learning algorithms and functions inbuilt in it. The framework Django which comes under Python is used at the backend to access web services and resources which is inbuilt in python programming language. To fetch the data for the website which should be reliable and accurate, Yahoo finance site is used and connecting it with API. So the prediction of stocks of all the companies which are there in yahoo finance can be done through our website.
Here are summaries of 10 research papers on stock price prediction using linear regression algorithm as a machine learning approach: [1]  This website can predict the stock prize for next 1 day to the next 360 days through graphical representation. Predicting stock market behavior has been a difficult task for researchers, but with the help of machine learning, it has become possible to accurately forecast stock prices.

2.Methodology
In the given project, stock prices are predicted using Linear regression algorithm in machine learning and data implementation using python tools and libraries like Scikit-learn, Numpy are done.

Linear regression
A linear regression contains the labelled data (supervised learning) which generates the relationship between independent and dependent variables using simple mathematical equations and thereby calculate the best fit line or line of minimum reluctance. This line can be used to calculate stock predictions using graph or curve analysis.
Linear regression is considered to be better than most of the other techniques as it is easier to Implement and contains basic mathematical and computational theory. It involves fitting a straight line to the given data points of independent variable(x) and dependent variable(y) whose slope is (m) and error is (e). This line is implemented by reducing the sum of squared differences between actual values understood in the above equations and diagrams-: here, 'c' is the intercept formed on dependent axis y. for multiple data sets with slopes m1, m2…mk we can use-: Steps for implementation of Linear regression includes-: 1) Importing necessary computing packages and creating the data from input files using pandas library. 2) Filter out the essential variables and generate a numpy array from pandas data frame to store continuous set of data. 3) Assigning the input variable (x,y) and performing recursive feature normalization , where we will compress our input variables to magnified values for faster speed and accuracy. 4) Plotting the data sets using matplotlib and plotly tools through normalized data and generate the graph as shown below-: Where θ0 and θ1 are current and next optimal positions, α is small step , Ω is direction and c(θ) is SSE..

Flow of stock market prediction website -
In order to develop GUI (graphical user interface) to make this predictor tool accessible to users, predictor is converted to a website which will show real time stock market prediction.
The first step in this is to collect and fetch the data from reliable source site Yahoofinance and creating a DBMS (data base management system) using SQLite. Data preprocessing is yet another important step in which inaccuracy or inconsistencies in data had been removed and data is transformed into user understandable format using pandas library in python. In the backend part numPy, plotly, matplotlib are used for multiple operation execution. The prediction part is performed using linear regression technique of machine learning. To access the machine learning tools and resources for the website, scikit learn library and Django framework are used respectively. For UI/UX part Html5 and CSS3 versions are used. The website is maintained at regular intervals and fetch new and current status of data everytime.

Collect Data
Data Pre-processing

3.Results and Discussions
The primary objective of this project was to predict stock market prices at a higher accuracy rates and it had been achieved at an approximate accuracy ranging in between 75% to 85 %. The stock market prediction website named "J3 predictor" can predict stock values from 1 day to 365 days (1 year). The website has stock data of multiple stocks connected to the data server through yahoo finance by API path. Website has ticker information of all the stocks available at the third tab, from which ticker value can be inserted into predictor page of second tab and get the results as shown below.  The results obtained at the first tab of the website are for top 6 companies and the remaining stock prediction occurs at prediction section. The comparison between actual stock prices and predicted prices for various NIFTY trading companies for 3 days duration from 10 may to 12 may are shown in table given below-: If the user enters wrong ticker symbol or wrong time duration then the predictor will give error that the data is inadequate. In this way, the stock prediction using machine learning has proven very useful for stock market prediction and can help many people who are newcomers to stock market or want to make money using stocks.

5.Future Scope
• Increased prediction accuracy. Future stock price projections are likely to be more accurate thanks to continuously improving machine learning algorithms • Information extraction from news articles and other text sources using natural language processing (NLP). A company's financial performance, competitive environment, and other elements that might affect its stock price can all be learned about using NLP. Then, using this data, machine learning systems can be trained to produce more precise predictions.
• The application of machine learning to forecast how non-financial events would affect stock values. Natural disasters or political scandals are examples of non-financial events that can have a big impact on stock values. Machine learning can be used to forecast how these occurrences would affect stock prices, enabling investors to reduce risk in their portfolios.
• The application of machine learning to forecast how climate change would affect the stock market. To reduce risk in investor portfolios, machine learning can be used to forecast how climate change would affect the stock market.
Overall, the potential of employing machine learning to anticipate stock prices is very positive. Machine learning algorithms are improving in accuracy, and more data is being made available to train them. Additionally, new machine learning algorithms are always being created. Future stock price predictions are likely to be more accurate because of these considerations.

6.Conclusion
Many people desire to forecast future stock prices in order to increase their fortune because the stock market is continuously changing. However, due to the volatile nature of the stock market, current solutions that employ cutting-edge technology like Deep Learning, AI, and Neural Networks have not proven successful in making precise forecasts. As a result, the analysis of the current methods for stock market prediction using a linear regression algorithm is the main goal of this review work. A supervised machine learning approach called linear regression establishes a linear relationship between independent and dependent variables. The choice of an appropriate dataset is crucial for successful stock market prediction using linear regression, according to a review of research papers. According to the experiments, the linear regression method performed better in terms of accuracy than other machine learning techniques. However, a lot of experts also stated that they planned to investigate neural networks' potential for stock market prediction in the future.

Acknowledgement
The research project received support from a renowned institution in Pune that is actively involved in the field of education and engineering sciences. The head of the Department of DESH, Prof. Chandrashekhar Mahajan, and the coordinator Dr. Sachin Sawant from this institution provided valuable assistance at every level of the project, and their contributions are highly appreciated. According to the experiments, the linear regression method performed better in terms of accuracy than other machine learning techniques. However, a lot of experts also stated that they planned to investigate neural networks' potential for stock market prediction in the future.