Skip to content

Instantly share code, notes, and snippets.

View yamaguchiyuto's full-sized avatar

Yuto Yamaguchi yamaguchiyuto

View GitHub Profile
@yamaguchiyuto
yamaguchiyuto / extract_nouns.py
Created June 17, 2013 03:00
Extracting nouns from specified text using python and nltk.
import nltk
text_str = "I have written this book and these papers."
text = nltk.word_tokenize(text_str)
result = nltk.pos_tag(text)
nouns = [r[0] for r in result if r[1] == 'NN' or r[1] == 'NNS']
import numpy as np
from scipy import linalg,sparse,random
class RESCAL:
def __init__(self,r,lamb_A,lamb_R):
self.r = r
self.lamb_A = lamb_A
self.lamb_R = lamb_R
def fit(self,X,niter=30):
@yamaguchiyuto
yamaguchiyuto / predict.py
Created February 23, 2016 23:51
Reproducing TransE experiments [NIPS'13]
import sys
import pickle
import numpy as np
import pandas as pd
from transe import TRANSE
modelfilepath = sys.argv[1]
h = sys.argv[2]
r = sys.argv[3]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
class CPALS:
def __init__(self,k,lamb,max_iter):
self.k=k
self.lamb=lamb
self.max_iter=max_iter
def _calc_data_shape(self,X):
max_i = -1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
class Tucker:
def __init__(self,R,S,T,max_iter):
self.latent_size = (R,S,T)
self.max_iter=max_iter
def _calc_data_shape(self,X):
max_i = -1
max_j = -1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yamaguchiyuto
yamaguchiyuto / dpgmm.py
Created March 13, 2017 14:26
Dirichlet Process Gaussian Mixture Model
import numpy as np
class DPGMM:
def __init__(self,alpha=1,mu0=0,rho0=1,a0=1,b0=1,max_iter=30):
self.alpha = alpha
self.mu0=mu0
self.rho0=rho0
self.a0=a0
self.b0=b0
self.max_iter=max_iter