Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7916371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:47:01+00:00 2026-06-03T14:47:01+00:00

The structure of my tree is simple, the depth is two, each child node

  • 0

The structure of my tree is simple, the depth is two, each child node is the direct child of the root, and each node has a weight except the root. Is there a good way to measure the similarity of two trees?
Here is the original question:
Suppose you have a data list about the books that you have read. The list contains keys and values like a hashtable. The keys are the book categories, and the values are the amount of books that you have read under the current category. So every person has this data list, I want to compare the similarity of two users based on this data list. I know the collaborative-iltering can do this, but I am trying this way and compare it with cf.
So I treat the data list as a weighted tree. The categories are the child nodes, the weight of each child node is the times that this category appears in user’s books.
The similarity is similar with the similarity of two users in collaborative iltering. It’s a number.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:47:04+00:00Added an answer on June 3, 2026 at 2:47 pm

    This can be done using set operations.

    I once implemented such a similarity metric in the Meta-CVS software, years ago. This was used to identify renamed files when importing snapshots to a branch. Of course, files can be renamed and edited between baselines, which means you cannot perform exact comparisons. But I digress.

    Jaccard Index1

    First of all, two users can have completely different interests in books. Or they can have completely the same interest.

    What you can do is compute the size of their combined set of interests, and represent that part they have in common as a fraction of the overall size.

    Suppose that the interests sets were not weighted, but simply sets categories without an associated weight. Similarity could then be expressed as the number of categories that the two users have in common, divided by the total number of categories. That is to say, the cardinality of the set intersection, divided by the cardinality of the set union.

    If weights are involved, you have to work them in somehow. Perhaps calculate the total weight of the set intersection by the total weight of the union (watching out for division by zero).

    As you can see, this metric yields 0.0 if the users have no categories in common, and 1.0 if they are interested in matching categories (regardless of the weight), so it is viable.

    Cosine Similarity2

    Another way to define the similarity would be to treat this as a vector dot product (correlation). Firstly, determine all of the categories that exist between the two users. Form a vector, for each of the two users, in which the weight of every category is present (as a zero, if the user doesn’t have that category in his interest set).

    Then you can calculate similarity by taking the dot product of these vectors, and dividing it by the product of their lengths: (A . B) / |A||B|

    The length of a vector is the square root of the sum of the squares of the weights. (Again, watching out for division by zero.)

    Under this similarity metric, if the users have no categories in common, the two vectors are perpendicular, and their dot product is zero. This metric is basically the cosine of the angle between the two vectors. The closer the cosine is to one, the more parallel the vectors are (users’s interests are “aligned in the same direction”).

    Hope this gives you some ideas; but as you can see, this is open-ended.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a simple parameterized tree structure, based on a root Node. Each node
I have a tree structure where each Node has a parent and a Set<Node>
I have a parent/child table (simple tree) table structure (ID, ParentID), where I want
I have a simple tree structure represented like this: Node { int Id; int
I'm trying to implement a tree-like structure with two classes: Tree and Node .
I have a very simple binary tree structure, something like: struct nmbintree_s { unsigned
Given the following tree structure in Haskell: data Tree = Leaf Int | Node
I have a neat Model based off QAbstractItemModel. This has a simple hierarchical tree
Given a table that represents a hierarchical tree structure and has three columns ID
I am looking for a good Tree data structure class. I have come across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.