Is this an approach to user-item recommendations that could work - recommendation-engine

I am designing an application that incorporates a recommendation system base on user interactions (collaborative filtering). The user on his homepage is presented a set of 6 items to interact with. There will be between 50 and 300 items. The following actions are possible:
click on an item (strong interest)
refresh an item (some interest)
open a read-more dialog (some interest)
don't do anything an move on (no interest)
This data is collected and stored. The system should recommend items of interest to the user. I'am thinking about turning this data into a rating system.
Option A) if the user clicks on an item, this is translated into a implicit lifetime rating of 5. refreshing an item it a 4 and so on. So my user->item matrix would look like this:
item 1 | item 2 | item 3
john 5 4
jane 4
In this example john has clicked on item 1 and refreshed item 3. The rating can only go up really, i.e. if a user has previously refreshed an item I write a 4 and update only to a 5 if the item is clicked later.
Option B) each time the user does one of the above actions, I'll increment a scalar value for the item, which means it can grow unbounded.
item 1 | item 2 | item 3
john 55 1 30
jane 41 9
Maybe this is a problem, since now the numbers are harder to translate into a rating scale from 1 to 10
Option C) I count every interaction separately
item 1 click | item 1 refresh | item 1 read
john 3 1
jane 1 1
Here the problem is that "reading about" an item is probably only done once.
Independent of whatever option I choose, my idea is to first find similar users using something like cosine similarity or pearson correlation. Then pick the top 10 to 30 users from that list and compile a toplist of their favorite items. From that list, I will then recommend items that the current user has had little interaction with in the past.
Is this something that could work? I am worried that finding similar users will eliminate the chance of finding interesting (new) items for the current user.

What you suggest sounds reasonable. Your concern about not finding new items is a reflection of the collaborative filtering method which is metadata-based. To find new items you would have to undoubtedly do some content analysis which would be a separate stage. For example, if your items are news articles you might try to identify important keywords for each user.

Related

Most efficient voting system in Firebase

I'm working on an app that lets users upload pictures and rate (so vote with stars 1-5) each others pictures. But I keep thinking that the database system that I'm building is not efficient enough. I hope that there is someone who can give me advice.
Right now I have a database table called "images". It has the following fields:
doc_id
user_id
image
amount_of_votes
rating
Everytime a user votes the amount_of_votes gets a +1 and the rating gets calculated by (rating*old amount of votes + new vote) / new amount of votes
But this gives me the following problems:
If 2 users look at the same image at the same time (for example an iamge with 2 votes with 1 star) then if the first user votes 5 stars a new rating is calculated. But if the second user votes 1 star again then the last user who votes still gets 2 votes with 1 star and doesn't see the new 5 star rating.
Also I think that it's not safe to do it this way. A user can in theorie just change the amount to 1 and the rating to 1.
I want to build a new voting system where there is a new table called votes and it holds the user_id and the vote that the user gives. But that gives me the following problem:
if a user clicks on a really popular image then if has to load a lot of votes and calculate an average. That isn't efficient.
Does anyone know what the best system is that I can use? I have spend days on the internet but I haven't found the best system yet...
I didn’t try implementing it myself but my approach for this will be the use of a Snapshot listener.
It can help you to have updated information in the application whenever something changes in the document. The voting system which I use is collecting 5 stars, 4 stars , 3 stars, etc, separately. For example: how many 5 stars ratings a user got, how many 4 stars a user got and so on.
Then, to calculate the average rating I use the following formula:
((no_of_votes_for_5stars * 5) + (no_of_votes_for_4stars * 4) + (no_of_votes_for_3stars * 3) + (no_of_votes_for_2stars * 2) + (no_of_votes_for_1star * 1)) / (no_of_votes_for_5stars +no_of_votes_for_4stars + no_of_votes_for_3stars + no_of_votes_for_2stars + no_of_votes_for_1star )
You can save the number of stars data separately in the Firestore database and whenever someone rates a photo, you can increment the current count. And you can implement the above formula inside the app code so your application gets the number of stars info and calculates the average using the above formula, and then displays it.

IS it ok to have 20 activities in an app?

