Open-source Java recommendation system taste (1)-basic item-based recommendation

Source: Internet
Author: User

Http://terryma.blog.sohu.com/58889892.html

 

I am ashamed to pay attention to the recommendation system for a long time and have no output.
I have learned about the open-source Java recommendation system taste over the past few days. I have some experiences and I will post it slowly.

If the item-based recommendation is generated:
Assume that there are four users: u1, U2, U3, and U4.
Product has n C1, C2, C3
Steps:
1. Find out the user's score for the product.
2. Identify similarity between products.
3. Users can be recommended.
What needs to be done manually is to rate the similarity between products. This is a very troublesome task. If there are n products, we need n! .
If taste is used for implementation, the required code is as follows:

1. Create a dataset. The main data content is the user's score on the product:

DataModel model = new FileDataModel(new File("data.txt"));

2. Establish item similarity and set
For example, create a thing first (three items are available here)
Final item Item1 = new genericitem <string> ("0 ");
Final item item2 = new genericitem <string> ("1 ");
Final item item3 = new genericitem <string> ("2");
Record item Similarity
Final collection <genericitemcorrelation. itemitemcorrelation> correlations =
New arraylist <genericitemcorrelation. itemitemcorrelation> (2 );
Correlations. Add (New genericitemcorrelation. itemitemcorrelation (Item1, Item1, 1.0 ));
Correlations. Add (New genericitemcorrelation. itemitemcorrelation (Item1, item3, 0.5 ));
3. generate recommendations
Final itemcorrelation correlation = new genericitemcorrelation (correlations );
Final recommender = genericitembasedrecommender (datamodel, correlation );
4. Final recommendation generation
Final list <recommendeditem> recommended = recommender. Recommend ("test1", 1 );
Final recommendeditem firstrecommended = recommended. Get (0 );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.