Skip to content

Instantly share code, notes, and snippets.

View abnova's full-sized avatar

Aleksandr Blekh abnova

View GitHub Profile
@Inpirical-Coder
Inpirical-Coder / twitter.R
Created November 16, 2014 01:22
Simple script to download, scrub and classify Tweets according to polarity and emotion using a simple Bayes classifier
# 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.
library(ggplot2)
library(reshape)
library(scales)
### INSTRUCTIONS
# 1. Save file to same local directory
# 2. Change time zone specification in third IMPORT DATA statement
# 3. In each top_n_for_hour or top_n_for_day, test to statistical significance by comparing the result of the top_n function and the result of the matrix t test
@KatieHoban
KatieHoban / gist:4648be8e5a87606a5b28
Last active August 29, 2015 14:03
Unfollower Detector
#While this particular version takes files of the text on my followers and following pages,
#it can be easily modified to check a past list of followers against a more recent list -
#just replace following.txt with the "past followers" file and followers.txt with "present followers".
#encoding may be 'utf-8' depending on the type of files you are using
with open('following.txt', 'r', encoding = 'latin-1') as following_file:
with open('followers.txt', 'r', encoding = 'latin-1') as followers_file:
discrepancy = set(following_file).difference(followers_file)
@phillip-burger-sculpturearts
phillip-burger-sculpturearts / iris-lm-demo.Rmd
Created June 15, 2014 21:49
Analysis that fits linear models to the iris data set. Aim is to compare and interpret the results obtained from the open-source R lm() with results obtained from the Revolution Analytics RRE7 rxLinMod() function. This gist uses the open-source lm().
Example analysis-fitting linear models to iris data set
========================================================
* Name: iris-lm-demo.Rmd
* Date: June 12, 2014
* Author: Phillip Burger
```{r setup, message=FALSE, echo=FALSE}
options(width = 80, prompt = '>> ')
setwd("~/")
opts_chunk$set(out.width=650 , fig.align='center')
opts_knit$set(progress = TRUE, warning = TRUE, message=FALSE)
@NewsappAJC
NewsappAJC / legislative_tracker_model.R
Created February 13, 2014 23:10
R script used to estimate probabilities for the Atlanta Journal-Constitution's Georgia Legislative Navigator.
library(RMySQL)
library(rms)
gga_host<-Sys.getenv("GGA_HOST")
gga_user<-Sys.getenv("GGA_USER")
gga_password<-Sys.getenv("GGA_PASSWORD")
gga_database<-Sys.getenv("GGA_DATABASE")
con <-dbConnect(MySQL(), user = gga_user, password = gga_password, host = gga_host, dbname = gga_database)
@thertrader
thertrader / performanceReportREADME.txt
Last active December 7, 2021 05:19
Trading Strategies Performance Report with R and Knitr
###############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#to make the final table, I changed manually the n size every trial by: 1e3, 1e4, 1e5, 1e6, 1e7. Then I also chnaged the benchmark object 'res'
n <- 1e7
set.seed(51)
process <- data.frame(id=sample(100, n, rep=T), x=rnorm(n), y=runif(n), z=rpois(n, 1) pexp(2, rate=1/3) )
all <- multicore:::detectCores(all.tests=TRUE)
if(!require(rbenchmark)){
install.packages("rbenchmark")
} else{
@ndarville
ndarville / business-models.md
Last active October 9, 2025 17:55
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@dsparks
dsparks / Marimekko.R
Created September 23, 2012 14:34
Simplest marimekko/mosaic plot
# Simplest possible marimekko/mosaic plot
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("vcd", "ggplot2", "RColorBrewer")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
theme_set(theme_gray(base_size = 7))
# All you need to start with is individual count data, and a grouping variable
@abelsonlive
abelsonlive / getInsights.R
Created May 27, 2012 20:09
getInsights - an R API for Google Insights
#see below for query specifications
getInsights <- function(
username = "Insights4R@gmail.com",
password = "googleinsights4r",
text_query = "'hello world'",
date_query = "1/2004 108m",
geo_query = "US",
search_type= "all",
filter_category="none"){