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
import geopandas as gpd #libspatialindex nees to be installed first | |
import json # library to handle JSON files | |
# Importing the Edinburgh borough boundary GeoJSON file as a dataframe in geopandas | |
map_df = gpd.read_file(r'/resources/Data_Science_Capstone/neighbourhoods.geojson') |
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.
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): |
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
#----------- 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
#------------- DEEP LEARNING -----------------# | |
#-----LSTM Network with Keras------# | |
#--- Parameters----# | |
# encodes input sequence dense vectors | |
embed_dim = 128 | |
# transforms the vector sequence into a single vector |
OlderNewer