diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index b0e62b6d3b..0c0d9f1326 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -69,10 +69,12 @@ PreRankerResult::PreRankerResult(FeatureID const & id, PreRankingInfo const & in } // static -bool PreRankerResult::LessRank(PreRankerResult const & r1, PreRankerResult const & r2) +bool PreRankerResult::LessRankAndPopularity(PreRankerResult const & r1, PreRankerResult const & r2) { if (r1.m_info.m_rank != r2.m_info.m_rank) return r1.m_info.m_rank > r2.m_info.m_rank; + if (r1.m_info.m_popularity != r2.m_info.m_popularity) + return r1.m_info.m_popularity > r2.m_info.m_popularity; return r1.m_info.m_distanceToPivot < r2.m_info.m_distanceToPivot; } diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index a2cd42ff20..e509b1ba0f 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -31,7 +31,7 @@ class PreRankerResult public: PreRankerResult(FeatureID const & id, PreRankingInfo const & info); - static bool LessRank(PreRankerResult const & r1, PreRankerResult const & r2); + static bool LessRankAndPopularity(PreRankerResult const & r1, PreRankerResult const & r2); static bool LessDistance(PreRankerResult const & r1, PreRankerResult const & r2); FeatureID const & GetId() const { return m_id; } diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp index 4ed40dea2b..4db663baaf 100644 --- a/search/pre_ranker.cpp +++ b/search/pre_ranker.cpp @@ -30,8 +30,9 @@ void SweepNearbyResults(double eps, set const & prevEmit, vector(m_rank) / numeric_limits::max(); + double const popularity = static_cast(m_popularity) / numeric_limits::max(); auto nameScore = m_nameScore; if (m_pureCats || m_falseCats) @@ -112,6 +115,7 @@ double RankingInfo::GetLinearModelRank() const double result = 0.0; result += kDistanceToPivot * distanceToPivot; result += kRank * rank; + result += kPopularity * popularity; result += kNameScore[nameScore]; result += kErrorsMade * GetErrorsMade(); result += kType[m_type]; diff --git a/search/search_quality/scoring_model.py b/search/search_quality/scoring_model.py index aa333ea52e..9ccc36bf4e 100755 --- a/search/search_quality/scoring_model.py +++ b/search/search_quality/scoring_model.py @@ -16,10 +16,11 @@ import sys MAX_DISTANCE_METERS = 2e6 MAX_RANK = 255 +MAX_POPULARITY = 255 RELEVANCES = {'Irrelevant': 0, 'Relevant': 1, 'Vital': 3} NAME_SCORES = ['Zero', 'Substring', 'Prefix', 'Full Match'] SEARCH_TYPES = ['POI', 'Building', 'Street', 'Unclassified', 'Village', 'City', 'State', 'Country'] -FEATURES = ['DistanceToPivot', 'Rank', 'FalseCats', 'ErrorsMade', 'AllTokensUsed'] + NAME_SCORES + SEARCH_TYPES +FEATURES = ['DistanceToPivot', 'Rank', 'Popularity', 'FalseCats', 'ErrorsMade', 'AllTokensUsed'] + NAME_SCORES + SEARCH_TYPES BOOTSTRAP_ITERATIONS = 10000 @@ -36,6 +37,7 @@ def normalize_data(data): data['DistanceToPivot'] = data['DistanceToPivot'].apply(transform_distance) data['Rank'] = data['Rank'].apply(lambda v: v / MAX_RANK) + data['Popularity'] = data['Popularity'].apply(lambda v: v / MAX_POPULARITY) data['Relevance'] = data['Relevance'].apply(lambda v: RELEVANCES[v]) cats = data['PureCats'].combine(data['FalseCats'], max)