Giter Site home page Giter Site logo

roshancharlie / tata-motors-close-price-forecasting Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 14.42 MB

License: Apache License 2.0

Jupyter Notebook 100.00%
stock-price-prediction tata eda linear-regression matplotlib numpy pandas plotly python random-forest

tata-motors-close-price-forecasting's Introduction

TATA Motors Stock Close Price Forecasting

Introduction

This project aims to predict the closing price of TATA Motors stock using various machine learning algorithms and technical indicators. The data used for this project ranges from 2020 to 2023.

Libraries Used

The following libraries are used in this project:

  • pandas for data manipulation and analysis
  • yfinance for downloading stock data from Yahoo Finance
  • numpy for mathematical operations
  • matplotlib and seaborn for plotting and visualization
  • plotly for interactive charts
  • cufflinks for creating charts using pandas dataframes
  • warnings for ignoring warnings
  • sklearn for machine learning algorithms and evaluation metrics

Data Collection and Exploration

The data for TATA Motors stock is collected from yfinance library and the start and end dates are set from 1999 to 2023. The data is then explored to understand the general characteristics and trends of the stock.

Exploratory Data Analysis

The following exploratory data analysis techniques are used in this project:

  • Calculation of mean, median, standard deviation, max and min of closing price and opening price
  • Distribution of daily returns
  • Candlestick chart to show the variation between the highest and lowest returns
  • Moving average chart to show the trend of the closing price and Opening Price
  • Correlation heatmap to show the relationship between different features
  • Technical indicators such as simple moving average and Bollinger Bands to identify trends and volatility.

Feature Engineering

The following features are engineered in this project:

  • Weekly moving average for the Closing Price
  • Bollinger Bands for the Closing Price

Model Selection and Evaluation

The following machine learning algorithms are used in this project:

  • Linear Regression
  • Random Forest Regressor
  • Support Vector Regression (SVR)

Optional

Before training our models, we need to standardize our data to ensure that the scale of each feature is consistent. This is important because some algorithms are sensitive to the scale of the input data.To standardize the data, we will use the MinMaxScaler class from the scikit-learn library. This class will transform our data by subtracting the mean and dividing by the standard deviation.

The models are trained and tested and the evaluation metrics used are R2 score

  • R2 score for linear regression: 0.9516679456767138
  • R2 score for random forest: 0.9298548382265217
  • R2 score for Support Vector R: 0.34399857626537955 The best performing model is selected based on the evaluation metrics.

Based on the R2 scores, it appears that the linear regression model performed the best with an R2 score of 0.9516679456767138

Model Prediction

Linear Regression model will be used to predict the closing price of Tata Motors stock.After that, we will evaluate the model by checking the R2 score, mean absolute error, and mean squared error.We will then use this model to make predictions on the future closing prices of Tata Motors stock.Then Plot The Actual and Prediction Data Using The Scatter Plot and Inference Chart is Plotted to show all how predicted price support the momentum for long term

Connect with me

Gmail LinkedIn Instagram HackerRank Github logo

tata-motors-close-price-forecasting's People

Contributors

roshancharlie avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.