Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: components/ntp_snippets/user_classifier.cc

Issue 2845483003: [User classifier] Adapt the defaults to planned M58 rollout (Closed)
Patch Set: Fix unit-tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/user_classifier.h" 5 #include "components/ntp_snippets/user_classifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cfloat> 8 #include <cfloat>
9 #include <string> 9 #include <string>
10 10
(...skipping 23 matching lines...) Expand all
34 const double kMaxHours = 7 * 24; 34 const double kMaxHours = 7 * 24;
35 const char kMaxHoursParam[] = "user_classifier_max_hours"; 35 const char kMaxHoursParam[] = "user_classifier_max_hours";
36 36
37 // Ignore events within |kMinHours| hours since the last event (|kMinHours| is 37 // Ignore events within |kMinHours| hours since the last event (|kMinHours| is
38 // the length of the browsing session where subsequent events of the same type 38 // the length of the browsing session where subsequent events of the same type
39 // do not count again). 39 // do not count again).
40 const double kMinHours = 0.5; 40 const double kMinHours = 0.5;
41 const char kMinHoursParam[] = "user_classifier_min_hours"; 41 const char kMinHoursParam[] = "user_classifier_min_hours";
42 42
43 // Classification constants. 43 // Classification constants.
44 const double kActiveConsumerClicksAtLeastOncePerHours = 72; 44 const double kActiveConsumerClicksAtLeastOncePerHours = 96;
45 const char kActiveConsumerClicksAtLeastOncePerHoursParam[] = 45 const char kActiveConsumerClicksAtLeastOncePerHoursParam[] =
46 "user_classifier_active_consumer_clicks_at_least_once_per_hours"; 46 "user_classifier_active_consumer_clicks_at_least_once_per_hours";
47 47
48 const double kRareUserOpensNTPAtMostOncePerHours = 96; 48 // The previous value in production was 72, i.e. 3 days. The new value is a
49 // cautios shift in the direction we want (having slightly more rare users).
50 const double kRareUserOpensNTPAtMostOncePerHours = 66;
49 const char kRareUserOpensNTPAtMostOncePerHoursParam[] = 51 const char kRareUserOpensNTPAtMostOncePerHoursParam[] =
50 "user_classifier_rare_user_opens_ntp_at_most_once_per_hours"; 52 "user_classifier_rare_user_opens_ntp_at_most_once_per_hours";
51 53
52 // Histograms for logging the estimated average hours to next event. 54 // Histograms for logging the estimated average hours to next event.
53 const char kHistogramAverageHoursToOpenNTP[] = 55 const char kHistogramAverageHoursToOpenNTP[] =
54 "NewTabPage.UserClassifier.AverageHoursToOpenNTP"; 56 "NewTabPage.UserClassifier.AverageHoursToOpenNTP";
55 const char kHistogramAverageHoursToShowSuggestions[] = 57 const char kHistogramAverageHoursToShowSuggestions[] =
56 "NewTabPage.UserClassifier.AverageHoursToShowSuggestions"; 58 "NewTabPage.UserClassifier.AverageHoursToShowSuggestions";
57 const char kHistogramAverageHoursToUseSuggestions[] = 59 const char kHistogramAverageHoursToUseSuggestions[] =
58 "NewTabPage.UserClassifier.AverageHoursToUseSuggestions"; 60 "NewTabPage.UserClassifier.AverageHoursToUseSuggestions";
59 61
60 // The enum used for iteration. 62 // The enum used for iteration.
61 const UserClassifier::Metric kMetrics[] = { 63 const UserClassifier::Metric kMetrics[] = {
62 UserClassifier::Metric::NTP_OPENED, 64 UserClassifier::Metric::NTP_OPENED,
63 UserClassifier::Metric::SUGGESTIONS_SHOWN, 65 UserClassifier::Metric::SUGGESTIONS_SHOWN,
64 UserClassifier::Metric::SUGGESTIONS_USED}; 66 UserClassifier::Metric::SUGGESTIONS_USED};
65 67
66 // The summary of the prefs. 68 // The summary of the prefs.
67 const char* kMetricKeys[] = { 69 const char* kMetricKeys[] = {
68 prefs::kUserClassifierAverageNTPOpenedPerHour, 70 prefs::kUserClassifierAverageNTPOpenedPerHour,
69 prefs::kUserClassifierAverageSuggestionsShownPerHour, 71 prefs::kUserClassifierAverageSuggestionsShownPerHour,
70 prefs::kUserClassifierAverageSuggestionsUsedPerHour}; 72 prefs::kUserClassifierAverageSuggestionsUsedPerHour};
71 const char* kLastTimeKeys[] = {prefs::kUserClassifierLastTimeToOpenNTP, 73 const char* kLastTimeKeys[] = {prefs::kUserClassifierLastTimeToOpenNTP,
72 prefs::kUserClassifierLastTimeToShowSuggestions, 74 prefs::kUserClassifierLastTimeToShowSuggestions,
73 prefs::kUserClassifierLastTimeToUseSuggestions}; 75 prefs::kUserClassifierLastTimeToUseSuggestions};
74 76
75 // Default lengths of the intervals for new users for the metrics. 77 // Default lengths of the intervals for new users for the metrics.
76 const double kInitialHoursBetweenEvents[] = {24, 48, 96}; 78 const double kInitialHoursBetweenEvents[] = {24, 48, 120};
77 const char* kInitialHoursBetweenEventsParams[] = { 79 const char* kInitialHoursBetweenEventsParams[] = {
78 "user_classifier_default_interval_ntp_opened", 80 "user_classifier_default_interval_ntp_opened",
79 "user_classifier_default_interval_suggestions_shown", 81 "user_classifier_default_interval_suggestions_shown",
80 "user_classifier_default_interval_suggestions_used"}; 82 "user_classifier_default_interval_suggestions_used"};
81 83
82 static_assert(arraysize(kMetrics) == 84 static_assert(arraysize(kMetrics) ==
83 static_cast<int>(UserClassifier::Metric::COUNT) && 85 static_cast<int>(UserClassifier::Metric::COUNT) &&
84 arraysize(kMetricKeys) == 86 arraysize(kMetricKeys) ==
85 static_cast<int>(UserClassifier::Metric::COUNT) && 87 static_cast<int>(UserClassifier::Metric::COUNT) &&
86 arraysize(kLastTimeKeys) == 88 arraysize(kLastTimeKeys) ==
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 377
376 void UserClassifier::SetMetricValue(Metric metric, double metric_value) { 378 void UserClassifier::SetMetricValue(Metric metric, double metric_value) {
377 pref_service_->SetDouble(kMetricKeys[static_cast<int>(metric)], metric_value); 379 pref_service_->SetDouble(kMetricKeys[static_cast<int>(metric)], metric_value);
378 } 380 }
379 381
380 void UserClassifier::ClearMetricValue(Metric metric) { 382 void UserClassifier::ClearMetricValue(Metric metric) {
381 pref_service_->ClearPref(kMetricKeys[static_cast<int>(metric)]); 383 pref_service_->ClearPref(kMetricKeys[static_cast<int>(metric)]);
382 } 384 }
383 385
384 } // namespace ntp_snippets 386 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698