Visulalize authors relationships based upon not-hiragana-kanji rubis on Aozorabunko.
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 python | |
# -*- coding:utf-8 -*- | |
''' | |
正準相関分析 | |
cca.py | |
''' | |
import numpy as np | |
import scipy as sp | |
from scipy import linalg as LA |
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
# http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html | |
from scipy.spatial.distance import squareform, pdist | |
def test_distance(): | |
X = [[2,3,4],[0,0,0],[1,1,1],[2,2,2]] | |
print pdist(X, 'euclidean') | |
print squareform(pdist(X, 'euclidean')) | |
print squareform(pdist(X, polynomial_kernel)) | |
test_distance() |
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
# -*- coding:utf-8 -*- | |
from pymongo import MongoClient | |
client = MongoClient() | |
db = client.xvideos | |
def create_db(): | |
f = open('xvideos.com-db.csv') | |
for line in f: |
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
('blowjob', 'hardcore') 594241 | |
('blowjob', 'brunette') 336485 | |
('blowjob', 'teen') 334746 | |
('amateur', 'teen') 322670 | |
('brunette', 'hardcore') 320892 | |
('hardcore', 'teen') 302974 | |
('blonde', 'brunette') 282348 | |
('blonde', 'blowjob') 272567 | |
('blowjob', 'oral') 269461 | |
('blonde', 'hardcore') 252474 |
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 random | |
def sort_test(): | |
a = [random.random() for i in range(100)] | |
b = [random.random() for i in range(100)] | |
c = dict(zip(a, b)) | |
sorted(c, key=c.get) |
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
Amateur | |
Anal | |
Anime | |
Asian Woman | |
Ass | |
Ass to Mouths | |
BDSM | |
Big Ass | |
Big Cock | |
Big Tits |
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 python | |
# -*- coding:utf-8 -*- | |
''' | |
まとめサイトなどURLに含まれるYouTubeをプレイリストに保存する | |
$ python youtube_gdata_playlist.py http://... | |
''' | |
# 以下要設定 | |
# cf. YouTubeクライアント |
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 python | |
# -*- coding:utf-8 -*- | |
''' | |
try some parameters. | |
$ python params_test.py | |
[0, -1] | |
False | |
[0, 0] | |
False |
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 python | |
# -*- coding:utf-8 -*- | |
# Viterbi algorithm | |
# http://en.wikipedia.org/wiki/Viterbi_algorithm | |
# | |
# > python viterbi.py | |
# 0 1 2 | |
# Rainy: 0.06000 0.03840 0.01344 | |
# Sunny: 0.24000 0.04320 0.00259 | |
# (0.01344, ['Sunny', 'Rainy', 'Rainy']) |