Skip to main content

Serko Northsky TTV Scoring

The TTV (Trip Travel Value) Scoring system is Serko Northsky's intelligent ranking engine that evaluates trip options (accommodations, flights) against user preferences and company policies to provide personalized rankings.

Overview

The TTV Scoring system works in four steps:

  1. Extracting features from trip option entities (e.g., price, distance, amenities)
  2. Evaluating features against user preferences and company policies
  3. Computing scores that determine option rankings
  4. Generating insights that explain why options scored well or poorly

Architecture

Class Hierarchy

ScoringCriterion (abstract base for evaluation criteria)

├── Preference (user/trip preferences)
│ ├── AccommodationPreferences/ (17 implementations)
│ └── FlightPreferences/ (5 implementations)

└── Policy (company compliance rules)
└── PolicyModels (stay rules, flight rules)

OptionFeature[T, TripOptionPart] (abstract base for extractable features)

├── AccommodationFeature[T] → extracts from Accommodation entity
├── ProductFeature[T] → extracts from Product entity
├── RoomFeature[T] → extracts from Room entity
└── FlightFeature[T] → extracts from Flight entity

Component Flow

                    ┌───────────────────┐
│ ScoringCriterion │
│ (defines how to │
│ evaluate) │
└────────┬──────────┘

┌──────────────┴──────────────┐
│ │
┌─────────▼─────────┐ ┌───────────▼───────────┐
│ Preference │ │ Policy │
│ (user choices) │ │ (company rules) │
└───────────────────┘ └───────────────────────┘
│ │
│ ┌──────────────────┐ │
└───►│ OptionFeature │◄────┘
│ (extracts values │
│ to be scored) │
└────────┬─────────┘


┌──────────────────┐
│ compute_score │
│ (returns weighted│
│ score 0.0-1.0) │
└──────────────────┘

ScoringCriterion Base Class

The ScoringCriterion is the abstract base class for all scoring criteria.

Key class attributes:

  • name, description — Human-readable identifiers
  • main_condition_field, main_condition_value_type — Condition configuration
  • condition_operator — Comparison operator (IS_EQUAL, IS_LESS_THAN, etc.)
  • trip_step_type — ACCOMMODATION or FLIGHT
  • weight — Score multiplier (-100 to 100)

Condition Operators

OperatorDescriptionExample
IS_EQUALExact matchBrand equals "Hilton"
IS_NOT_EQUALNot equalExclude specific value
IS_GREATER_THANGreater thanRating greater than 3.5
IS_GREATER_THAN_OR_EQUALGreater or equalRoom size at least 20
IS_LESS_THANLess thanPrice under 200
IS_LESS_THAN_OR_EQUALLess or equalDistance at most 5
CONTAINSValue in collectionAmenity contains keyword

OptionFeature Base Class

The OptionFeature is a generic base class for extractable features:

Type parameters:

  • T — Value type (float, bool, str, int, datetime)
  • TripOptionPart — Source entity (Accommodation, Flight, etc.)

Key methods:

  • create() — Factory method to extract feature from entity
  • to_insight() — Generate natural language description

Accommodation Implementation

See option_feature/accommodation/ and preference/accommodation_preferences/ for implementations.

Features

FeatureTypeCategoryDescription
DistanceFeaturefloatLocationDistance from search center (km)
StarRatingFeaturefloatQualityStar rating (1-5)
GuestRatingFeaturefloatQualityGuest review rating
ChainFeaturestrBrandHotel chain name
HasGymFeatureboolAmenitiesHas gym/fitness
HasWifiFeatureboolAmenitiesHas WiFi
HasBreakfastFeatureboolAmenitiesOffers breakfast
PricePerNightFeaturefloatPricingNightly rate
IsRefundableFeatureboolPoliciesIs refundable

Preferences

PreferenceTypeOperatorCategory
MaximumPricePerNightPreferencefloatIS_LESS_THANBudget
MinimumStarRatingPreferencefloatIS_GREATER_THANQuality
MaximumDistancePreferencefloatIS_LESS_THANLocation
AccommodationBrandPreferencestrIS_EQUALBrand
HasGymPreferenceboolIS_EQUALAmenities
RoomIsRefundablePreferenceboolIS_EQUALPolicies

Flight Implementation

See option_feature/flight/ and preference/flight_preferences/ for implementations.

Features

FeatureTypeCategoryDescription
TotalPriceFeaturefloatPricingTotal flight price
NumberOfLegsFeatureintRouteNumber of segments
ValidatingCarrierFeaturestrAirlineTicketing airline
TotalDurationFeatureintScheduleDuration in minutes
TotalEmissionsFeaturefloatEnvironmentalCO2 emissions (kg)
CabinClassFeaturelist[CabinType]ComfortCabin per leg
DepartureTimeFeaturedatetimeScheduleFirst leg departure

Preferences

PreferenceTypeOperator
AirlinePreferencestrIS_EQUAL
MaximumFlightPricePreferencefloatIS_LESS_THAN
MaximumNumberOfLegsPreferenceintIS_LESS_THAN_OR_EQUAL
CabinClassPreferencestrIS_EQUAL
FlightIsRefundablePreferenceboolIS_EQUAL

Registry System

Features and preferences are automatically registered using metaclasses. See PreferenceRegistry and PreferenceFactory.

Source Files Reference

PurposePath
ScoringCriterionmodels/core_models/scoring/scoring_criterion.py
OptionFeaturemodels/core_models/scoring/option_feature/option_feature.py
Preferencemodels/core_models/scoring/preference/preference.py
PreferenceFactorymodels/core_models/scoring/preference/preference_factory.py
AccommodationFeaturesmodels/core_models/scoring/option_feature/accommodation/
FlightFeaturesmodels/core_models/scoring/option_feature/flight/