All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.reco4j.similarity.BinaryJaccardSimilarity Maven / Gradle / Ivy

Go to download

Reco4j is an open source project aims at developing a recommendation framework based on graph data sources. We choose graph databases for several reasons. They are NoSQL databases, so "schemaless". This means that it is possible to extend the basic data structure with intermediate information, i.e. similarity value between item and so on. Moreover, since every information is expressed with properties, nodes and relations, the recommendation process can be customized to work on every graph. Reco4j can be used on every graph where "user" and "item" is represented by node and the preferences are modelled as relationship between them. Current implementation leverage on Neo4j as first graph database integrated in our framework.

The newest version!
package org.reco4j.similarity;

///*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//
//package org.recommender.similarity;
//
//import java.util.BitSet;
//import org.codemotor.recommender.model.Item;
//import org.codemotor.recommender.model.Rating;
//
///**
// *
// ** @author Alessandro Negro 
// */
//public class BinaryJaccardSimilarity implements ISimilarity
//{
//
//  public double getSimilarity(Item x, Item y)
//  {
//    if (x.getBinaryRating() == null || y.getBinaryRating() == null)
//      return -1;
//
//    BitSet tmp = (BitSet) x.getBinaryRating().clone();
//    tmp.and(y.getBinaryRating());
//    int commonUsers = tmp.cardinality();
//
//    tmp = (BitSet) x.getBinaryRating().clone();
//    tmp.or(y.getBinaryRating());
//    int totalUsers = tmp.cardinality();
//    
//    double sim = 0.0;
//    if (commonUsers > 0)
//      sim = (double) commonUsers / (double) totalUsers;
//
//    return sim;
//  }
//}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy