Algorithm for comparator with multi product results - algorithm

I would like to implement an application that creates customized packages starting from a user's search.
For example, if the user has a sum of money and wants to assemble a computer, the system must return the best possible combination of components being in that price. For example, the user indicates that requires a processor, a mainboard, a RAM and an HDD: He must spend at most $ 1,000.
Then, the application will search and display the best combination for the user (each product has a weight - some kind of ranking - and value).
Which algorithm you advise me to do this research?
Thank you

Related

Calendar Scheduling algorithm

I'm working on an application which organises events. A user enters periods over the course of a week in which they are free, not free, and would prefer to work in.
Once the application is given a list of tasks of varying lengths to complete, it organises them according to the user's avaibalibity and the relative priority of the task.
What kind of algorithm am I looking at using in order to meet the application's requirements?
This is kind of solving a sudoku since multiple invariants need to align for any possible variable of the solution (i.e user must be available for given time period, tasks have priority index etc...).
That means, you can use back-tracking until you find one possible solution/alignment of tasks and return, or possibly continue until you find all possible solutions and return all of them.

Location and timeframe matching algorithm

I am developing a B2C service on demand and I need to create the matching algorithm, simple yet efficient enough to run on a Laravel backend.
The service matches house cleaners with customers, where the customer, when booking, defines a certain date and timeframe when (s)he will be available at home.
On the other hand (#1), cleaners don't have a working schedule and should be picked according to geographical proximity and, of course, availability (not to have two services starting at the same time or too close time-wise one from the other).
Obviously, there should be a geographical limit so that after a certain ε km the algorithm stops searching and, according to the type of service chosen, there is a specific duration.
Another solution (#2) could be to have a predefined weekly schedule and match schedules in order to define a "working calendar" as new requests come.
In any case the cleaner can opt not to accept a booking, in that case the algorithm will continue searching for another possible candidate.
Which algorithm would you suggest for solution #1 and #2?
Thank you

How to implement the Strategy design pattern?

I am working on a recommendation system. It would be an Android application in which user will input their preferences and on the bases of those preferences, other matched profiles would be shown to that user. I am getting data from the user and storing it in the Firebase.
These are the numerical values and in order to show the matched profiles to that user, I am using two algorithms for calculating the similarity count between the users: Cosine similarity and Pearson correlation
I am fetching the name of the algorithm from the application and then performing the algorithm in order to show similar profiles to the user.
if (request.query.algo === "cosine") {
// compute cosine value
}
else if (request.query.algo === "pearson-correlation") {
// compute pearson correlation coefficents
}
As it would be a real time application so this method is totally wrong, I want to implement Strategy design pattern where the algorithm could be decided on the run time rather than on the compile time.
So now the problem is, In Strategy design pattern, how would I decide when to use which algorithm?
For example, when you buy something with a credit card, the type of credit card doesn't matter. All credit cards have a magnetic strip that has encoded information in it. The strips, and what it contains, represent the 'interface' and the type of card would be the 'implementation'. Each credit card can be replaced by any other and all are fully independent of each other.
Similarly, On what bases I should choose in between Cosine and Pearson on run time with Strategy design pattern?
From my understanding of it, Pearson would perform worse in those cases where two user profiles have very differing set of items (in this case the preferences).
Perhaps that could be your criteria? In cases where the number of matching preferences is above a certain threshold use Pearson and for other cases use cosine.
You could perhaps show your user a CLOSE match list, which uses cosine to show users whos profiles have a lot in common.
Then you could show a second list, which says You might also be interested in, which uses Pearson to show matching profiles who dont have a lot of common preferences.

pre calculate users interests

i need an approach or an algorithm to pre-calculate an users interest based on his tweets..
the user connects his account with his twitter account and after retrieving his tweets for the first time i will have to pre-calculate his tastes and interests..
as this user continues to use the my system i will have to make those predictions more accurate..
is there an algorithm or a mathematical model which will help in this requirement?
please provide - existing research links or open source code or examples which will help me to get started..
You can use Machine-Learning for this task.
One possible machine learning algorithm is Bag Of Words with k-nearest neighbors:
Create a training set [users which you know what their interest are], and use the Bag Of Words [preferably with n-grams] to "learn" the training set.
When a new user arrives - have the words/n-grams extracted as features - and find the k nearest neighbors to determine what the interests are.
To get improvement over time - you can have some additional explicit feedback - users can click on agreement/disagreement for what the algorithm said. You can later use this information to extend the size of your training set - which will probably result in more accurate decisions.
This is a standrad algorithm for learning "features" between sets of sentences/words, so you should at least use it as a guideline.
There is also an open source project that might help you: Apache Mahout.

Recommendation algorithm (and implementation) for finding similar items and users

I have a database of about 700k users along with items they have watched/listened to/read/bought/etc.
I would like to build a recommendation engine that recommends new items based on what users with similar taste in things have enjoyed, as well as actually finding people the user might want to be friends with on a social network I'm building (similar to last.fm).
My requirements are as follows:
Majority of the "users" in my database aren't actually users of my website. They have been data mined from third-party sources. However, when recommending users, I would like to limit the search to people who are members of my website (while still taking advantage of the bigger data set).
I need to take multiple items into consideration. Not "people who like this one item you enjoyed...", but "people who like most of the items you enjoyed...".
I need to compute similarities between users and show them when viewing their profiles (taste-o-meter).
Some items are rated, others are not. Ratings are from 1-10, not boolean values. In most cases it would be possible to deduct a rating value from other stats if it's not present (e.g. if the user has favourited an item, but hasn't rated it, I could just assume a rating of 9).
It has to interact with Python code in one way or another. Preferably, it should use a seperate (possibly NoSQL) database and expose an API to use in my web back-end. The project I'm making uses Pyramid and SQLAlchemy.
I would like to take item genres into account.
I would like to display similar items on item pages based on both its genre (possibly tags) and what users who enjoyed the item liked (like Amazon's "people who bought this item" and Last.fm artist pages). Items from different genres should still be shown, but have a lower similarity value.
I would prefer a well-documented implementation of an algorithm with some examples.
Please don't give an answer like "use pysuggest or mahout", since those implement a plethora of algorithms and I'm looking for one that's most suitable for my data/use. I've been interested in Neo4j and how it all could be expressed as a graph of connections between users and items.
To determine similarity between users you can run cosine or pearson similarity (Found in Mahout and everywhere on the net really!) across the user vector. So your data representation should look something like
u1 [1,2,3,4,5,6]
u2 [35,24,3,4,5,6]
u1 [35,3,9,2,1,11]
In the point where you want to take multiple items into consideration you can use the above to determine how similar someones profiles are. The higher the correlation score the likelihood they have very similar items is. You can set a threshold so someone with .75 similarity has a similar set of items in their profile.
Where you are missing values you can of course make up your own values. I'd just keep them binary and try to blend the various different algorithms. That's called an ensemble.
Overall you are looking for something called item based collaborative filtering as the recommendation aspect of your set up and also used to identify similar items. It's a standard recommendation algorithm that does pretty much everything you've asked for.
When trying to find similar users you can perform some type of similarity metric across your user vectors.
Regarding Python, the book called programming in collective intelligence gives all their samples in python so go pick up a copy and read chapter 1.
Representing all of this as a graph will be somewhat problamatic as your undying representation is a Bipartile Graph. There are lots of recommendation approaches out there that use a graph based approach but its generally not the best performing approach.
Actually that is one of the sweetspots of a graph database like Neo4j.
So if your data model looks like this:
user -[:LIKE|:BOUGHT]-> item
You can easily get recommendations for an user with a cypher statement like this:
start user = node:users(id="doctorkohaku")
match user -[r:LIKE]->item<-[r2:LIKE]-other-[r3:LIKE]->rec_item
where r.stars > 2 and r2.stars > 2 and r3.stars > 2
return rec_item.name, count(*) as cnt, avg(r3.stars) as rating
order by rating desc, cnt desc limit 10
This can also be done using the Neo4j Core-API or the Traversal-API.
Neo4j has an Python API that is also able to run cypher queries.
Disclaimer: I work for Neo4j
There are also some interesting articles by Marko Rodriguez about collaborative filtering.
I can suggest to have a look at my open source project Reco4j. It is a graph-based recommendation engine that can be used on a graph database like yours in a very straigthforward way. We support as graph database neo4j. It is in an early version but very soon a more complete version will be available. In the meantime we are looking for some use case of our project, so please contact me so that we can see how we can collaborate.

Resources