How granthgg/news-headline-sentiment-analysis-stock-prediction works
Main Components
• User Interface (Frontend) – The Streamlit app (located in WebApp/main.py) that serves as the entry point for users. It displays the UI, accepts user input (news headlines), and allows model selection using radio buttons.
• ML Prediction Engine – This consists of the pre-trained ML models (Logistic Regression, Naive Bayes, Random Forest) stored as pickle files (lr_classifier.pkl, nb_classifier.pkl, rf_classifier.pkl) that are loaded to make predictions.
• Data Resources – CSV files (Stock Headlines.csv available in both the root and WebApp directories) might be used for either training, testing, or displaying live stock headlines. There’s also a training corpus stored in train_corpus.pkl.
• Experimentation/Development Notebook – The Stock Sentiment Analysis.ipynb indicates exploratory analysis/development which might have been used to develop and validate the ML models.
Relationships and Interactions
• User actions (entering a headline and selecting a prediction model) trigger the Streamlit app (frontend) to call the appropriate prediction function.
• The main application logic (in main.py) loads the selected ML model from its respective pickle file and uses the headline input to generate a prediction.
• After processing, the application returns the result to the UI where the prediction (e.g., “stock price goes up or down”) is displayed to the user.
• Additionally, the UI fetches and displays the top 10 world news headlines, which might be stored in one of the CSV files.
Architectural Patterns and Design Principles
• Clearly separated UI and prediction logic – Although integrated in a single script, it is conceptually divided into a presentation layer (Streamlit interface) and a business logic layer (prediction engine).
• Modularity – The existence of separate pickle files for different ML models allows for plug-and-play flexibility, with the user choosing which model to use.
• Data Handling – The CSV files and the training corpus indicate a separation between static resources and dynamic computation (the classification logic).
Relevant Technologies and Frameworks
• Streamlit for building the web UI.
• Python as the programming language underpinning the application logic.
• Machine Learning libraries (e.g., scikit-learn, implied by the classifiers used) for the creation of the ML models.
• Serialization with pickle for model storage and retrieval.