Skip to content

Instantly share code, notes, and snippets.

#The input data should be in CSV format.
# Each row is a campaign. The columns are (description and variable name):
# Campaign id (id)
# Conversion rate (cvr)
# Bid price (price)
# Max allocated campaign budget (max_allocation)
import csv
import sys
id cvr price max_allocation
1 0.005 4 100
2 0.001 0.75 100
3 0.0001 0.1 100
@greeness
greeness / gist:a547c28d441d2e79f793
Last active August 29, 2015 14:13
cw from Justin Ma's impl
% Exploiting feature covariance in high-dimensional online learning
% http://videolectures.net/aistats2010_ma_efcih/
% http://sysnet.ucsd.edu/projects/url/
function [err,mu,sigma,mem] = cw(X,Y,params)
% X is k features by N instances
% Y is 1 label in {-1,1} by N instances
% params is struct containing options
% err: cumulative mistakes after each example
@greeness
greeness / gist:a097d116ac9e60372c7f
Created November 19, 2014 04:35
learning scipy numpy
[Python Scientific Lecture Notes]: (http://scipy-lectures.github.io/index.html)
@greeness
greeness / simhash links
Last active April 28, 2020 14:05
simhash
@greeness
greeness / board.py
Created July 14, 2014 20:46
board init and hexagon printout
import json
from sys import stdout
from random import choice, seed, shuffle
from copy import deepcopy
basic_shapes = [
[(0,0), (1,0), (2,0)],
[(0,0), (0,1), (0,2)],
[(0,0), (-1,1), (-2,2)],
[(0,0), (-1,0), (-2,0)],
@greeness
greeness / gist:da164882b4baa7638e97
Created June 10, 2014 19:47
Random project for dimension reduction
http://users.ics.aalto.fi/ella/publications/randproj_kdd.pdf
import json
from datetime import datetime
from copy import deepcopy
from random import random
def append_features_from_user_block(user_block, user_row):
user_row["num_turns"] = len(user_block)
user_row["min_balance"] = min([x["balance"] for x in user_block])
user_row["max_balance"] = max([x["balance"] for x in user_block])
user_row["min_level"] = min([x["level"] for x in user_block])
@greeness
greeness / standard.py
Last active August 29, 2015 14:02
step 1.
from datetime import datetime
import numpy as np
age_ranges = ['13-24', '25-35', '36-52', '53-64']
device_options = ['Phone', 'Tablet']
platform_options = ['a', 'i']
def weighted_choice(weights):
totals = np.cumsum(weights)
norm = totals[-1]
{
"metadata": {
"name": "2d Convolution"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{