Improve parameter validation (#6769)
* Add quotes to unused parameters. * Check for whitespace.
This commit is contained in:
@@ -537,15 +537,18 @@ class LearnerConfiguration : public Learner {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(trivialfis): Make eval_metric a training parameter.
|
||||
keys.emplace_back(kEvalMetric);
|
||||
keys.emplace_back("verbosity");
|
||||
keys.emplace_back("num_output_group");
|
||||
|
||||
std::sort(keys.begin(), keys.end());
|
||||
|
||||
std::vector<std::string> provided;
|
||||
for (auto const &kv : cfg_) {
|
||||
// FIXME(trivialfis): Make eval_metric a training parameter.
|
||||
if (std::any_of(kv.first.cbegin(), kv.first.cend(),
|
||||
[](char ch) { return std::isspace(ch); })) {
|
||||
LOG(FATAL) << "Invalid parameter \"" << kv.first << "\" contains whitespace.";
|
||||
}
|
||||
provided.push_back(kv.first);
|
||||
}
|
||||
std::sort(provided.begin(), provided.end());
|
||||
@@ -557,9 +560,9 @@ class LearnerConfiguration : public Learner {
|
||||
std::stringstream ss;
|
||||
ss << "\nParameters: { ";
|
||||
for (size_t i = 0; i < diff.size() - 1; ++i) {
|
||||
ss << diff[i] << ", ";
|
||||
ss << "\"" << diff[i] << "\", ";
|
||||
}
|
||||
ss << diff.back();
|
||||
ss << "\"" << diff.back() << "\"";
|
||||
ss << R"W( } might not be used.
|
||||
|
||||
This may not be accurate due to some parameters are only used in language bindings but
|
||||
|
||||
Reference in New Issue
Block a user