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
# This gist uses rgl and quadprog to draw a circus tent | |
# by solving a quadratic program in R. The original problem is from the MathWorks MATLAB demo at: | |
# http://www.mathworks.com/help/optim/examples/large-scale-bound-constrained-quadratic-programming.html | |
# | |
# More information on this problem at: | |
# http://quantitate.blogspot.com/2014/04/the-circus-tent-problem-with-rs-quadprog.html | |
# | |
# author: R. Walker (r_walker@zoho.com) | |
# LICENSE: MIT |
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
# This gist compares three methods for solving a quadratic program in R. | |
# The original problem is from the MathWorks MATLAB demo at: | |
# http://www.mathworks.com/help/optim/examples/large-scale-bound-constrained-quadratic-programming.html | |
# | |
# More information on this problem at: | |
# http://quantitate.blogspot.com/2014/04/the-circus-tent-problem-with-rs-quadprog.html | |
# | |
# author: R. Walker (r_walker@zoho.com) | |
# LICENSE: MIT | |
library(quadprog) |
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
#!/usr/bin/python3 | |
''' | |
Autocompletion using a trie and a user supplied language file. | |
HINT: Linux/Unix users can look in "/usr/share/dict" for language files. | |
Author: rwalker | |
Email: r_walker@zoho.com | |
License: MIT | |
''' | |
import argparse, os, sys |
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
# | |
# Docker demo: container for a simple autocomplete program | |
# Autocomplete script is python3 and consumes a dictionary | |
# file packaged in the ubuntu operating system. | |
# | |
# start with the base ubuntu image | |
FROM ubuntu | |
# Tell apt-get that we are going to be NONINTERACTIVE |
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
#!/usr/bin/python3 | |
''' | |
Put documents from the stream into Kafka | |
''' | |
import argparse | |
from kafka import SimpleProducer, KafkaClient | |
from time import sleep | |
def chunk_iterable(A,n): | |
'''An iterable that contains the iterates of A divided into lists of size n. |
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
#!/usr/bin/python3 | |
''' | |
Sample from the twitter API and post results to a file or to Kafka. | |
To use, set credientials as enviornment variables, e.g. | |
export TWITTER_ACCESS_TOKEN=... | |
or source myfile | |
where myfile exports the authorization variables | |
''' | |
import twython, json, re, argparse, subprocess, os, sys, time | |
from socket import timeout |
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
# This gist samples positive and negative examples of a topic | |
# in the Reuters21578 corpus using R's "tm" package to manage | |
# the data. After some simple transformations to the text, | |
# the data are extracted to a document-term matrix and a simple | |
# SVM model is fit to classify positive examples of the topic. | |
# | |
# author: R. Walker (r_walker@zoho.com) | |
# LICENSE: MIT | |
# | |
# NOTE: Download the full Reuters21578 corpus from |
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
library(foreign) | |
library(car) | |
library(ggplot2) | |
library(scales) | |
# load the CHIS data | |
file <- "~/projects/CHIS/chis15_adult_stata/Data/ADULT.dta" # your file | |
CHIS <- read.dta(file, convert.factors = TRUE) | |
# Recode insurance type |
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
# This gist compares three methods for solving a randomly generated quadratic program in R. | |
# author: R. Walker (r_walker@zoho.com) | |
# LICENSE: MIT | |
library(quadprog) | |
library(kernlab) | |
library(ipoptr) | |
library(ggplot2) | |
library(reshape2) | |
######################################################### | |
# Random QP Generation (in the style of quadprog) |
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
library(quadprog) | |
library(osqp) | |
# This gist compares the quadprog solver against OSPQ on a very simple problem. | |
## | |
## The following example comes directly from `?? quadprog` documentation` | |
## | |
## Assume we want to minimize: -(0 5 0) %*% b + 1/2 b^T b | |
## under the constraints: A^T b >= b0 |
OlderNewer