Git Product home page Git Product logo

Comments (6)

ocelma avatar ocelma commented on July 30, 2024

Hi,

You don't need this code bit:

from recsys.utils.svdlibc import SVDLIBC
svdlibc = SVDLIBC('/usr/local/python-recsys-master/recsys/data/movielens/ratings.dat')
svdlibc.to_sparse_matrix(sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
svdlibc.compute(k=100)
svd = svdlibc.export()

svd can be created using either divisi2 SVD (default), or by calling SVDLIBC, the external C library, that runs faster, and uses less memory.

Looking at your code, you're doing both things, and you only need to do one.
You can have a look here for (quick start example): http://ocelma.net/software/python-recsys/build/html/quickstart.html (step 8 is an alternative version of step 2).

I hope this helps!

from python-recsys.

cycchao avatar cycchao commented on July 30, 2024

thank you very much!another question...now i get the svd model and i save it to '/tmp/Svd_model'

how could i get the RMSE and MAE of this model?under the path /python-recsys-master/python-recsys-master/draft,there is a code named test_svd.py ,but everytime i run it ,there is no result in a long time....Is there alternate way to get the model's Evaluation?thanks a lot for you kindly reply!

from python-recsys.

ocelma avatar ocelma commented on July 30, 2024

Regarding your RMSE and MAE question, try this:

#Evaluation using prediction-based metrics
rmse = RMSE()
mae = MAE()
for rating, item_id, user_id in test.get():
    try:
        pred_rating = svd.predict(item_id, user_id)
        rmse.add(rating, pred_rating)
        mae.add(rating, pred_rating)
        print 'RMSE=%s' % rmse.compute()
        print 'MAE=%s' % mae.compute()
    except KeyError:
        continue

print 'Final RMSE=%s' % rmse.compute()
print 'Final MAE=%s' % mae.compute()

from python-recsys.

cycchao avatar cycchao commented on July 30, 2024

According to your guide,i write a code named MySVDNeiStart.py,in order to compute the RMSE and MAE of My SVD++ Model,but After 30 minutes ,it still has no result,could you help me?

import recsys.algorithm
from recsys.algorithm.factorize import SVD,SVDNeighbourhood
from recsys.datamodel.data import Data
recsys.algorithm.VERBOSE = True
filename = '/usr/local/python-recsys-master/recsys/data/movielens/ratings.dat'
data = Data()
format = {'col':0, 'row':1, 'value':2, 'ids': int}
data.load(filename, sep='::', format=format)
train, test = data.split_train_test(percent=80) # 80% train, 20% test

svd = SVDNeighbourhood()
svd.set_data(train)
svd.compute(k=100, min_values=5, pre_normalize=None, mean_center=True, post_normalize=True, savefile='/tmp/svd_neig')

#Evaluation using prediction-based metrics

from recsys.algorithm.factorize import SVD
from recsys.evaluation.prediction import RMSE, MAE
rmse = RMSE()
mae = MAE()
for rating, item_id, user_id in test.get():
try:
pred_rating = svd.predict(item_id, user_id)
rmse.add(rating, pred_rating)
mae.add(rating, pred_rating)
except KeyError:
continue

print 'Final RMSE=%s' % rmse.compute()
print 'Final MAE=%s' % mae.compute()

from python-recsys.

thuvh avatar thuvh commented on July 30, 2024

instead writing a single file to run, i use python console to check code. It work perfect like charm 💯

from python-recsys.

ocelma avatar ocelma commented on July 30, 2024

Perfect. Glad to hear that it worked fine!

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.