How safiullahaamir/tweetviralitypredictor works
Project Type and Purpose
• This is a machine-learning-powered Streamlit web application that predicts tweet virality (Viral vs Non-Viral).
• It comprises a small training pipeline (in a Jupyter notebook and Python scripts), serialized artifacts (model and vectorizer), and a Streamlit front end for inference.
Main Components
a. Frontend (Streamlit UI)
• TweetViralityPredictor_App.py: defines the web interface, input fields, and displays prediction.
• Hosted on Streamlit Cloud (tweet-virality-predictor.streamlit.app).
b. Model Artifacts (Storage)
• tfidf_vectorizer.pkl: serializes the TF-IDF transformer.
• logistic_regression_model.pkl: serializes the trained classifier.
c. Data & Training Pipeline
• main.ipynb: data preprocessing, EDA, feature engineering, model training, evaluation.
• tweet_content-engagement_dataset.csv: the training dataset.
d. Dependency & Configuration
• requirements.txt: Python dependencies (pandas, numpy, scikit-learn, streamlit, etc.).
• .devcontainer: development environment setup for VS Code (optional).
Relationships & Data Flow
1. User enters tweet text and numeric features in the Streamlit UI.
2. TweetViralityPredictor_App.py loads tfidf_vectorizer.pkl to transform text → feature vector.
3. The vector and numeric inputs feed into logistic_regression_model.pkl for inference.
4. Prediction (“Viral”/“Non-Viral”) is returned to the UI.
5. (Offline) main.ipynb reads the CSV → trains model → serializes artifacts.
Architectural Patterns & Design Principles
• Separation of Concerns: distinct phases for training (in notebook) vs. inference (in app script).
• Layered Architecture:
• Presentation Layer (Streamlit UI)
• Application Layer (prediction logic in Python script)
• Data Layer (serialized model & vectorizer, CSV dataset)
• Reproducibility: environment pinned in requirements.txt and devcontainer.json.