How remidomingues/virality-prediction works
Main Components
• External Data Sources:
• Twitter API: This is where tweet data comes from.
• Data Ingestion and Collection:
• Scripts such as stream.py, tweeets2011Crawler.py, and twitterSearch.py are responsible for fetching tweet data from Twitter.
• authExample.py (to be renamed to auth.py) handles API authentication.
• Data Storage:
• A MongoDB instance is used to store raw and processed tweet data.
• Data Preprocessing / Feature Extraction:
• featureExtractor.py (and possibly dataAnalysis.py) extracts the necessary features from the raw data.
• retweetUpdater.py is used later to update tweet retweet counts to capture later engagement.
• Model Training and Prediction:
• regression.py (and possibly svr.py) are used to train regression or classifier models.
• viralityPrediction.py uses the trained models to predict tweet or hashtag virality.
• Utility/Indexing:
• hashtagIndex.py builds the inverted index mapping hashtags to corresponding tweets for further predictions.
Flow and Interactions
• Data flows from the external source (Twitter API) into the Data Collection modules.
• Collected tweets are stored in MongoDB.
• Once in storage, preprocessing starts:
• Feature Extraction: Data flows from MongoDB to the featureExtractor.
• Update Processes: retweetUpdater.py adjusts engagement data.
• For Machine Learning:
• After feature extraction, the cleaned data is fed into the model training components (regression.py, svr.py) to train predictive models.
• Trained models are then used by viralityPrediction.py for making predictions.
• Additionally, hashtagIndex.py creates a mapping from hashtags to tweets, which is used in some prediction tasks.
Architectural Patterns and Design Principles
• Pipeline/Chain-of-Responsibility: Each stage (data ingestion → storage → preprocessing → modeling → prediction) is a distinct layer that passes data along, which is typical for a data-driven predictive system.
• Separation of Concerns: The project distinguishes between acquiring data (stream/crawler), storing data (MongoDB), processing data (feature extraction, retweet updating, indexing), and analyzing data (model training and prediction).
Specific Technologies and Frameworks
• Python is the backbone of the scripts.
• MongoDB is used as the database.
• Machine learning libraries (implied by regression.py and possibly svr.py) are central to the predictive functionality.
• Twitter API is a critical external dependency.
Elements
• Labels for each component:
• Clearly label nodes like “Twitter API”, “Data Ingestion (stream.py, tweeets2011Crawler.py, twitterSearch.py)”, “MongoDB Database”, “Feature Extraction (featureExtractor.py)”, “Retweet Updater (retweetUpdater.py)”, “Model Training (regression.py/svr.py)”, and “Prediction (viralityPrediction.py)”.
• Differentiating external systems (Twitter API) from processing scripts and databases for clarity.