opted-eu / meteor-api

Meteor API Server
https://meteor.opted.eu/
GNU General Public License v3.0
1 stars 0 forks source link

Recommender System #40

Closed mrwunderbar666 closed 1 year ago

mrwunderbar666 commented 1 year ago

Find similar entries based on what they have in common.

Example query for calculating jaccard similarity between datasets:

{
  var(func: has(sources_included)) {
    D2_num_sources as count(sources_included)
  }
  var(func: uid(0x149fb920)) {
    name
    D1_num_sources as count(sources_included)
    v as sources_included {
      ~sources_included {
          intersection as count(sources_included, @filter(uid(v)))
          distance as math(1 - (intersection / (1.0 * D1_num_sources + 1.0 * D2_num_sources) )) # 1.0 is required to cast int to floats
        }
    }
  }
  similarDatasets(func: uid(distance), orderasc: val(distance), first: 10) {
    name
    uid
    common_items: val(intersection)
    d: val(distance)
    }
}