This file contains 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
source "https://rubygems.org" | |
gem "rails", "~> 4.2" | |
gem "rails_admin" | |
gem "pg" |
This file contains 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
% Experiments on 5% of the data | |
% Parralellisation 8 workers 4 cores with hyperthreading | |
>> tic; trainLFM(P, 10, 1, 1); toc | |
Elapsed time is 150.857689 seconds. | |
>> tic; trainLFM(P, 100, 1, 1); toc | |
Elapsed time is 2153.943994 seconds. | |
% Just threads |
This file contains 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
function [X,Y] = trainLFM(P, f, alpha, lambda) | |
%trainLFM Trains Latent Factor Model for CF with implicit feedback | |
% Takes a playcount matrix P and its parameters alpha and lambda. | |
% and uses the C_{u,s} = 1 + \alpha P_{u,s} as confidence model | |
[num_users, num_songs] = size(P); | |
% Initialize decomposisiton X and Y with values from 0 to 1 | |
X = rand(num_users, f); | |
Y = rand(num_songs, f); |
This file contains 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 | |
from collections import namedtuple | |
from collections import defaultdict | |
import numpy as np | |
import logging | |
from progress_bar import ProgressBar | |
ArtistTermFreq = namedtuple('ArtistTermFreq', ['artist_id', 'term', 'freq']) | |
class ArtistTermFreqIterator: |
This file contains 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
from collections import namedtuple | |
from collections import defaultdict | |
ArtistTermFreq = namedtuple('ArtistTermFreq', ['artist_id', 'term', 'freq']) | |
class ArtistTermFreqIterator: | |
def __init__(self, artist_term_file, artist_collection, term_collection): | |
self.term_file = artist_term_file | |
self.artist_indexes = self._create_artist_indexes(artist_collection) | |
self.track_index = self._create_track_reverse_mapping() |
This file contains 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
#!/usr/bin/env python3 | |
import os | |
import sys | |
import tables | |
import numpy as np | |
from scipy import sparse | |
from scipy import io | |
from collections import defaultdict | |
from multiprocessing import Queue, Process |
This file contains 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
#!/usr/bin/env python3 | |
import os | |
import sys | |
import tables | |
import numpy as np | |
TASTE_PROFILE_FILE = os.path.abspath(sys.argv[1]) | |
TASTE_PROFILE_STATISTICS_FILE = os.path.abspath(sys.argv[2]) |
This file contains 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 | |
import scipy.io | |
import scipy.linalg | |
import scipy.sparse.linalg; | |
import numpy | |
import matplotlib.pyplot | |
def relative_residual(U, z): | |
m, n = U.shape | |
return numpy.linalg.norm((numpy.eye(m) - U.dot(U.T)).dot(z)) / numpy.linalg.norm(z) |
This file contains 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
# Load data | |
import re | |
import scipy.io | |
import scipy.linalg | |
import scipy.sparse.linalg; | |
import numpy | |
import matplotlib.pyplot | |
def relative_residual(U, z): |
NewerOlder