This project aims to predict the stock price of Reliance Industries Limited (RIL) using Twitter sentiment analysis. By combining social media signals with historical stock prices, we attempt to explore the impact of public sentiment on market behavior.
The project pipeline includes:
- Collecting tweets relevant to Reliance
- Performing sentiment analysis on tweets
- Merging sentiment scores with historical RIL stock data
- Building a predictive model (Linear Regression)
- Visualizing the effect of sentiment on stock prices
- Tweets.csv: Contains raw tweets about Reliance.
- RIL.csv: Historical stock price data of Reliance Industries.
- Twitter_Dataset.pkl: Pickled version of the preprocessed tweet dataset.
- Clean tweet texts by removing mentions, URLs, emojis, and special characters
- Convert to lowercase and remove stopwords
- Perform tokenization and lemmatization
- Each tweet is assigned a polarity score using TextBlob
- Tweets are labeled as Positive, Neutral, or Negative
- Daily sentiment scores are averaged
- Resulting features include daily average sentiment and counts of each sentiment class
- Stock price data is merged with daily sentiment scores
- Final dataset includes stock closing prices and aggregated sentiment data
- A linear regression model is trained to predict next-day closing prices
- Features used: sentiment polarity, sentiment counts
- Performance is evaluated using Mean Squared Error (MSE)
- Visual plots compare predicted vs actual stock prices
The model shows that Twitter sentiment holds weak but noticeable predictive power for RIL stock movements. The results validate that sentiment data can enhance traditional price forecasting.
- pandas
- numpy
- matplotlib
- seaborn
- textblob
- sklearn
Install them using:
pip install -r requirements.txt- Clone the repository or download the
.ipynbfile - Ensure all datasets (
RIL.csv,Tweets.csv) are in the same directory - Open the notebook and run all cells in order
This project is developed as part of a stock prediction research case study using NLP and sentiment-driven market signals.