RustRelevancy.sys.mjs

class RustRelevancy.sys.InterestMetrics()

Interest metrics that we want to send to Glean as part of the validation process. These contain the cosine similarity when comparing the user’s interest against various interest vectors that consumers may use.

Cosine similarly was chosen because it seems easy to calculate. This was then matched against some semi-plausible real-world interest vectors that consumers might use. This is all up for debate and we may decide to switch to some other metrics.

Similarity values are transformed to integers by multiplying the floating point value by 1000 and rounding. This is to make them compatible with Glean’s distribution metrics.

RustRelevancy.sys.InterestMetrics.top2interestSimilarity

type: number

The same as before, but the top 2 interests are copied. This measures the highest possible similarity with consumers that used interest vectors with a two interests (note: this means they would need to choose the user’s top two interests and have the exact same proportion between them as the user).

RustRelevancy.sys.InterestMetrics.top3interestSimilarity

type: number

The same as before, but the top 3 interests are copied.

RustRelevancy.sys.InterestMetrics.topSingleInterestSimilarity

type: number

Similarity between the user’s interest vector and an interest vector where the element for the user’s top interest is copied, but all other interests are set to zero. This measures the highest possible similarity with consumers that used interest vectors with a single interest set.

class RustRelevancy.sys.InterestVector()

Vector storing a count value for each interest

Here “vector” refers to the mathematical object, not a Rust Vec. It always has a fixed number of elements.

RustRelevancy.sys.InterestVector.animals

type: number

RustRelevancy.sys.InterestVector.arts

type: number

RustRelevancy.sys.InterestVector.autos

type: number

RustRelevancy.sys.InterestVector.business

type: number

RustRelevancy.sys.InterestVector.career

type: number

RustRelevancy.sys.InterestVector.education

type: number

RustRelevancy.sys.InterestVector.fashion

type: number

RustRelevancy.sys.InterestVector.finance

type: number

RustRelevancy.sys.InterestVector.food

type: number

RustRelevancy.sys.InterestVector.government

type: number

RustRelevancy.sys.InterestVector.hobbies

type: number

RustRelevancy.sys.InterestVector.home

type: number

RustRelevancy.sys.InterestVector.inconclusive

type: number

RustRelevancy.sys.InterestVector.news

type: number

RustRelevancy.sys.InterestVector.realEstate

type: number

RustRelevancy.sys.InterestVector.society

type: number

RustRelevancy.sys.InterestVector.sports

type: number

RustRelevancy.sys.InterestVector.tech

type: number

RustRelevancy.sys.InterestVector.travel

type: number

class RustRelevancy.sys.Interest()

List of possible interests for a domain. Domains can have be associated with one or multiple interests. Inconclusive is used for domains in the user’s top sites that we can’t classify because there’s no corresponding entry in the interest database.

RustRelevancy.sys.Interest.ANIMALS

ANIMALS

RustRelevancy.sys.Interest.ARTS

ARTS

RustRelevancy.sys.Interest.AUTOS

AUTOS

RustRelevancy.sys.Interest.BUSINESS

BUSINESS

RustRelevancy.sys.Interest.CAREER

CAREER

RustRelevancy.sys.Interest.EDUCATION

EDUCATION

RustRelevancy.sys.Interest.FASHION

FASHION

RustRelevancy.sys.Interest.FINANCE

FINANCE

RustRelevancy.sys.Interest.FOOD

FOOD

RustRelevancy.sys.Interest.GOVERNMENT

GOVERNMENT

RustRelevancy.sys.Interest.HOBBIES

HOBBIES

RustRelevancy.sys.Interest.HOME

HOME

RustRelevancy.sys.Interest.INCONCLUSIVE

INCONCLUSIVE

RustRelevancy.sys.Interest.NEWS

NEWS

RustRelevancy.sys.Interest.REAL_ESTATE

REAL_ESTATE

RustRelevancy.sys.Interest.SOCIETY

SOCIETY

RustRelevancy.sys.Interest.SPORTS

SPORTS

RustRelevancy.sys.Interest.TECH

TECH

RustRelevancy.sys.Interest.TRAVEL

TRAVEL

class RustRelevancy.sys.RelevancyApiError()

Errors we return via the public interface.

class RustRelevancy.sys.Unexpected()

Unexpected

RustRelevancy.sys.score(interestVector, contentCategories)

Calculate score for a piece of categorized content based on a user interest vector.

This scoring function is of the following properties: - The score ranges from 0.0 to 1.0 - The score is monotonically increasing for the accumulated interest count

# Params: - interest_vector: a user interest vector that can be fetched via RelevancyStore::user_interest_vector(). - content_categories: a list of categories (interests) of the give content. # Return: - A score ranges in [0, 1].

Returns:

number