I am trying to make a basic kids app. I have 20 questions to be asked, kid will tap on the right colour and once he does so , next question should appear.
My questions is shall I keep changing layout of the same activity or shall I call 2 and create 20 different actvities for 20 different colour questions. What isthe Best Practice?
one activity is enough . you can just change the texview values of questions and answers and manipulate colors if you want too. as soon as user hits next button check with answer ,add it to score or add just 0 then change values for next question.
you dont need to create new button you do just change the button name or question 1.user open the app 2. there is a start quiz button 3. user press the start quiz button 4. we do four things (A)creating a hash-table of questions giving it 1.2.3...ids, creating hashtable of right answers giving same ids 1.2.3.. then two more tables with fake answers giving same ids (B) when we are done doing this we start with first question. (c) using id 1 from table 1 get the the value and assign it to question or the first button i guess. (d) using id 1 get value from table 2 which our right answers table assign it to one of 3 buttons (e) now get value from 3 and 4 table which is our fake answer table using id 1 n assign to other two buttons.5 now our question 1 is ready and wait for user to click on one of three buttons. 6. lets say user click button 3 . 7 using button id we get button name which the answer user gave us we match it with our table 2 id 1 8. if it matches user giving the right answer we add 1 point to user score and move to next question which will be question number+1 so 2 then will repeat same from step C to E but this time we will use id 2 . so every time user answer we go to next question using +1 with question number until be get at 20. 9. if answer does not match we add nothing to score move to next question. When question number reaches 20 we finish we hide all button and show a textview with user's score

Displaying a 'Top Result' with Algolia?

I want to search 3 different indices at once, breaking out their results into 3 separate sections.
Above these 3 sections though, I want to display a 4th section with a single result row, and this section will be titled "Best Result".
It should take the best result of the 3 indices that most perfectly matches.
Does anyone know how I can achieve this? Thanks!
By design, when the ranking of each index is properly set (both attributeToIndex, and customRanking settings filled), the Algolia engine returns the most relevant et popular results for each new search request. First the one without typos and with perfect matches, then the others...
Which mean that if you want to display all the top results on a single page, you only need to take the N first result of each index.
Then it's just a matter of display. Like on the following websites, you can imagine to display those results into multiple columns:
http://telly.com/
Prototype built using the TED API
Feel free to look at tips about the best way to display result hits in multiple columns using Algolia and Bootstrap 3
Beside that you can also consider passing the getRankingInfo=1 parameter with your search query, and filter the results displayed accordingly to the matching info returned for each hit within the _rankingInfo property.
firstMatchedWord: 2000
geoDistance: 0
geoPrecision: 1
nbExactWords: 2
nbTypos: 0
proximityDistance: 1
userScore: 9499
words: 2

ListView: instantly updating and time comparision

I have to work on an application in which we are getting list of orders(with all details and display_time) and we have to show them in list view, but the condition is we have to show particular order on their exact display_time.
For example below are some orders with display time:
order_id: 101 |
display_time (hh:mm:ss): 09:10:00
order_id: 102 |
display_time (hh:mm:ss): 09:30:00
Then the requirement is:
We have to show the orders on list on exact their display time.
All order should come instantly as they entered in database.
Edit
The first thing that I need is:
To get the order from database (SQL Server) instantly without hitting
any API. Like push notification.
Then the second need is:
To compare the device's time and order's display_time and if its matched then make visible the order in ListView. I have to do this for each order i think.
I don't know how can I do this.
So please suggest how can we do the above task.
I hope I understand correctly. Mainly you want the list of items to be in the order of time from earliest to latest.
Here is one algorithm and it could be enhanced.
Allocate 100 (arbitrary) items/rows in the Listview.
If you only have 2 items or orders initially, make the other 98 rows not visible (state).
If a new order is entered, add the new order into one of the non-visible rows. And make it visible of course.
The issue in this case, you may have to reorder the items above the new order. However this is only a manipulation of text in your rows. A data structure is necessary to support this.
I claim this algorithm is fast. I think this is a good start.

How to show categories and sub categories in view page and select menu in zend frame work

i'm having the table like
category_id category_name parent_id
1 General Grocery 0
2 Ready to eat 0
3 rice 1
4 oils 1
5 flour 1
6 seed 1
7 testing cate 0
8 testing 5
i want to display the categories with "n" number of sub categories in subcategories. My main moto is by using the array generated by the code i want to display in view page and the select menu in the zend form. I found the code in php. but i'm unable to use that in zend. Can some one help me out with this please.
Thank you.
I think you need to generate a tree.. so there are two known patterens to me
adjacency level pattern
Nested Level Patteren
I suggest you to use Nexted level pattern
If you follow the given below two links you will surely come to know what to do.
http://blog.richardknop.com/2009/05/nested-set-model/
http://baobab.sideralis.org/
By this you can generate appropriate tree. now you have to generate a tree in which you can select your items. so you should use this tree http://www.dhtmlx.com/docs/products/dhtmlxTree/index.shtml
you can keep checkboxes to select the items and store in the database