GithubHelp home page GithubHelp logo

Comments (18)

Sandy4321 avatar Sandy4321 commented on June 8, 2024

I try to run test case, to learn how it works, do you have more examples?

from flurs.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

Anaconda2\Lib\site-packages\flurs\evaluator.py", line 7, in
from . import logger

ValueError: Attempted relative import in non-package

from flurs.

takuti avatar takuti commented on June 8, 2024

@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.

takuti avatar takuti commented on June 8, 2024

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.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

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.

takuti avatar takuti commented on June 8, 2024

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.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

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.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

by the way , may you share this paper Sketching Dynamic Interactions for Online Item Recommendation "User Item" filetype:pdf pls?

from flurs.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

my email [email protected]
thanks

from flurs.

takuti avatar takuti commented on June 8, 2024

You are right; Q is an item matrix.

Sent the paper to your email.

from flurs.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

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.

takuti avatar takuti commented on June 8, 2024

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.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

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.

takuti avatar takuti commented on June 8, 2024

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.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

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.

Sandy4321 avatar Sandy4321 commented on June 8, 2024

as example to compare with http://surpriselib.com/

from flurs.

takuti avatar takuti commented on June 8, 2024

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.

takuti avatar takuti commented on June 8, 2024

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)

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.