def naive_CBF(): dm = build_data.build_urm() target = build_data.loadTarget() rec = r.CBF_coldstart(k=50) rec.fit() recommended = rec.recommendAll(target, 10) playlists = recommended[:, 0] recommended = numpy.delete(recommended, 0, 1) i = 0 res_fin = [] for j in recommended: res = '' for k in range(0, len(j)): res = res + '{0} '.format(j[k]) res_fin.append(res) i = i + 1 d = {'playlist_id': playlists, 'track_ids': res_fin} df = pandas.DataFrame(data=d, index=None) df.to_csv("../results/recommended9.csv", index=None) i = 1 + 1
def __init__(self, features): self._lambda = 0.1 self._alpha = 40 self._URM = bd.build_urm().tocsr() self._users = self._URM.shape[0] self._items = self._URM.shape[1] self._X = sps.csr_matrix(np.random.normal(size=(self._users, features))) self._Y = sps.csr_matrix(np.random.normal(size=(self._items, features))) self._X_I = sps.eye(self._users) self._Y_I = sps.eye(self._items) self._I = sps.eye(features) self._II = self._I * self._lambda self._xTx = self._X.T.dot(self._X) self._Cui = self._URM * self._alpha self._ALS_ITERS = 100
def __init__(self, k, coldstart=10): self._coldstart = coldstart self._cbf = CBF_Item_Naive(k) self._URM = bd.build_urm().tocsr() self._toppop = TopPop()
def __init__(self, k): self._cosine = sim.Cosine_Similarity(bd.build_icm(), k) self.URM = bd.build_urm() self._k = k