| OLD | NEW |
| 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/translate/core/browser/translate_ranker_impl.h" | 5 #include "components/translate/core/browser/translate_ranker_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 model_->proto().translate().logistic_regression_model(); | 252 model_->proto().translate().logistic_regression_model(); |
| 253 | 253 |
| 254 double dot_product = | 254 double dot_product = |
| 255 (features.accepted_count * logit.accept_count_weight()) + | 255 (features.accepted_count * logit.accept_count_weight()) + |
| 256 (features.denied_count * logit.decline_count_weight()) + | 256 (features.denied_count * logit.decline_count_weight()) + |
| 257 (features.ignored_count * logit.ignore_count_weight()) + | 257 (features.ignored_count * logit.ignore_count_weight()) + |
| 258 (features.accepted_ratio * logit.accept_ratio_weight()) + | 258 (features.accepted_ratio * logit.accept_ratio_weight()) + |
| 259 (features.denied_ratio * logit.decline_ratio_weight()) + | 259 (features.denied_ratio * logit.decline_ratio_weight()) + |
| 260 (features.ignored_ratio * logit.ignore_ratio_weight()) + | 260 (features.ignored_ratio * logit.ignore_ratio_weight()) + |
| 261 ScoreComponent(logit.source_language_weight(), features.src_lang) + | 261 ScoreComponent(logit.source_language_weight(), features.src_lang) + |
| 262 ScoreComponent(logit.dest_language_weight(), features.dst_lang) + | 262 ScoreComponent(logit.target_language_weight(), features.dst_lang) + |
| 263 ScoreComponent(logit.country_weight(), features.country) + | 263 ScoreComponent(logit.country_weight(), features.country) + |
| 264 ScoreComponent(logit.locale_weight(), features.app_locale); | 264 ScoreComponent(logit.locale_weight(), features.app_locale); |
| 265 | 265 |
| 266 return Sigmoid(dot_product + logit.bias()); | 266 return Sigmoid(dot_product + logit.bias()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void TranslateRankerImpl::FlushTranslateEvents( | 269 void TranslateRankerImpl::FlushTranslateEvents( |
| 270 std::vector<metrics::TranslateEventProto>* events) { | 270 std::vector<metrics::TranslateEventProto>* events) { |
| 271 DCHECK(sequence_checker_.CalledOnValidSequence()); | 271 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 272 DVLOG(3) << "Flushing translate ranker events."; | 272 DVLOG(3) << "Flushing translate ranker events."; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 292 return model_loader_ != nullptr; | 292 return model_loader_ != nullptr; |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace translate | 295 } // namespace translate |
| 296 | 296 |
| 297 std::ostream& operator<<(std::ostream& stream, | 297 std::ostream& operator<<(std::ostream& stream, |
| 298 const translate::TranslateRankerFeatures& features) { | 298 const translate::TranslateRankerFeatures& features) { |
| 299 features.WriteTo(stream); | 299 features.WriteTo(stream); |
| 300 return stream; | 300 return stream; |
| 301 } | 301 } |
| OLD | NEW |