model.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_LEARNING_IMPL_MODEL_H_
  5. #define MEDIA_LEARNING_IMPL_MODEL_H_
  6. #include "base/callback.h"
  7. #include "base/component_export.h"
  8. #include "media/learning/common/labelled_example.h"
  9. #include "media/learning/common/target_histogram.h"
  10. namespace media {
  11. namespace learning {
  12. // One trained model, useful for making predictions.
  13. // TODO(liberato): Provide an API for incremental update, for those models that
  14. // can support it.
  15. class COMPONENT_EXPORT(LEARNING_IMPL) Model {
  16. public:
  17. // Callback for asynchronous predictions.
  18. using PredictionCB = base::OnceCallback<void(TargetHistogram predicted)>;
  19. virtual ~Model() = default;
  20. virtual TargetHistogram PredictDistribution(
  21. const FeatureVector& instance) = 0;
  22. // TODO(liberato): Consider adding an async prediction helper.
  23. };
  24. } // namespace learning
  25. } // namespace media
  26. #endif // MEDIA_LEARNING_IMPL_MODEL_H_