Bhargav Adepu

NO. 15MACHINE LEARNING · SHIPPEDNOVEMBER – DECEMBER 2024

Stock Sentiment Prediction

Six algorithms, one ensemble vote

Best model93.29%K-Neighbors
Spread3.6 ptsbest to worst
Algorithms6combined by voting
Training records14,000+sentiment-labelled

Python · Django 3.2 · scikit-learn · TensorFlow · TF-IDF · NLTK

Raw text runs through a full NLP preprocessing pipeline — cleaning, tokenization, stop-word removal, lemmatization, then TF-IDF vectorisation with n-gram feature extraction — before being fed to six different classifiers: a deep neural network, SVM, logistic regression, decision tree, K-Neighbors and gradient boosting, combined through a voting ensemble.


K-Neighbors93.29%
Logistic Regression92.31%
Gradient Boosting92.14%
Deep Neural Network91.82%
Decision Tree91.00%
Support Vector Machine89.69%
0100%

FIG. 1Six classifiers on identical features. The interesting result is the spread: 3.6 points separates the best from the worst, which says the features are doing the work, not the model choice.

K-Neighbors came out best at 93.29% accuracy with precision, recall and F1 all at 0.933. But the more useful observation is the narrowness of the field: only 3.6 percentage points separate the best model from the worst, and a KNN beating a deep network on the same features is a strong hint that the TF-IDF representation is carrying the signal and the classifier is close to irrelevant. The ensemble exists for robustness rather than for accuracy.