This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------ FEATURE ENGINEERING ----------------# | |
#--- Part of Speech Tags (POS)--# | |
nltk.download('averaged_perceptron_tagger') | |
pos_family = { | |
'NOUN' : ['NN','NNS','NNP'], # Removed 'NNPS' | |
'PRON' : ['PRP','PRP$','WP','WP$'], | |
'VERB' : ['VB','VBD','VBG','VBN','VBP','VBZ'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------- DEEP LEARNING -----------------# | |
#-----LSTM Network with Keras------# | |
#--- Parameters----# | |
# encodes input sequence dense vectors | |
embed_dim = 128 | |
# transforms the vector sequence into a single vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------- CROSS-VALIDATION WITH GRID SEARCH ------------------------# | |
# Naive Bayes Classifier | |
# combine features | |
features_tfidf = features_union(tfidf) | |
# instantiate pipeline object | |
nb_pipeline = Pipeline([('feats', features_tfidf), ('clf', MultinomialNB())]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------- FEATURE ENGINEERING ------------------------# | |
#---------- Sentiment Score with Vader -----------------# | |
# Instantiate Vader | |
analyser = SentimentIntensityAnalyzer() | |
def polarity_scores_all(tweet): | |
''' | |
Takes string of text to: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------------------- ETL ---------------------------------------# | |
# Pipeline like preprocessing with helper functions | |
nltk.download('stopwords') | |
stop_words = stopwords.words('english') | |
# cleaning helper function -----------------------------# | |
def processTweet(tweet): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder