Comments (2)
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.
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)
- SVD.compute() kernel fail on Windows HOT 4
- SVD.similar() user or item HOT 2
- Python 3 support HOT 1
- replace csc-pyparse with SciPy HOT 3
- Multiple Values HOT 1
- Can't install csc HOT 2
- How to increase the number of similarity/recommending item results HOT 2
- Getting error while laoding the data. HOT 2
- RuntimeWarning: invalid value encountered in divide ----Special characters in user_id HOT 4
- x Neighbours in svd.recommend HOT 1
- ImportError: No module named algorithm HOT 1
- IndexError: Error creating second index list HOT 2
- Can we load data using pandas dataframe? HOT 1
- AveragePrecision in recsys.evaluation.ranking HOT 1
- Storing results for all dataset in json file HOT 1
- Working with csv HOT 1
- how to install in python3? HOT 2
- Divisi2 what/where is it ? HOT 1
- Which version of Python is used HOT 2
- `recsys` package ownership on PyPI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-recsys.