GithubHelp home page GithubHelp logo

Comments (2)

ocelma avatar ocelma commented on May 26, 2024

Once you've created the model, and stored it in disk, you can load the SVD model again, but (unfortunately) this does not load the original input matrix, as this takes much time.

The only way for you to do so would be to load the data again from the raw file. Something like:

svd = SVD(filename=sFileTarget) # Loading already computed SVD model
svd.load_data(filename=sFileSource, sep=',', format=dictFormat) # Re-load the matrix each time!
svd.create_matrix() # And (re)create it
(...)

from python-recsys.

jmadison222 avatar jmadison222 commented on May 26, 2024

Great thanks for the reply. Makes sense. And that's still a big lift since compute() is the more time consuming. But now I get this error:

/appl/build/anaconda/lib/python2.7/site-packages/csc_utils/ordered_set.pyc in __getitem__(self, index)
     50         else:
     51             # assume it's a fancy index list
---> 52             return OrderedSet([self.items[i] for i in index])
     53 
     54     def copy(self):

IndexError: list index out of range

Where the code I have is this:

from recsys.algorithm.factorize import SVD
svd = SVD(filename=sFileTarget) # Loading already computed SVD model
svd.load_data(filename=sFileSource, sep=',', format=dictFormat)
svd.create_matrix()
setCustIDs = set([x[2] for x in svd.get_data().get()[0:100]]) # Get some sample customer IDs
print(setCustIDs)
[(x, svd.recommend(x, n=3, is_row=False, only_unknowns=True)) for x in setCustIDs]

Such that the last line works fine if I do the full compute. That is, this code works:

sFileSource = '/appl/cwa/data/cov_100k.out'
sFileTarget = '/appl/cwa/data/coverage.model'
# dictFormat = {'col':0, 'row':1, 'value':2, 'ids': int}
dictFormat = {'col':0, 'row':1, 'value':2}

import recsys.algorithm
recsys.algorithm.VERBOSE = True
from recsys.algorithm.factorize import SVD
svd = SVD()
svd.load_data(filename=sFileSource, sep=',', format=dictFormat)
k = 5 # Number of clusters
svd.compute(
    k=k, min_values=3, pre_normalize=None, 
    mean_center=False,
    post_normalize=True, savefile=sFileTarget
)
print(svd.get_data().get()[0:5]) # Look at data for sanity check.
setCustIDs = set([x[2] for x in svd.get_data().get()[0:100]]) # Get some sample customer IDs
print(setCustIDs) 
[(x, svd.recommend(x, n=3, is_row=False, only_unknowns=True)) for x in setCustIDs]

And both the working and non-working code are getting the same customer IDs for that print statement:

set([33, 195, 262, 198, 266, 285, 144, 254, 222, 215, 218, 123, 61, 126, 63])

Thoughts?

from python-recsys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.