Skip to content

Instantly share code, notes, and snippets.

View yamaguchiyuto's full-sized avatar

Yuto Yamaguchi yamaguchiyuto

View GitHub Profile
@yamaguchiyuto
yamaguchiyuto / btree.hs
Last active November 1, 2023 03:07
Haskell B-tree implementation
data Tree a = Nil Int | Leaf Int [a] | Node Int [a] [Tree a] deriving Show
find :: (Ord a, Eq a) => Tree a -> a -> Bool
find (Nil _) _ = False
find (Leaf _ []) _ = False
find (Leaf m (k:ks)) x
| x == k = True
| x < k = False
| x > k = find (Leaf m ks) x
find (Node _ [] (t:ts)) x = find t x
@yamaguchiyuto
yamaguchiyuto / probabilistic_matrix_factorization.ipynb
Last active September 25, 2017 06:47
Probabilistic matrix factorization using Edward
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.
@yamaguchiyuto
yamaguchiyuto / atm.py
Last active April 13, 2019 10:15
Author Topic Model
import random
import copy
import numpy as np
from scipy.sparse import lil_matrix
class ATM:
def __init__(self, K, alpha, beta, max_iter, verbose=0):
self.K=K
self.alpha = alpha
self.beta = beta
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yamaguchiyuto
yamaguchiyuto / nctm.py
Created March 22, 2017 00:00
Noisy Correspondence Topic Model
import random
import numpy as np
from scipy.sparse import lil_matrix
class NCTM:
def __init__(self, K, alpha, beta, gamma, eta, max_iter, verbose=0):
self.K=K
self.alpha = alpha
self.beta = beta
self.gamma = gamma
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yamaguchiyuto
yamaguchiyuto / ctm.py
Created March 21, 2017 07:27
Correspondence Topic Model
import random
import numpy as np
from scipy.sparse import lil_matrix
class CTM:
def __init__(self, K, alpha, beta, gamma, max_iter, verbose=0):
self.K=K
self.alpha = alpha
self.beta = beta
self.gamma = gamma
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yamaguchiyuto
yamaguchiyuto / jtm.py
Last active May 25, 2020 05:16
Joint Topic Models
import random
import numpy as np
from scipy.sparse import lil_matrix
class JTM:
def __init__(self, K, alpha, beta, max_iter, verbose=0):
self.K=K
self.alpha = alpha
self.beta = beta
self.max_iter = max_iter