Commit d219c1d1 authored by dominich@chromium.org's avatar dominich@chromium.org

Track confidence calculations better. Reduce minimum user text length.

Database sizes are low so it is safe to reduce the minimum user text length. This should increase coverage.

To help track potential coverage increases, it is good to remove trivial 0 confidences from the histogram of confidences.

BUG=107212,107213

Review URL: http://codereview.chromium.org/8870006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114091 0039d316-1c4b-4281-b951-d872f2087c98
parent 37643b3f
......@@ -35,7 +35,7 @@ const float kConfidenceCutoff[] = {
0.5f
};
const size_t kMinimumUserTextLength = 2;
const size_t kMinimumUserTextLength = 1;
const int kMinimumNumberOfHits = 3;
COMPILE_ASSERT(arraysize(kConfidenceCutoff) ==
......@@ -130,23 +130,20 @@ void NetworkActionPredictor::ClearTransitionalMatches() {
NetworkActionPredictor::Action NetworkActionPredictor::RecommendAction(
const string16& user_text,
const AutocompleteMatch& match) const {
double confidence = 0.0;
switch (prerender::GetOmniboxHeuristicToUse()) {
case prerender::OMNIBOX_HEURISTIC_EXACT:
case prerender::OMNIBOX_HEURISTIC_EXACT_FULL:
confidence = ExactAlgorithm(user_text, match);
break;
default:
NOTREACHED();
break;
};
DCHECK(prerender::GetOmniboxHeuristicToUse() ==
prerender::OMNIBOX_HEURISTIC_EXACT ||
prerender::GetOmniboxHeuristicToUse() ==
prerender::OMNIBOX_HEURISTIC_EXACT_FULL);
bool is_in_db = false;
const double confidence = CalculateConfidence(user_text, match, &is_in_db);
DCHECK(confidence >= 0.0 && confidence <= 1.0);
UMA_HISTOGRAM_COUNTS_100("NetworkActionPredictor.Confidence_" +
prerender::GetOmniboxHistogramSuffix(),
confidence * 100);
if (is_in_db) {
UMA_HISTOGRAM_COUNTS_100("NetworkActionPredictor.Confidence_" +
prerender::GetOmniboxHistogramSuffix(),
confidence * 100);
}
// Map the confidence to an action.
Action action = ACTION_NONE;
......@@ -383,11 +380,13 @@ bool NetworkActionPredictor::TryDeleteOldEntries(HistoryService* service) {
return true;
}
double NetworkActionPredictor::ExactAlgorithm(
double NetworkActionPredictor::CalculateConfidence(
const string16& user_text,
const AutocompleteMatch& match) const {
const AutocompleteMatch& match,
bool* is_in_db) const {
const DBCacheKey key = { user_text, match.destination_url };
*is_in_db = false;
if (user_text.length() < kMinimumUserTextLength)
return 0.0;
......@@ -395,6 +394,7 @@ double NetworkActionPredictor::ExactAlgorithm(
if (iter == db_cache_.end())
return 0.0;
*is_in_db = true;
const DBCacheValue& value = iter->second;
if (value.number_of_hits < kMinimumNumberOfHits)
return 0.0;
......
......@@ -146,9 +146,12 @@ class NetworkActionPredictor
bool TryDeleteOldEntries(HistoryService* service);
// Uses local caches to calculate an exact percentage prediction that the user
// will take a particular match given what they have typed.
double ExactAlgorithm(const string16& user_text,
const AutocompleteMatch& match) const;
// will take a particular match given what they have typed. |is_in_db| is set
// to differentiate trivial zero results resulting from a match not being
// found from actual zero results where the calculation returns 0.0.
double CalculateConfidence(const string16& user_text,
const AutocompleteMatch& match,
bool* is_in_db) const;
// Adds a row to the database and caches.
void AddRow(const DBCacheKey& key,
......
......@@ -38,11 +38,11 @@ struct TestUrlInfo {
} test_url_db[] = {
{ GURL("http://www.testsite.com/a.html"),
ASCIIToUTF16("Test - site - just a test"), 1,
ASCIIToUTF16("just"), 5, 0,
ASCIIToUTF16("j"), 5, 0,
NetworkActionPredictor::ACTION_PRERENDER },
{ GURL("http://www.testsite.com/b.html"),
ASCIIToUTF16("Test - site - just a test"), 1,
ASCIIToUTF16("just"), 3, 0,
ASCIIToUTF16("ju"), 3, 0,
NetworkActionPredictor::ACTION_PRERENDER },
{ GURL("http://www.testsite.com/c.html"),
ASCIIToUTF16("Test - site - just a test"), 5,
......@@ -62,7 +62,7 @@ struct TestUrlInfo {
NetworkActionPredictor::ACTION_PRERENDER },
{ GURL("http://www.testsite.com/g.html"),
ASCIIToUTF16("Test - site - just a test"), 12,
ASCIIToUTF16("j"), 5, 0,
ASCIIToUTF16(""), 5, 0,
NetworkActionPredictor::ACTION_NONE },
{ GURL("http://www.testsite.com/h.html"),
ASCIIToUTF16("Test - site - just a test"), 21,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment