Mahout using Boolean data to evaluate precision and recall

Source: Internet
Author: User

/* Evaluate precision and recall with no-preference-worthy Boolean * data * */package byuser;import;import;import;import;import;import;import;import;import;import;import;import;import;import;import;import;import;import;import; public class Genericbooleanpretest {public Genericbooleanpretest () throws Tasteexception, Ioexception{datamodel model = New Genericbooleanprefdatamodel (New Filedatamodel (New File ("E:\\mahout Project \\examples\\ua.base")); Recommenderirstatsevaluator evaluator = new Genericrecommenderirstatsevaluator (); Recommenderbuilder recommenderbuilder= New Recommenderbuilder () {@Overridepublic recommender buildrecommender ( Datamodel model) throws Tasteexception {//TODO auto-generated method stubusersimilarity similarity = new Loglikelihoodsim Ilarity (model); Userneighborhood neighborhood = new Nearestnuserneighborhood (ten, similarity, model); return new Genericuserbasedrecommender (model, neighborhood, similarity);};D Atamodelbuilder ModelBuilder = new Datamodelbuilder () {@Overridepublic Datamodel Builddatamodel (fastbyidmap< PreferenceaRray> trainingdata) {//TODO auto-generated method Stubreturn New Genericbooleanprefdatamodel ( Genericbooleanprefdatamodel.todatamap (Trainingdata));}};i Rstatistics stats = evaluator.evaluate (Recommenderbuilder, modelBuilder, model, NULL, 10, Genericrecommenderirstatsevaluator.choose_threshold, 1.0); SYSTEM.OUT.PRINTLN ("The precision of Boolean data evaluation is:" + stats.getprecision ()); System.out.println ("The Recall of Boolean data evaluation is:" + stats.getrecall ());} public static void Main (string[] args) throws Tasteexception, IOException {//TODO auto-generated method Stubgenericboolea Npretest test = new Genericbooleanpretest ();}}


Mahout using Boolean data to evaluate precision and recall

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: 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.