// Python · Deep Learning · NLP

Crypto
Sentiment

Deep learning models that predict cryptocurrency market sentiment from Twitter. 20,000 tweets, two model architectures — CNN and MLP — trained and evaluated with no pretrained weights.

// Data Pipeline

Twitter API · Tweepy
20,000 tweets
Preprocessing
clean · tokenize · filter
VADER
auto-label sentiment
Split
19,900 train · 100 test
Model A
MLP
Bag-of-Words
Model B
CNN
Embedding + Conv1D

Accuracy

Both models were evaluated on a held-out test set of 100 tweets. The MLP outperformed the CNN, likely due to the bag-of-words representation being a better fit for short, noisy tweet text.

Example Tweets

Manual tests used during evaluation — both models predicted correctly.

"crypto will definitley go up. It has a bright future! #bitcoin"
POSITIVE · both models
"crypto will die soon!!! Please dont buy"
NEGATIVE · both models

Implementation

Built with Keras on TensorFlow. Data collected via Tweepy. Sentiment labels generated automatically using VADER.

Tweepy

Twitter API client. Searched for crypto-opinion keywords — "crypto will", "crypto can", "crypto is" — filtering out retweets and links to target opinionated text.

VADER

Rule-based sentiment analyzer from NLTK. Used to auto-classify 20,000 tweets as positive or negative, producing training labels without manual annotation.

Keras / TensorFlow

Both models built with Keras Sequential API. CNN uses Embedding → Conv1D → MaxPooling → Dense. MLP uses bag-of-words frequency vectors as input.

NLTK

Tokenization, stopword removal, and VADER sentiment analysis. Preprocessing pipeline strips punctuation, non-alphabetic tokens, and common English stop words.

Neural Bag-of-Words

Vectorization strategy for the MLP. Each tweet is encoded as a frequency vector over the full vocabulary — 26,836 dimensions — fed directly into a dense layer.

Vocab Filtering

Custom vocabulary built from the corpus, retaining only words appearing in 2+ tweets. Rare and misspelled words are excluded before training.

// How It Works

Under the Hood

Two separate pipelines — one per model — share the same preprocessing and labeling steps.

Data Collection twitter_data.py

Tweepy's cursor API streams tweets matching keyword filters over a date range. Each tweet is cleaned — punctuation stripped, stopwords removed, links and retweet markers dropped — then written to reviews.txt. A vocabulary counter tracks word frequency; words appearing fewer than twice are excluded from vocab.txt.

Auto-Labeling VADER

VADER's polarity scorer produces positive, negative, and neutral scores for each cleaned tweet. If the negative score dominates, the tweet is labeled 0. If positive dominates, it's labeled 1. Neutral tweets are discarded. Labels are saved to classify.txt, aligned line-by-line with reviews.txt.

CNN Model Conv1D

Tweets are integer-encoded and padded to uniform length. An embedding layer maps each word to a 100-dim vector. A Conv1D layer with 32 filters and kernel size 8 extracts local n-gram features, followed by max pooling, a dense ReLU layer, and a sigmoid output. Trained for 50 epochs with binary cross-entropy.

MLP Model Bag-of-Words

Tweets are encoded as frequency vectors over the full 26,836-word vocabulary using texts_to_matrix(mode='freq'). A single hidden layer of 50 ReLU units feeds into a sigmoid output. Trained for 100 epochs. Higher accuracy than the CNN — the global word-frequency representation works well for short social media text.

// Reflection

What I Learned

Things that weren't obvious until I built it.