This file contains hidden or 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
# Short scripts for testing three different sentiment classifiers on tweets, | |
# acquiring the tweets used for testing, | |
# calculating systems' precision, recall and F-measures. | |
require(RCurl) # For downloading file from a given URL. | |
require(twitteR) # Used for the 'twitter' class. | |
require(sentiment) # For bayes and voter classifiers. | |
source("sent140.R") # Used for the Sentiment 140 API. Can be downloaded from here: | |
# https://github.com/okugami79/sentiment140/blob/master/R/sentiment.r |
This file contains hidden or 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
# Simple script for doing some data-analysis of tweets; | |
# looking at "sentiment" and "emotion" using the sentiment package. | |
# see https://sites.google.com/site/miningtwitter/questions/sentiment/sentiment | |
# for background. | |
# SETTINGS | |
# ============================================================================= | |
authenticated = TRUE # If TRUE will load credential from file. | |
tweets.from.file = TRUE # If TRUE will load tweets from file rather than query. | |
no.tweets = 1500 # Number of tweets to fetch in every search; <= 1,500. |
This file contains hidden or 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
# Code to fetch news streams from 5 live sources, process the streams and text | |
# and apply a simple sentiment scoring algorigthm. | |
# | |
# A writeup of the analysis can be found here: | |
# https://www.linkedin.com/pulse/article/20141109035942-34768479-r-sentiment-scoring-hsbc-w-harvard-general-inquirer | |
# Define the packages we want to load: | |
packs = c( | |
"tm", # Text mining | |
"tm.plugin.webmining", # Web-source plugin for text mining |
This file contains hidden or 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
# Some code to asses an SVM with a two-dimensional feature space: | |
# trend (price - simple moving average) and relative strength index. | |
# The code is an adaptation of the code found in the following linkedin post: | |
# "Trading the RSI using a Support Vector Machine" | |
# "https://www.linkedin.com/pulse/article/20141103165037-172934333-trading-the-rsi-using-a-support-vector-machine" | |
# Settings | |
sma.window = 50 # Number of observations in simple moving average. | |
rsi.window = 3 # Number of observation in relative strength index (RSI) |
This file contains hidden or 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
# This is a simple example for acquiring text-stream assets using the R "tm" package | |
require(tm) # Load the text-mining package. | |
require(tm.plugin.webmining) # Web-mining plugin for text mining. | |
require(SnowballC) # Package for stemming. | |
# Define the symbol we want to acquire news on. | |
sym = "NYSE:HSBC" | |
# Build a corpus of the news items. |