Unverified Commit 7b411bdd authored by Guolin Ke's avatar Guolin Ke Committed by GitHub
Browse files

warning for init_score in save_binary (#2649)



* warning for init_score in save_binary

fix #2639

* Update metadata.cpp

* added info into docs
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
parent d9398434
...@@ -1109,6 +1109,9 @@ lgb.Dataset.set.reference <- function(dataset, reference) { ...@@ -1109,6 +1109,9 @@ lgb.Dataset.set.reference <- function(dataset, reference) {
#' Save \code{lgb.Dataset} to a binary file #' Save \code{lgb.Dataset} to a binary file
#' #'
#' Please note that \code{init_score} is not saved in binary file.
#' If you need it, please set it again after loading Dataset.
#'
#' @param dataset object of class \code{lgb.Dataset} #' @param dataset object of class \code{lgb.Dataset}
#' @param fname object filename of output file #' @param fname object filename of output file
#' #'
......
...@@ -15,7 +15,8 @@ lgb.Dataset.save(dataset, fname) ...@@ -15,7 +15,8 @@ lgb.Dataset.save(dataset, fname)
passed dataset passed dataset
} }
\description{ \description{
Save \code{lgb.Dataset} to a binary file Please note that \code{init_score} is not saved in binary file.
If you need it, please set it again after loading Dataset.
} }
\examples{ \examples{
library(lightgbm) library(lightgbm)
......
...@@ -593,6 +593,8 @@ IO Parameters ...@@ -593,6 +593,8 @@ IO Parameters
- if ``true``, LightGBM will save the dataset (including validation data) to a binary file. This speed ups the data loading for the next time - if ``true``, LightGBM will save the dataset (including validation data) to a binary file. This speed ups the data loading for the next time
- **Note**: ``init_score`` is not saved in binary file
- **Note**: can be used only in CLI version; for language-specific packages you can use the correspondent function - **Note**: can be used only in CLI version; for language-specific packages you can use the correspondent function
- ``header`` :raw-html:`<a id="header" title="Permalink to this parameter" href="#header">&#x1F517;&#xFE0E;</a>`, default = ``false``, type = bool, aliases: ``has_header`` - ``header`` :raw-html:`<a id="header" title="Permalink to this parameter" href="#header">&#x1F517;&#xFE0E;</a>`, default = ``false``, type = bool, aliases: ``has_header``
......
...@@ -563,6 +563,7 @@ struct Config { ...@@ -563,6 +563,7 @@ struct Config {
// alias = is_save_binary, is_save_binary_file // alias = is_save_binary, is_save_binary_file
// desc = if ``true``, LightGBM will save the dataset (including validation data) to a binary file. This speed ups the data loading for the next time // desc = if ``true``, LightGBM will save the dataset (including validation data) to a binary file. This speed ups the data loading for the next time
// desc = **Note**: ``init_score`` is not saved in binary file
// desc = **Note**: can be used only in CLI version; for language-specific packages you can use the correspondent function // desc = **Note**: can be used only in CLI version; for language-specific packages you can use the correspondent function
bool save_binary = false; bool save_binary = false;
......
...@@ -1149,6 +1149,11 @@ class Dataset(object): ...@@ -1149,6 +1149,11 @@ class Dataset(object):
def save_binary(self, filename): def save_binary(self, filename):
"""Save Dataset to a binary file. """Save Dataset to a binary file.
.. note::
Please note that `init_score` is not saved in binary file.
If you need it, please set it again after loading Dataset.
Parameters Parameters
---------- ----------
filename : string filename : string
......
...@@ -514,6 +514,10 @@ void Metadata::SaveBinaryToFile(const VirtualFileWriter* writer) const { ...@@ -514,6 +514,10 @@ void Metadata::SaveBinaryToFile(const VirtualFileWriter* writer) const {
if (!query_boundaries_.empty()) { if (!query_boundaries_.empty()) {
writer->Write(query_boundaries_.data(), sizeof(data_size_t) * (num_queries_ + 1)); writer->Write(query_boundaries_.data(), sizeof(data_size_t) * (num_queries_ + 1));
} }
if (num_init_score_ > 0) {
Log::Warning("Please note that `init_score` is not saved in binary file.\n"
"If you need it, please set it again after loading Dataset.");
}
} }
size_t Metadata::SizesInByte() const { size_t Metadata::SizesInByte() const {
......
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