1
votes

I'm Familiar with algorithms implementation and new to machine learning but i have gap between academic and production.

I'm implementing recommender system and learning Model finished with good results then i stopped and asked what to do next? how to deploy it with existing website

during learning i used CSV dataset and local machine but online will be database with hundreds of thousands of users and thousands of users. so i think it is impossible to load all data and recommend things to user.

the question is: how will i use my trained models in production?

4

4 Answers

1
votes

When you said "database with hundreds of thousands of users and thousands of users." I guess you meant "hundreds of thousands of users and thousands of items". Do you have a User collaborative filtering or an Item-Item filtering?

If so, I guess thoose numbers (10K*1K) wont be a problem for any decent relational database. Basically you create a table, let say "Rattings", where you store: UserId, ItemId and Ratting (you can omit this ratting filed if your "features" are binaries ex: Item purchased or not).

If your user-item matrix is sparse this table will be small. Also you create an "Users" table where, after any insertion in the "Rattings" table, you can pre-compute, for example, the user average ratting if you need to normalize the predictions and other data you may need. As a rule of thumb, dont do very complex calculus involving scanning other tables when you are inserting but do simple maths if this helps to avoid doing complex scanning in other tables when data is retrieved for calculating the predictions/recommendations.

You could get some ideas from here: http://lemire.me/fr/documents/publications/webpaper.pdf

Take into account the Relational Db is an storage, even it could calculate almost everything using Sql, the regular scenario is using the relational Db for filtering and joining and then do the maths in other layer/trier.

0
votes

You can either deploy the trained model to production yourself by creating an API, and deploying that on at least a couple instances connected with a load balancer.

The other route is to use a service that handles that for you. My service mlrequest makes it very simple to create and deploy high-availability, low-latency models.

You can use the reinforcement learning model that is well suited to making recommendations. Below is an example of a movie recommender.

from mlrequest import RL
rl = RL('your-api-key')
features = {'favorite-genre': 'action', 'last-movie-watched': 'die-hard'}
r = rl.predict(features=features, model_name='movie-recommender', session_id='the-user-session-id', negative_reward=0, action_count=3)
best_movie = r.predict_result[0]

When the model does a good job (e.g., the user clicked on or started watching the predicted movie) then you should reward the model by giving it a positive value (in this case, a 1).

r = rl.reward(model_name='movie-recommender', session_id='the-user-session-id', reward=1)

Every time the model is rewarded for a correct action it took, it will learn to do those actions in that context more often. The model therefore learns in real-time from its own environment and adjusts its behavior to give better recommendations. No manual intervention needed.

-1
votes

I don't really get what you mean here. Normally, you train your model with a certain set of training data. Then you validate your model using a certain set of test data. If the model shows promissing results(e.g. is "trained well") it goes to production.

Take shopping recommondations as an example. You've trained a model to suggest the next product based on previous products. Now, in production, if your customer buys/looks at a new product, you feed your algorithm with this product and it gives you a set of other products you might choose. This is just the same as with your training/validation data.

The source of data genereally is not relevant. But maybe I really don't get your question. Could you elaborate?

-1
votes

Here is an example of how to Integrate a Machine Learning Model into a Web app https://www.youtube.com/watch?v=mu-R0dQ3-Qo and the code can be found here https://github.com/shivasj/Integrating-a-Machine-Learning-Model-into-a-Web-app