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.
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.
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.
Set up your environment:
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txtDownload 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.pyThis 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.
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.
Python (pandas, TextBlob, statsmodels), Exponential Smoothing for forecasting, Power BI Desktop for visualization, YAML configuration.