Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/all_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
}
}
"""]
print all_pairs(catalogue)
print all_pairs(catalogue, parallel=True)
print all_pairs(catalogue, distance=distances.kolmogorov)
print(all_pairs(catalogue))
print(all_pairs(catalogue, parallel=True))
print(all_pairs(catalogue, distance=distances.kolmogorov))

# Example code for loading a pickle file of submissions

Expand Down
10 changes: 7 additions & 3 deletions examples/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

from ripoff import all_pairs, distances
from ripoff.clustering import cluster
import urllib2
import hcluster
import pylab

try:
import urllib.request as liburl
except ImportError:
import urllib2 as liburl

# some famous German literature
urls = [("http://www.gutenberg.org/files/21000/21000-0.txt", "Faust 1"),
("http://www.gutenberg.org/cache/epub/2230/pg2230.txt", "Faust 2"),
Expand All @@ -40,8 +44,8 @@

for url, name in urls:
headers = {'User-Agent': 'Mozilla/5.0'}
req = urllib2.Request(url, None, headers)
catalogue.append(urllib2.urlopen(req).read())
req = liburl.Request(url, None, headers)
catalogue.append(liburl.urlopen(req).read())

# calc similarity matrix
M = all_pairs(catalogue,
Expand Down
12 changes: 5 additions & 7 deletions ripoff/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@
@author: moschlar
'''

try:
import cStringIO as StringIO
except ImportError:
import StringIO
from io import StringIO

import pylab
import hcluster


def cluster(M, method='complete'):
return hcluster.linkage(hcluster.squareform(M), method=method)


def dendrogram(M, method='complete', title='complete linkage clustering', **kw):
s = StringIO.StringIO()

import pylab

s = StringIO()
pylab.figure()
if title:
pylab.title(title)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: BSD License",
],
install_requires=['numpy', 'hcluster', 'matplotlib'],
install_requires=['numpy', 'dedupe-hcluster', 'matplotlib'],
)