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 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'] |
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 | |
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): |
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 | |
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.
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 | |
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.
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 | |
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.
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 | |
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 |