GRU4Rec | original Theano implementation of the algorithm | Recommender System library
kandi X-RAY | GRU4Rec Summary
kandi X-RAY | GRU4Rec Summary
This is the original theano implementation of the algorithm of the paper "Session-based Recommendations With Recurrent Neural Networks", with the extensions introduced in the paper "Recurrent Neural Networks with Top-k Gains for Session-based Recommendations".
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Fit the model
- Performs RMSprop
- Wrapper for GpuSearchSortedSearchSortedSearchSortedSortedSortedSortedSorts
- Perform the GPU search using the GPU search
- Evaluate the GPU
- Compute the symbolic prediction
- Evaluate multiple sessions
- Predict next batch
- Code into python code
- Extract kernel from GPU
- Code python code
- Load GPU kernel
- Load data from a pickle file
- Set parameters
- Set the final activation
- Set hidden activation
- Sets the loss function
- Load a model from a pickle file
- Return the tags associated with the given optimizer
- Computes the cross entropy logits of the covariance matrix
- Compute the diagonal of X
- Compute cross entropy
- Extend the weight matrix
- Remove an optimizer
- Compute the top1 maximum of yhat
GRU4Rec Key Features
GRU4Rec Examples and Code Snippets
Community Discussions
Trending Discussions on Recommender System
QUESTION
I intend to use a hybrid user-item collaborative filtering to build a Top-N recommender system with TensorFlow Keras
currently my dataframe consist of |user_id|article_id|purchase
purchase is always TRUE because the dataset is a history of user - article purchases
This dataset has 800,000 rows and 3 columns
2 QuestionsHow do I process it such that I will have 20% purchase = true and 80% purchase = false to train the model?
Is a 20%, 80% true:false ratio good for this use case?
ANSWER
Answered 2022-Mar-05 at 12:35
- How do I process it such that I will have 20% purchase = true and 80% purchase = false to train the model?
Since you only have True values, it means that you'll have to generate the False values. The only False that you know of are the user-item interactions that are not present in your table. If your known interactions can be represented as a sparse matrix (meaning, a low percentage of the possible interactions, N_ITEMS x N_USER, is present) then you can do this:
- Generate a random user-item combination
- If the user-item interaction exists, means is True, then repeat step 1.
- If the user-item interaction does not exist, you can consider it a False interaction.
Now, to complete your 20%/80% part, just define the size N of the sample that you'll take from your ground truth data (True values) and take 4*N False values using the previous steps. Remember to keep some ground truth values for your test and evaluation steps.
- Is a 20%, 80% true:false ratio good for this use case?
In this case, since you only have True values in your ground truth dataset, I think the best you can do is to try out different ratios. Your real world data only contains True values, but you could also generate all of the False values. The important part to consider is that some of the values that you'll consider False while training might actually be True values in your test and validation data. Just don't use all of your ground truth data, and don't generate an important portion of the possible combinations.
I think a good start could be 50/50, then try 60/40 and so on. Evaluate using multiple metrics, see how are they changing according to the proportion of True/False values (some proportions might be better to reach higher true positive rates, other will perform worse, etc). In the end, you'll have to select one model and one training procedure according to the metrics that matter the most to you.
QUESTION
I'm dabbling with ML and was able to take a tutorial and get it to work for my needs. It's a simple recommender system using TfidfVectorizer and linear_kernel. I run into a problem with how I go about deploying it through Sagemaker with an end point.
...ANSWER
Answered 2021-Nov-05 at 01:24I came to the conclusion that I didn't need to deploy this through SageMaker. Since the final linear_kernel output was a Dictionary I could do quick ID lookups to find correlations.
I have it working on AWS with API Gateway/Lambda, DynamoDB and an EC2 server to collect, process and plug the data into DynamoDB for fast lookups. No expensive SageMaker endpoint needed.
QUESTION
I am trying to learn about recommender systems in Python by reading a blog that contains a great example of creating a recommender system of repositories in GitHub.
Once the dataset is loaded with read_csv(), the person that wrote the code decided to convert that data into a pivot_table pandas for visualizing the data in a more simple way. Here, I left you an image of that part of the code for simplicity:
In that table, rows are the users and columns are the repositories. The cross section between a row and a column is the punctuation that a user gives to a particular repository.
Due to the fact that many of the elements of that table are null (we can say that we are having a sparse matrix, very typical in machine learning), he decided to study the level of sparsity of the matrix by means of this code:
...ANSWER
Answered 2021-Oct-18 at 17:43By default, nonzero
will return a tuple of the form (row_idxs, col_idxs)
. If you hand it a one-dimensional array (like a pandas series), then it will still return a tuple, (row_idxs,)
. To access this first array, we still must index ratings.nonzero()[0]
to get the first-dimension index of nonzero elements.
More info available on the numpy page for nonzero
here, as both pandas and numpy use the same implementation.
QUESTION
I'm currently building a recommender system using Goodreads data.
I want to change string user ids into integers.
Current user ids are like this: '0d688fe079530ee1fe6fa85eab10ec5c'
I want to change it into integers(e.g. 1
, 2
, 3
, ...), to have the same integer ids which share the same string ids. I've considered using function df.groupby('user_id')
, but I couldn't figure out how to do this.
I would be very thankful if anybody let me know how to change.
...ANSWER
Answered 2021-Jul-25 at 04:52Use pd.factorize
as suggested by @AsishM.
Input data:
QUESTION
I am building a recommender system in Python using the MovieLens dataset (https://grouplens.org/datasets/movielens/latest/). In order for my system to work correctly, I need all the users and all the items to appear in the training set. However, I have not found a way to do that yet. I tried using sklearn.model_selection.train_test_split
on the partition of the dataset relevant to each user and then concatenated the results, thus succeeding in creating training and test datasets that contain at least one rating given by each user. What I need now is to find a way to create training and test datasets that also contain at least one rating for each movie.
ANSWER
Answered 2021-Jun-11 at 20:37This requirement is quite reasonable, but is not supported by the data ingestion routines for any framework I know. Most training paradigms presume that your data set is populated sufficiently that there is a negligible chance of missing any one input or output.
Since you need to guarantee this, you need to switch to an algorithmic solution, rather than a probabilistic one. I suggest that you tag each observation with the input and output, and then apply the "set coverage problem" to the data set.
You can continue with as many distinct covering sets as needed to populate your training set (which I recommend). Alternately, you can set a lower threshold of requirement -- say get three sets of total coverage -- and then revert to random methods for the remainder.
QUESTION
I am trying to implement a group recommender system with the Django framework, using the LensKit tools for Python (specifically a Recommender object which adapts the UserUser algorithm). However, it only returns individual recommendations in some cases (for some specific users), but it always returns recommendations for groups of users (I create a hybrid user whose scores are the average of group members' scores and request recommendations for it). Below is my implementation for requesting recommendations for an individual user, as well as for a group:
...ANSWER
Answered 2021-May-23 at 02:53The most likely cause of this problem is that the user-user recommender cannot build enough viable neighborhoods to provide recommendations. This is a downside to neighborhood-based recommendations.
The solutions are to either switch to an algorithm that can always recommend for a user with some ratings (e.g. one of the matrix factorization algorithms), and/or use a fallback algorithm such as Popular
to recommend when the personalized collaborative filter cannot recommend.
(Another solution would be to implement one of the various cold-start recommenders or a content-based recommender for LensKit, but none are currently provided by the project.)
QUESTION
I have trained a gensim doc2vec model for an English news recommender system. the model was trained with 40K news data. I am using the code below to recommend the top 5 most similar news for e.g. news_1:
...ANSWER
Answered 2021-May-19 at 09:07There's a bulk contiguous vector structure initially created by training, for the initial known set of vectors. It's amenable to the every-candidate bulk vector calculation at the heart of most_similar()
- so that operation goes about as fast as it can, with the right vector libraries for your OS/processor.
But, that structure wasn't originally designed with incremental expansion in mind. Indeed, if you have 1 million vectors in a dense array, then want to add 1 to the end, the straightforward approach requires you to allocate a new 1-million-and-1 long array, bulk copy over the 1 million, then add the last 1. That works, but what seems like a "tiny" operation then takes a while, and ever-longer as the structure grows. And, each add more-than-doubles the temporary memory usage, for the bulk copy. So, the naive pattern of adding a whole bunch of new items individuall in a loop can be really slow & memory-intensive.
So, Gensim hasn't yet focused on providing a set-of-vectors that's easy & efficient to incrementally grow with new vectors. But, it's still indirectly possible, if you understand the caveats.
Especially in gensim-4.0.0
& above, the .dv
set of doc-vectors is an instance of KeyedVectors
with all that class's standard functions. Thos include the add_vector()
and add_vectors()
methods:
You can try these methods to add your new inferred vectors to the model.dv
object - and then they'll also be ncluded in folloup most_similar()
results.
But keep in mind:
The above caveats about performance & memory-usage - which may be minor concerns as long as your dataset isn't too large, or manageable if you do additions in occasional larger batches.
The containing
Doc2Vec
model generally isn't expecting its internal.dv
to be arbitrarily modified or expanded by other code. So, once you start doing that, parts of themodel
may not behave as expected. If you have problems with this, you could consider saving-aside the fullDoc2Vec
model
before any direct-tampering with its.dv
, and/or only expanding a completely separate instance of the doc-vectors, for example by saving them aside (eg:model.dv.save(DOC_VECS_FILENAME)
) & reloading them into a separateKeyedVectors
(eg:growing_docvecs = KeyedVectors.load(DOC_VECS_FILENAME)
).
QUESTION
I am trying to create a recommender system from this kaggle dataset: f7a1f242-c
https://www.kaggle.com/kerneler/starter-user-artist-playcount-dataset-f7a1f242-c
the file is called: "user_artist_data_small.txt"
The data looks like this:
1059637 1000010 238
1059637 1000049 1
1059637 1000056 1
1059637 1000062 11
1059637 1000094 1
I'm getting an error on the third last line of code.
...ANSWER
Answered 2021-May-10 at 14:09Just create a dataframe using the CSV reader (with a space delimiter) instead of creating an RDD:
QUESTION
I have a movie recommender system I have been working on and currently it is printing two different sets of output because I have two different types of recommendation engines. Code is like this:
...ANSWER
Answered 2021-Apr-07 at 23:00If the return type of get_input_movie()
is a Pandas DataFrame or a Pandas Series, you can try:
Replace the following 2 lines:
QUESTION
would like to say I still feel fairly new too python in general. But I have a movie recommender system that I have been working on, and the way I have it setup is for the user to enter a movie in the console and then it spits out 10 recommendations and ask for another movie.
When a misspelled movie is entered, it gives error message KeyError: 'Goodfellas'
and it stops running.
I would like for it to just start the loop over, until the user ends the loop using my break word. Here is my code for reference.
ANSWER
Answered 2021-Mar-23 at 21:19Look at try-except
and continue
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install GRU4Rec
You can use GRU4Rec like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page