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
""" | |
A little script for summarizing my Interactive Broker statements | |
""" | |
from pandas import * | |
from pandas.util.testing import set_trace as st | |
import numpy as np | |
from BeautifulSoup import BeautifulSoup |
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
#!/usr/bin/env python2.6 | |
# coding: utf-8 | |
import twitter | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
ACCESS_TOKEN_KEY = '' | |
ACCESS_TOKEN_SECRET = '' |
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
def online_mean_variance(iterable): | |
mN = 0 | |
mM = 0.0 | |
mS = 0.0 | |
for x in iterable: | |
mN += 1 | |
nextM = mM + (x - mM) / mN | |
mS += (x - mM) * (x - nextM) |
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
license: gpl-3.0 | |
redirect: https://observablehq.com/@mbostock/mobile-patent-suits |
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
from scipy import linalg | |
import numpy as np | |
from scipy.spatial.distance import cosine | |
#Let's define the matrix | |
user_ids = np.array(['Amanda', 'Anna', 'Bruno', 'Ricardo']) | |
item_ids = np.array(['Back to The Future', 'Conan', | |
'Lord of the Rings', 'Star Wars']) | |
matrix = np.matrix([ |
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
# Copyright 2011 10gen | |
# | |
# Modified by Antonin Amand <[email protected]> to work with gevent. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
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
.fb_access_token | |
.fbconsole.py |
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
def spearman_coefficient(X, Y): | |
""" | |
Considering the rows of X (and Y=X) as vectors, compute the | |
distance matrix between each pair of vectors. | |
Like Pearson Coefficient , but compares relative ranking of preference | |
values instead of preference values themselves. That is, each user's | |
preferences are sorted and then assign a rank as their preference value, | |
with 1 being assigned to the least preferred item. |
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
import datetime | |
import sys | |
import random | |
def _rank_dists(ranks1, ranks2): | |
"""Finds the difference between the values in ranks1 and ranks2 for keys | |
present in both dicts. If the arguments are not dicts, they are converted | |
from (key, rank) sequences. | |
""" |
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
# Script to generate a co-occurring tag graph from news articles via Guardian Platform API | |
# This is a quick hack script - just get things done... Needs refactoring/tidying... | |
import simplejson,urllib,csv,sys | |
from itertools import combinations | |
# D3.js json generator from https://bitbucket.org/hagberg/networkx-d3 | |
import d3 | |