Skip to content

Instantly share code, notes, and snippets.

@ngopal
ngopal / Exploring SciKit Learn.ipynb
Created May 28, 2017 22:53
Trying AdaBoosted Decision Trees
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ngopal
ngopal / Data+Scientist+Thinking+Process.ipynb
Created May 23, 2017 18:12
IMBD_notebook example for Tim
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.
@ngopal
ngopal / REPL.R
Created April 18, 2017 04:52
How to write a REPL in R
REPL <- function() {
while(T) {
print(eval(parse(text=readline("NG>>"))))
}
}
REPL()
@ngopal
ngopal / spam.clisp
Created March 23, 2017 00:46
A first attempt at creating bayesian a spam filter from stratch; Trying to do this in lisp as a learning exercise; Definitely still a work in progress...
;; A first attempt at creating bayesian a spam filter from stratch
;; Trying to do this in lisp as a learning exercise
;; Definitely still a work in progress...
(defparameter *spam* '(this is a spam document that is fake news))
(defparameter *ham* '(this is nikhils document))
(defparameter *testdoc* '(this is a test document that is meant to be fake))
(setq spam-table (make-hash-table))
(setq ham-table (make-hash-table))
library(randomForest)
library(RJSONIO)
library(ROCR)
# Research Questions
# 1. What are the ranked importances of node encodings?
# 2. What are the ranked importances of edge encodings?
# 3. How important is network structure to noticeability?
# 3a. Where do participants tend to click?
@ngopal
ngopal / stocktwitdash.R
Created February 14, 2017 19:43
The beginnings of a stock twit dashboard.
library(syuzhet)
library(igraph)
library(RCurl)
plotDashBoard <- function(ticker) {
twits <- getURL(paste("https://api.stocktwits.com/api/2/streams/symbol/",ticker,".json", sep=""))
twts.tab <- fromJSON(twits)
# Sentiment
twt.sent <- get_nrc_sentiment(twts.tab$messages$body)
@ngopal
ngopal / wines.R
Last active February 10, 2017 21:39
A very quick and surface-level analysis of wines using the wines.com API
library(rjson)
apikey = 'REDACTED' # please get one from wines.com
url <- paste('http://services.wine.com/api/beta2/service.svc/json/catalog?filter=categories(614)&offset=0&size=100&apikey=',apikey,sep="")
document <- fromJSON(file=url, method='C')
# I am pulling down light and crispy white wine data above
ds <- matrix(0, 100, 3)
for (i in 1:length(document$Products$List)) {
ds[i,] <- c(as.numeric(document$Products$List[[i]]$PriceRetail),
as.numeric(document$Products$List[[i]]$Ratings$HighestScore),
@ngopal
ngopal / general_assembly.ipynb
Last active January 21, 2017 03:09
removed an annoying extra cell.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ngopal
ngopal / quote_generator_main.py
Created September 17, 2012 00:41
the main program for the quote generator web app example (built with Flask)
from flask import Flask, url_for, render_template, g, redirect
import random
import sqlite3
DATABASE = 'quotes.db'
app = Flask(__name__)
def connect_db():
return sqlite3.connect(DATABASE)