def pd(self, t_):
		r = []
		for i, c in zip(t_.ti, t_.c):
			if i in self.be:
				r.append(self.be[i])
			else:
				r.append(to_wv(self.m.pd(c), e_cv.v))
		return r
	def be_load(self):
		p = os.path.join(m.dd, "be_{}.npy".format(self.ds))
		if os.path.exists(p):
			e_ = np.load(p)
			print("ld:" + p)
		else:
			m_ = m()
			e_ = np.array([to_wv(m_.pd(i), e_cv.v) for i in dt.t.c])
			np.save(p, e_)

		self.be = {}
		for i, v in zip(dt.t.ti, e_):
			self.be[i] = v
Exemplo n.º 3
0
    def init(self):
        self.sr = sr(self)
        self.q_ = [q(c=0, u=0, l=[0.0, 0.0], z=[0.0])]

        t_ = t()  # e
        ec = de.to_t(self.e.c[0])
        t_.c_(np.array([ec]))
        t_.c2_(np.array([to_wv(ec, t_cv.v)]))
        self.t_ = [t_]

        self.d = {}
        self.d_ = [0.0]
        self.l = 0
Exemplo n.º 4
0
from d.d import d, ds
from d.t import t
from d.g.wv import e_cv, to_wv
from d.ul import c_sim
from rw.be_.m import m
from z2.ul import ndcg

np.set_printoptions(precision=3)

x = t(np.load(os.path.join(ds, "t_test.npy")))
g = d.te_g

m_ = m()
x2 = []
for i in x.c:
    x2.append(to_wv(m_.pd(i), e_cv.v))

top = 500
r = []
for g_, a in zip(g.c2, g.ei):
    s = {i: c_sim(g_, x2[i]) for i in range(len(x2))}
    o = sorted(s, key=s.get, reverse=True)  # max
    s2 = (x.ei[o] == a) * 1

    r_ = []
    for k in range(1, top + 1):
        r_.append(ndcg(s2, k))

    #print("@{} {}".format(10, r_[10-1]))
    r.append(r_)
print("{}".format(np.mean(np.array(r), axis=0)[[5, 10, 60]].tolist()))
import numpy as np
import os
from d.d import d, ds
from d.t import t
from d.de import de
from d.g.wv import t_cv, to_wv
from d.ul import c_sim
from z2.ul import ndcg, ndcg_k
np.set_printoptions(precision=3)

x = t(np.load(os.path.join(ds, "t_test.npy")))
g = d.te_g

top = 500
r = []
for g_, a in zip(g.c, g.ei):
    ec = to_wv(de.to_t(g_), t_cv.v)

    s = {i: c_sim(ec, x.c2[i]) for i in range(len(x.v))}
    o = sorted(s, key=s.get, reverse=True)  # max
    s2 = (x.ei[o] == a) * 1

    r_ = []
    for k in range(1, top + 1):
        r_.append(ndcg_k(s2, k))

    #print("@{} {}".format(10, r_[10-1]))
    r.append(r_)
print("{}".format(np.mean(np.array(r), axis=0)[[5, 10, 60]].tolist()))
Exemplo n.º 6
0
 def d_u(self, t_, t2_):
     v1 = to_wv(t_.u_m(), t_uv.v)
     v2 = to_wv(t2_.u_m(), t_uv.v)
     return dis(v1, v2)
Exemplo n.º 7
0
 def d_c(self, t_, t2_):
     v1 = to_wv(t_.c_m(), t_cv.v)
     v2 = to_wv(t2_.c_m(), t_cv.v)
     return dis(v1, v2)
	def __init__(self, p):
		self.p = p
		self.c = {}
		self.ec = to_wv(de.to_t(self.p.e.c[0]), t_cv.v)