Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News Sentiment Forecast

A Python pipeline that converts news headlines into daily sentiment scores and forecasts the next 30 days. Results are visualized in Power BI as a standard dashboard with ML-powered predictions underneath.

This works as a template, any dataset with dates and text can plug into the same workflow.

Dataset

Uses the News Category Dataset from Kaggle (HuffPost articles):

Misra, Rishabh. News Category Dataset
https://www.kaggle.com/datasets/rmisra/news-category-dataset

Download News_Category_Dataset_v3.json and place it in data/raw/huffpost.json.

What it does

The pipeline processes news data through several steps: loads the HuffPost JSON file, converts it to CSV with date, headline, description, and category, combines text fields, computes sentiment scores using TextBlob, aggregates to daily averages, fits an Exponential Smoothing model, and forecasts 30 days ahead.

The Power BI dashboard shows historical sentiment (blue line), 30-day forecast (orange line), comparison cards for recent vs forecasted sentiment, and a table of forecasted values.

Running locally

Set up your environment:

python -m venv .venv
.venv\Scripts\activate  # Windows
pip install -r requirements.txt

Download the dataset from Kaggle and save as data/raw/huffpost.json.

Run the pipeline:

python src/convert_huffpost_json.py
python src/prepare_data.py
python src/train_forecast.py

This creates processed data files and exports data/forecast/forecast_for_pbi.csv.

Open dashboard/news_sentiment_forecast.pbix in Power BI Desktop and click Refresh.

Using your own data

Prepare a CSV with a date column and one or more text columns.

Update configs/config.yaml with your file path, date column name, and text column names.

Run the data preparation and forecasting scripts, then refresh the Power BI file.

Built with

Python (pandas, TextBlob, statsmodels), Exponential Smoothing for forecasting, Power BI Desktop for visualization, YAML configuration.

About

End-to-end template that adds sentiment analysis and 30-day time-series forecasting to any date + text dataset (e.g., news headlines), visualized in a Power BI dashboard.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages