Giter VIP home page Giter VIP logo

orange3-recommendation's Introduction

Orange3-Recommendation

Build Status codecov Documentation Status Codacy Badge

Orange3 Recommendation is a Python module that extends Orange3 to include support for recommender systems.

For more information, see our documentation

Dependencies

Orange3-Recommendation is tested to work under Python 3.

The required dependencies to build the software are Numpy >= 1.9.0 and Scikit-Learn >= 0.16

Install

This package uses distutils, which is the default way of installing python modules. To install in your home directory, use:

python setup.py install --user

To install for all users on Unix/Linux::

python setup.py build
sudo python setup.py install

For development mode use:

python setup.py develop

Scripting

All modules can be found inside orangecontrib.recommendation.*. Thus, to import all modules we can type:

from orangecontrib.recommendation import *

Rating pairs (user, item):

Let's presume that we want to load a dataset, train it and predict its first three pairs of (id_user, id_item)

import Orange
from orangecontrib.recommendation import BRISMFLearner
data = Orange.data.Table('movielens100k.tab')
learner = BRISMFLearner(num_factors=15, num_iter=25, learning_rate=0.07, lmbda=0.1)
recommender = learner(data)
prediction = recommender(data[:3])
print(prediction)
>>> [ 3.79505151  3.75096513  1.293013 ]

Recommend items for set of users:

Now we want to get all the predictions (all items) for a set of users:

import numpy as np
indices_users = np.array([4, 12, 36])
prediction = recommender.predict_items(indices_users)
print(prediction)
>>> [[ 1.34743879  4.61513578  3.90757263 ...,  3.03535099  4.08221699 4.26139511]
     [ 1.16652757  4.5516808   3.9867497  ...,  2.94690548  3.67274108 4.1868596 ]
     [ 2.74395768  4.04859096  4.04553826 ...,  3.22923456  3.69682699 4.95043435]]

Performance

See performance section in the documentation.

Relevant links

orange3-recommendation's People

Contributors

lanzagar avatar mstrazar avatar robertcv avatar salvacarrion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orange3-recommendation's Issues

New widget to plot the training loss

Usually is a good practice to analyze the evolution of the loss to understand how the model is being optimised. To achieve this, we can either output the loss as an array when the training finish or send it to the chart in a online way, having the possibility to stop the training at any given moment.
main-qimg-d23fbbc85b7d18b4e07b7942ecdfd856

SVDPlusPlusLearner traninng diverge error

Recommendation version

latest

Orange version

3.27.1

Expected behavior

(Print on screen)
[0.98389692 1.01224489 1.0078577 ]

Steps to reproduce the behavior

import Orange
from orangecontrib.recommendation import SVDPlusPlusLearner, BRISMFLearner

#Load data and train the model
data = Orange.data.Table('movie_lens/epinions_train.tab')
learner = SVDPlusPlusLearner(num_factors=15, num_iter=25, learning_rate=0.07, lmbda=0.1)
recommender = learner(data)

#Make predictions
prediction = recommender(data[:3])
print(prediction)

Actual behavior

RuntimeError: Training diverged and returned NaN.

Additional info (worksheets, data, screenshots, ...)

data are from the dataset folder of the recommendation package; placed at a subfolder "movie_lens" in the path of the script; actually any of the datafile causes the same error. using BRIMSFLearner works.
https://github.com/biolab/orange3-recommendation/blob/master/orangecontrib/recommendation/datasets/epinions_train.tab

Check correctness of CLiMF

CLiMF pass all the tests, so functions MRR and loss are maximized successfully but the increase on their values per iteration is too small (even for higher learning rates).

Checks:

  1. Functions MRR and loss have been check against other libraries providing the same results for the same set of inputs. Hence, we can presume that they are correct.
  2. f = np.einsum('j,ij->i', U[i], V[items]) provide the same results as f = precompute_f(data,U,V,i) but will half precision (I've tried to double it by using np.float64/np.float128 without success ). Maybe this could be the cause.

Run test:

# Function in test_climf.py
def test_mrr(self):
    learner = CLiMFLearner(num_factors=10, num_iter=10, verbose=3, learning_rate=0.0001, lmbda=0.001)
    super().test_mrr(learner, filename='epinions_train.tab', testdata='epinions_test.tab')

Output:

CLiMF factorisation started.
    Level of verbosity: 3
        - Verbosity = 1 ->  [time/iter]
        - Verbosity = 2 ->  [time/iter, loss]
        - Verbosity = 3 ->  [time/iter, loss, MRR]

- Step: 1
    - Time: 1.383s
    - Training loss: -98104.785
    - Train MRR: 0.0532

- Step: 2
    - Time: 1.536s
    - Training loss: -98104.462
    - Train MRR: 0.0657

- Step: 3
    - Time: 1.367s
    - Training loss: -98104.140
    - Train MRR: 0.0685

- Step: 4
    - Time: 1.415s
    - Training loss: -98103.817
    - Train MRR: 0.0698

- Step: 5
    - Time: 1.307s
    - Training loss: -98103.494
    - Train MRR: 0.0698

- Step: 6
    - Time: 1.287s
    - Training loss: -98103.171
    - Train MRR: 0.0696

- Step: 7
    - Time: 1.321s
    - Training loss: -98102.847
    - Train MRR: 0.0693

- Step: 8
    - Time: 1.299s
    - Training loss: -98102.522
    - Train MRR: 0.0697

- Step: 9
    - Time: 1.365s
    - Training loss: -98102.198
    - Train MRR: 0.0693

- Step: 10
    - Time: 1.301s
    - Training loss: -98101.872
    - Train MRR: 0.0694

MRR: 0.0856

Output should be similar to this:

iteration 1:
train mrr = 0.05750323
iteration 2:
train mrr = 0.06994045
iteration 3:
train mrr = 0.07469046
iteration 4:
train mrr = 0.07611490
iteration 5:
train mrr = 0.07690448
iteration 6:
train mrr = 0.07711117
iteration 7:
train mrr = 0.07657648
iteration 8:
train mrr = 0.07625065
iteration 9:
train mrr = 0.07590930
iteration 10:
train mrr = 0.07558414

Test MRR: Test MRR: 0.40167283

Relevant links:

install problem

Hey,
While working in orange3env in linux

I tried both via the options/add-ons and via 'pip install https://github.com/biolab/orange3-recommendation/tarball/0.1.3' installing the add-on

But when i open one of the two examples 'Baselines (recommendation)' or 'Latent factor models':
I get the warning:

Errors occurred while loading the workflow.
There were problems loading some of the widgets/links in the workflow.
Details:
ValueError("'Predictor' is not a valid output channel name for 'Baselines'.",)

and in the command line i get many error messages while it loads the example:

....(most is a repetition of the following:)
/home/dunc/Work/orange/orange3env/lib/python3.4/site-packages/orangecontrib/recommendation/utils/format_data.py:72: UserWarning: Row meta attribute not found. Applying heuristics {users: col=0}
  warnings.warn(text_warning)
/home/dunc/Work/orange/orange3env/lib/python3.4/site-packages/orangecontrib/recommendation/utils/format_data.py:77: UserWarning: Column meta attribute not found. Applying heuristics {items: row=1}
  warnings.warn(text_warning)
unable to set <Orange.widgets.gui.OrangeComboBox object at 0x7fafb57ccc18> to value 'None'. Possible values are 
unable to set <Orange.widgets.gui.OrangeComboBox object at 0x7fafb5741dc8> to value 'None'. Possible values are 
/home/dunc/Work/orange/orange3/Orange/evaluation/testing.py:353: OrangeWarning: Working with small-enough data; single-threaded sequential excecution will (probably) be faster. Setting n_jobs=1
  "Setting n_jobs=1", OrangeWarning)
/home/dunc/Work/orange/orange3env/lib/python3.4/site-packages/orangecontrib/recommendation/utils/format_data.py:72: UserWarning: Row meta attribute not found. Applying heuristics {users: col=0}
  warnings.warn(text_warning)
/home/dunc/Work/orange/orange3env/lib/python3.4/site-packages/orangecontrib/recommendation/utils/format_data.py:77: UserWarning: Column meta attribute not found. Applying heuristics {items: row=1}
  warnings.warn(text_warning)
/home/dunc/Work/orange/orange3env/lib/python3.4/site-packages/orangecontrib/recommendation/base_recommendation.py:110: RuntimeWarning: invalid value encountered in true_divide
  averages_users = sums_users / countings_users
/home/dunc/Work/orange/orange3env/lib/python3.4/site-packages/orangecontrib/recommendation/base_recommendation.py:127: RuntimeWarning: invalid value encountered in true_divide
  averages_items = sums_items / countings_items

(python:15531): Gtk-CRITICAL **: IA__gtk_widget_get_direction: assertion 'GTK_IS_WIDGET (widget)' failed

(python:15531): Gtk-CRITICAL **: IA__gtk_widget_get_direction: assertion 'GTK_IS_WIDGET (widget)' failed

Thanks in advance!

Problem with GEO add-on

I can´t use de GEO Add-on.

When I try to install through menu option:

Collecting Orange3-Geo
Using cached https://files.pythonhosted.org/packages/96/d0/2f849d65a70c261959f7f45be8cd2fb742f0e38b5faa190cc0de855053ae/Orange3-Geo-0.2.3.tar.gz
Requirement already satisfied: Orange3 in c:\users\jrangel\appdata\local\orange1\lib\site-packages (from Orange3-Geo) (3.18.0)
Requirement already satisfied: scikit-learn in c:\users\jrangel\appdata\local\orange1\lib\site-packages (from Orange3-Geo) (0.20.0)
Requirement already satisfied: pandas in c:\users\jrangel\appdata\local\orange1\lib\site-packages (from Orange3-Geo) (0.23.4)
Requirement already satisfied: scipy>=0.17 in c:\users\jrangel\appdata\local\orange1\lib\site-packages (from Orange3-Geo) (1.0.1)
Collecting shapely (from Orange3-Geo)
Using cached https://files.pythonhosted.org/packages/a2/fb/7a7af9ef7a35d16fa23b127abee272cfc483ca89029b73e92e93cdf36e6b/Shapely-1.6.4.post2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\jrangel\AppData\Local\Temp\pip-install-39b1zjx9\shapely\setup.py", line 80, in
from shapely.buildcfg import geos_version_string, geos_version,
File "C:\Users\jrangel\AppData\Local\Temp\pip-install-39b1zjx9\shapely\shapely_buildcfg.py", line 200, in
lgeos = CDLL("geos_c.dll")
File "C:\Users\jrangel\AppData\Local\Orange1\lib\ctypes_init
.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] No se puede encontrar el módulo especificado

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\jrangel\AppData\Local\Temp\pip-install-39b1zjx9\shapely\

Please help.

Regards

missing __init__.py in orangecontrib.recommendation.utils

Hi,

I installed orange3-recommendation per the instructions. When I ran Orange from the terminal, I kept getting this error:

An ImportError occurred while loading entry point 'Recommendation = orangecontrib.recommendation.widgets'
Traceback (most recent call last):
  File "c:\python34\lib\site-packages\Orange\canvas\registry\discovery.py", line 89, in run
    point = entry_point.load()
  File "c:\python34\lib\site-packages\pkg_resources\__init__.py", line 2355, in load
    return self.resolve()
  File "c:\python34\lib\site-packages\pkg_resources\__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "C:\Users\...\AppData\Roaming\Python\Python34\site-packages\orangecontrib\recommendation\__init__.py", line 6, in <module>
    from .base_recommendation import (ModelRecommendation as Model,
  File "C:\Users\...\AppData\Roaming\Python\Python34\site-packages\orangecontrib\recommendation\base_recommendation.py", line 2, in <module>
    from orangecontrib.recommendation.utils import format_data
ImportError: No module named 'orangecontrib.recommendation.utils'

After some looking around, I realized that orangecontrib/recommendation/utils didn't have an __init__.py file. Since I added it to my cloned orange3-recommendation repo, I have been able to see the Recommendation section in the toolbox bar. I figured this might help others as well.

Thanks!

SVD++ and BRISMF learners not showing evaluation results

Recommendation version

latest

Orange version

3.27.1

Expected behavior

Showing evaluation results

Actual behavior

Not showing any results; but it works for Baseline learners.

Steps to reproduce the behavior

Please see attached figure

Additional info (worksheets, data, screenshots, ...)

svdbrismf_graphic_problem

RuntimeWarning: overflow encountered in multiply

python 3.6.2
numpy 1.15.4+mkl
Orange3 3.18.0
Orange3-Recommendation 0.1.3

**

  • Error information:

**
if norm_feedback > 0: # Gradient Y
dx_yi = -eij/norm_feedback * Q[j, :]
+ lmbda * Y[feedback_u, :]
RuntimeError: Training diverged and returned NaN.

Orange3-recommendation install in Anaconda environment

Hi, How can I install Orange3-recommendation add-in in the Anaconda environment? I have Windows10, 64-bit installation and Orange3.3. Instructions for a pip or conda install in the Anaconda environment would be a great help. I have managed to install other add-ins in Orange3. I don't see it in the documentation for this one. Thanks!

Learners should not hold references to widgets

When learners are used with Tests & Score widget, they get deep_copied, which is implemented in python as pickling and unpickling. If a learner holds a reference to a widget, this currently results in a crash, as widgets cannot be pickled. But even if they could be, this would result in an unexpected behaviour where we would end up with two instances of the same widget, but only one node on a canvas.

See biolab/orange3#2793

How to obtain the benchmarked RMSE?

I tried to reproduce the RMSEs of ml-100k reported in the benchmarks. However, the number I got is 0.91474, far worse than the reported score 0.810 (I even used the training rmse). May I ask how to get the benchmark numbers? Here is my code:

data = Orange.data.Table('movielens100k.tab') 
brismf = BRISMFLearner(num_factors=15, num_iter=15, learning_rate=0.07, lmbda=0.1) #paras reported on the benchmarks page
recommender = brismf(data)
y_pred = recommender(data)
rmse = math.sqrt(mean_squared_error(data.Y, y_pred))
print(rmse)

Thanks.

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.