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
import sys | |
class Rhuthmos(object): | |
def __init__(self): | |
""" | |
wts = word to structure. A hash. | |
stw = structure to word. A tree. | |
""" | |
self.wts = {} | |
self.stw = {} |
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
import sys | |
class Rhuthmos(object): | |
def __init__(self): | |
""" | |
wts = word to structure. A hash. | |
stw = structure to word. A tree. | |
""" | |
self.wts = {} | |
self.stw = {} |
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
# stochastically generated poem from Darwin's _On the Origin of Species_. | |
He often begins his selection, | |
Done nothing, and all the species of shells in the same genus have been checked. | |
Mainly distinctive of each species, has been victorious in a reversed direction. | |
But I believe the above effect. | |
Competition by having inhabited a protected station, | |
Its contingencies of extinction will tend to intersect. | |
Connect and except secondly by a rotation. |
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
>>> from rhymeless import Rhymeless | |
>>> poem_generator = Rhymeless() | |
>>> book = open("books/on_the_origin_of_species.txt", "r") | |
>>> lines = [] | |
>>> for line in book: | |
... lines.append(line) | |
... | |
>>> book = "".join(lines) | |
>>> | |
>>> # the book variable is just a huge string. I could also train |
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
import numpy as np | |
import som | |
from grid import hexagonal_grid # comes with som repository | |
from distance import euclidean # also comes with the som repository | |
##### Create a funky, curved data set in 3 dimensions. ##### | |
data = np.transpose(np.matrix([ | |
np.random.normal(0,1,20000), | |
np.random.normal(0,1,20000), | |
np.random.normal(0,1,20000) |
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
import lsh | |
lsh_machine = lsh.LSH(assignment_name="example") | |
# data is a dictionary of the form: | |
#{user_id: set([item_id1, item_id2, ...]), ...} | |
# Depending on the input size, training can take a while. | |
# But it will use all your cores to do so, and will | |
# automatically cache the data for assignment_name. This |
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
import urllib2 | |
import os | |
import re | |
from sgmllib import SGMLParser | |
print '-' * 80 | |
print ' History of Electronic / Electroacoustic Music, 1937-2000 ' | |
print '-' * 80 | |
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
# Here's a small experiment in hacking together a formula notation for | |
# Python, in the style of R. This is without reference to any matrices, but | |
# it's pretty straightforward to see how one might plug such a system into a | |
# matrix library. | |
# I bet this could easily extend to other R formula features. | |
class Predictor(object): | |
def __init__(self,label): | |
self.label = label |
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
date,nbrhd,count | |
1997-01-01,Inner Richmond,121 | |
1997-01-01,Japantown,7 | |
1997-01-01,Glen Park,16 | |
1997-01-01,Western Addition,45 | |
1997-01-01,Outer Richmond,144 | |
1997-01-01,Tenderloin,56 | |
1997-01-01,Financial District/South Beach,6 | |
1997-01-01,Excelsior,56 | |
1997-01-01,Presidio Heights,36 |
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
/* | |
Cloning dplyr in Javascript, sort of | |
==================================== | |
Works on arrays of objects. | |
usage: | |
var transformation = DS.data(arrayOfObjects) | |
.standardize() |
OlderNewer