-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to hide the title when plotting evaluation reports.
PiperOrigin-RevId: 571061008
- Loading branch information
1 parent
b4f039f
commit 0cd75ba
Showing
14 changed files
with
418 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
yggdrasil_decision_forests/port/python/ydf/metric/metric.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2022 Google LLC. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
#include <string> | ||
|
||
#include "absl/status/statusor.h" | ||
#include "pybind11_abseil/status_casters.h" | ||
#include "pybind11_protobuf/native_proto_caster.h" | ||
#include "yggdrasil_decision_forests/metric/metric.pb.h" | ||
#include "yggdrasil_decision_forests/metric/report.h" | ||
|
||
namespace py = ::pybind11; | ||
|
||
namespace yggdrasil_decision_forests::port::python { | ||
namespace { | ||
|
||
absl::StatusOr<std::string> EvaluationToStr( | ||
const metric::proto::EvaluationResults& evaluation) { | ||
return metric::TextReport(evaluation); | ||
} | ||
|
||
absl::StatusOr<std::string> EvaluationPlotToHtml( | ||
const metric::proto::EvaluationResults& evaluation) { | ||
std::string html; | ||
metric::HtmlReportOptions options; | ||
options.plot_width = 500; | ||
options.plot_height = 400; | ||
options.include_text_report = false; | ||
options.include_title = false; | ||
options.num_plots_per_columns = 2; | ||
RETURN_IF_ERROR(metric::AppendHtmlReport(evaluation, &html, options)); | ||
return html; | ||
} | ||
|
||
} // namespace | ||
|
||
void init_metric(py::module_& m) { | ||
m.def("EvaluationToStr", EvaluationToStr, py::arg("evaluation")); | ||
m.def("EvaluationPlotToHtml", EvaluationPlotToHtml, py::arg("evaluation")); | ||
} | ||
|
||
} // namespace yggdrasil_decision_forests::port::python |
27 changes: 27 additions & 0 deletions
27
yggdrasil_decision_forests/port/python/ydf/metric/metric.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2022 Google LLC. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef YGGDRASIL_DECISION_FORESTS_PORT_PYTHON_METRIC_METRIC_H_ | ||
#define YGGDRASIL_DECISION_FORESTS_PORT_PYTHON_METRIC_METRIC_H_ | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace yggdrasil_decision_forests::port::python { | ||
|
||
void init_metric(pybind11::module_ &m); | ||
|
||
} // namespace yggdrasil_decision_forests::port::python | ||
|
||
#endif // YGGDRASIL_DECISION_FORESTS_PORT_PYTHON_METRIC_METRIC_H_ |
Oops, something went wrong.