Coders Packet

Stock Price Prediction using Linear Regression in Python

By Dhruv Khurana

Project on prediction of stock prices using a simple linear regression model in Python

Linear regression tries to predict the relationship between two variables by fitting a linear equation to the collected data. It attempts to draw a straight line that best minimizes the residual sum of squares. The relationship is modeled between an independent and a dependent variable. In this project, we will predict stock prices for the future dates using a dataset containing stock entries. We will use Closing Price as a target variable and the ordinal dates as the independent variable. After preprocessing the data, it is split into training and testing set. Finally the model is plotted for the test set variables. The model returns a R2 score (coefficient of determination) equal to 0.56 indicating a moderate linear relationship.
 
Plot of prediction
The Python script is written and tested in Spyder IDE which can be downloaded from the official Anaconda website.

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Dhruv Khurana (dhruvkhuranag)

Download packets of source code on Coders Packet