Comments (18)
I try to run test case, to learn how it works, do you have more examples?
from flurs.
Anaconda2\Lib\site-packages\flurs\evaluator.py", line 7, in
from . import logger
ValueError: Attempted relative import in non-package
from flurs.
@Sandy4321 Thanks for report. Could you describe the detail of what you did? On my local Python 2 (anaconda2-4.3.1) environment, I cannot see any import-related problems:
$ pip --version
pip 9.0.1 from /path/to/home/.pyenv/versions/anaconda2-4.3.1/lib/python2.7/site-packages (python 2.7)
$ pip install flurs
$ python
Python 2.7.13 |Anaconda 4.3.1 (x86_64)| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from flurs.data.entity import User, Item, Event
>>> user = User(0)
>>> item = Item(0)
>>> event = Event(user, item)
And CI including unit tests on Python2 successfully passes: https://travis-ci.org/takuti/flurs
from flurs.
Sorry about poor examples; I would add more examples and better documentation in the future.
For now, you may refer to an introductory notebook and repository (experiment.py
) which uses this package for the purpose of research experiments.
from flurs.
super , thanks I try to run this notebook, all runs perfect - no errors , but this lines
plt.plot(accuracy)
plt.xlabel('sample index (time)')
plt.ylabel('recall (window size = 200)')
give only straight line, may you help pls?
pls see in attachment pfd file with notebook copy
euroscipy_2017_jan22.pdf
from flurs.
Ah, the notebook assumes Python 3; if you are using Python 2, modify:
accuracy = []
for top_score, rank, recommend_time, update_time in evaluator.evaluate(events[300:]):
window.append(int(rank < 10)) # consider top-10 recommendation
accuracy.append(sum(window) / len(window))
to:
accuracy = []
for top_score, rank, recommend_time, update_time in evaluator.evaluate(events[300:]):
window.append(int(rank < 10)) # consider top-10 recommendation
accuracy.append(sum(window) / float(len(window)))
Even though accuracy should be float, sum(window) / len(window)
rounds the value to integer in Python 2.
from flurs.
super thanks , will try
by the way
this line
P[user], Q[user] = next_p, next_q
should it be
P[user], Q[item] = next_p, next_q
since matrix Q is matrix of items?
thanks
from flurs.
by the way , may you share this paper Sketching Dynamic Interactions for Online Item Recommendation "User Item" filetype:pdf pls?
from flurs.
my email [email protected]
thanks
from flurs.
You are right; Q is an item matrix.
Sent the paper to your email.
from flurs.
regarding to what was written above
the problem is
when I run file evaluator.py from flurs package
there is error in line from . import logger
Anaconda2\Lib\site-packages\flurs\evaluator.py", line 7, in
from . import logger
ValueError: Attempted relative import in non-package
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
D:\Factorisatoin_Machines\code\flurs_master_Jan21>pip --version
pip 9.0.1 from c:\users\sanderoct27\anaconda2\lib\site-packages (python 2.7)
D:\Factorisatoin_Machines\code\flurs_master_Jan21>pip install flurs
Requirement already satisfied: flurs in c:\users\sanderoct27\anaconda2\lib\site-
packages
Requirement already satisfied: scikit-learn in c:\users\sanderoct27\anaconda2\li
b\site-packages (from flurs)
Requirement already satisfied: numpy in c:\users\sanderoct27\anaconda2\lib\site-
packages (from flurs)
Requirement already satisfied: mmh3 in c:\users\sanderoct27\anaconda2\lib\site-p
ackages (from flurs)
Requirement already satisfied: scipy in c:\users\sanderoct27\anaconda2\lib\site-
packages (from flurs)
D:\Factorisatoin_Machines\code\flurs_master_Jan21>python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jun 29 2016, 11:07:13) [MSC
v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
hopefully now I put enough details to explain
by the way how to run flurs for python 3 ?
from flurs.
when I run file evaluator.py from flurs package
How did you call the module? Could you provide code you executed?
As the notebook suggests, even in Python 2, I have confirmed that evaluator can be successfully loaded as:
from flurs.evaluator import Evaluator
evaluator = Evaluator(recommender)
...
For Python 3, there is no difference; currently, FluRS supports both Python 2.7 and 3.4+ as much as I can, and hence you can use this library in a similar way to what you are now doing in Python 2.
from flurs.
hello
problem not in
calling Evaluator as you describe
from flurs.evaluator import Evaluator
evaluator = Evaluator(recommender)
work without error
but if I use this file
evaluator.py
stand alone , then
this line
from . import logger
the error message is
Anaconda2\Lib\site-packages\flurs\evaluator.py", line 7, in
from . import logger
may I just can not run this file
evaluator.py
but should call it from another code
from flurs.
In fact, since FluRS is standard python library, such usage is not expected.
But, if you remove from . import logger
and logger.xxx
lines from evaluation.py as workaround, your problem should be resolved; the error is just related to logging code, so there is no negative effect on the behavior of evaluatior.py.
from flurs.
I see thanks a lot, i am going to learn how it works , do you have simple example like https://github.com/takuti/stream-recommender/tree/master/config
but only not for streamed data, but for static data. Meaning to read data from LastFM or ML1M and to get recommendation and some score how good it works? and compare for example to svd?
Thanks a lot for help
from flurs.
as example to compare with http://surpriselib.com/
from flurs.
flurs/examples/movielens1m.py
provides an example of how to use this package, and, if you are interested in non-streamed recommendation, you simply need to call evaluator.fit
for all batch samples; that is,
stream:
evaluator = Evaluator(rec, data.can_repeat)
n_batch_train = int(data.n_sample * 0.2) # 20% for pre-training to avoid cold-start
n_batch_test = int(data.n_sample * 0.1) # 10% for evaluation of pre-training
batch_tail = n_batch_train + n_batch_test
# pre-train
# 20% for batch training | 10% for batch evaluate
# after the batch training, 10% samples are used for incremental updating
logging.info('batch pre-training before streaming input')
evaluator.fit(
data.samples[:n_batch_train],
data.samples[n_batch_train:batch_tail],
n_epoch=1 # single pass even for batch training
)
# 70% incremental evaluation and updating
logging.info('incrementally predict, evaluate and update the recommender')
res = evaluator.evaluate(data.samples[batch_tail:])
batch:
evaluator = Evaluator(rec, data.can_repeat)
n_batch_train = int(data.n_sample * 0.8) # 80% for training
# batch-train for all samples
# 80% for batch training | 20% for batch evaluate
logging.info('batch pre-training before streaming input')
evaluator.fit(
data.samples[:n_batch_train],
data.samples[n_batch_train:],
n_epoch=100 # set number of iterations as you want
)
In my Factorization Machines paper, evaluation has been conducted for both incremental (i.e., stream) and static (i.e., batch) model. You can also refer to the methodology.
from flurs.
The topic above is now different from the original one error : ValueError: Attempted relative import in non-package
, so I close this issue for now. If you have further questions, open another issue.
from flurs.
Related Issues (13)
- regularization for FM HOT 4
- TypeError: no supported conversion for types: (dtype('<U32'),) HOT 4
- Type statically and validate with `mypy`
- Add examples with non-MovieLens positive-only feedback data
- Revising project paths
- Benchmark with alternative recommender libraries (in a static setting)
- error while running import nltk HOT 4
- error installing on windows computer and python 3 HOT 1
- Setup CI for Windows
- error running movielens1m.py HOT 9
- updated are not on pip for appveyor and etc HOT 1
- Support creating User/Item object from arbitrary ID, rather than sequential index HOT 1
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 flurs.