A comprehensive MLOps solution for analyzing financial news sentiment and ranking stocks based on market impact.
- Data Ingestion: Curated financial news data from Kaggle News Sentiment Dataset.
- Local Storage: News articles stored in SQLite database with schema:
articles(id, title, content, date, source)
sentiments(article_id, label, score)
- Real-time Processing:
- Continuous model validation using incremental learning.
- Automated data versioning with DVC.
Data Layer (SQLite) → Processing Layer → Model Serving → Application Layer (Gradio)
-
Technical Implementation: Base Model: FinBERT (Financial Domain BERT).
-
Custom Training:
Fine-tuned on Kaggle dataset (10,000 labeled articles).
Dynamic threshold adjustment based on market volatility.
- Processing Flow::
Text cleaning (stopwords, lemmatization).
Context-aware sentiment scoring.
Confidence-based filtering (score > 0.7).
Interactive Plotly histograms.
Real-time sentiment distribution updates.
Ranking Score =
(Sentiment Strength × 0.5) +
(Article Volume × 0.3) +
(Recency Factor × 0.2)
Sentiment Strength: Weighted average of confidence scores.
Article Volume: log(n_articles) scaled 0-1.
Recency Factor: Exponential decay (24h half-life).
git clone https://github.com/AmmarsGeeks/Stock-Sentiment-MLOps
cd stock-sentiment-mlops
pip install -r requirements.txt
# Copy the example environment file:
cp .env.example .env
Edit .env to include:
Database path.
Model parameters.
python main.py
Fetch sentiment analysis for a specific company:
curl http://localhost:8000/analyze?company=Apple
Rank multiple companies based on news sentiment:
curl -X POST http://localhost:8000/rank \
-H "Content-Type: application/json" \
-d '{"companies": ["Apple", "Microsoft", "Google"]}'
Rank multiple companies based on news sentiment:
Python: Core programming language.
Gradio: For building the web interface.
Transformers: For sentiment analysis using FinBERT.
SQLite: For local data storage.
Plotly: For interactive visualizations.
Kaggle: For providing the News Sentiment Analysis Dataset.
Hugging Face: For the FinBERT model.
Gradio: For the easy-to-use web interface framework.