コード例 #1
0
ファイル: lr_lastfm.py プロジェクト: shy218/MorpheusPy
def one_run_m():
    print "start materialized regression"
    m_regressor = NormalizedLogisticRegression()
    start = time.time()
    m_regressor.fit(T, Y, w_init=w_init)
    end = time.time()
    print "end materialized regression"
    return end - start
コード例 #2
0
ファイル: lr_lastfm.py プロジェクト: shy218/MorpheusPy
def one_run_n():
    print "start factorized regression"
    n_regressor = NormalizedLogisticRegression()
    start = time.time()
    n_regressor.fit(normalized_matrix, Y, w_init=w_init2)
    end = time.time()
    print "end factorized regression"

    return end - start
コード例 #3
0
ファイル: lr_movie.py プロジェクト: shy218/MorpheusPy
print T.shape

w_init = np.matrix(np.random.randn(T.shape[1], 1))
w_init2 = np.matrix(w_init, copy=True)
gamma = 0.000001
iterations = 20
result_eps = 1e-6

print "start factorized matrix"
normalized_matrix = nm.NormalizedMatrix(s, [r1, r2], k)
print "end factorized matrix"

import time

print "start materialized regression"
m_regressor = NormalizedLogisticRegression()
start = time.time()
m_regressor.fit(T, Y, w_init=w_init)
end = time.time()
print "end materialized regression"
m_time = end - start

print "start factorized regression"
n_regressor = NormalizedLogisticRegression()
start = time.time()
n_regressor.fit(normalized_matrix, Y, w_init=w_init2)
end = time.time()
print "end factorized regression"

n_time = end - start
print "speedup is", m_time / n_time
コード例 #4
0
        dr = ds * f
        ns = nr * t

        s = np.random.rand(ns, ds)
        r = [np.random.rand(nr, dr)]
        num = np.random.randint(nr, size=ns)
        while (max(num) != nr - 1):
            num = np.random.randint(nr, size=ns)
        k = [num]
        T = np.mat(np.hstack((s, r[0][k[0]])))
        Y = np.matrix(np.random.randint(2, size=ns)).T
        normalized_matrix = nm.NormalizedMatrix(s, r, k)
        avg = []
        for _ in range(trails):
            w_init_m = np.matrix(np.random.randn(T.shape[1], 1))
            m_regressor = NormalizedLogisticRegression()
            m_start = time.time()
            m_regressor.fit(T, Y, w_init=w_init_m)
            m_end = time.time()

            w_init_n = np.matrix(np.random.randn(T.shape[1], 1))
            n_regressor = NormalizedLogisticRegression()
            n_start = time.time()
            n_regressor.fit(normalized_matrix, Y, w_init=w_init_n)
            n_end = time.time()
            avg.append((m_end - m_start) / (n_end - n_start))

        print(sum(avg) - min(avg) - max(avg)) / (trails - 2)
        result.append((sum(avg) - min(avg) - max(avg)) / (trails - 2))
    total.append(result)