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 sys | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from sklearn import grid_search | |
| from oreore_ridge import RidgeRegression | |
| def psi(xlist,M): | |
| """ make a design matrix """ | |
| ret = [] | |
| for x in xlist: |
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 sys | |
| import numpy as np | |
| from sklearn import cross_validation | |
| from oreore_ridge import RidgeRegression | |
| def psi(xlist,M): | |
| """ make a design matrix """ | |
| ret = [] | |
| for x in xlist: | |
| ret.append([x**i for i in range(0,M+1)]) |
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 re | |
| def remove_usernames_and_urls(text): | |
| username_removed_text = re.sub('@\w+', '', text) # remove usernames | |
| return re.sub('(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)', '', username_removed_text) # remove urls |
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 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 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 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] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 |