Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do binomial check in label_encode functions only when adding new labels #1892

Merged
merged 2 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Thanks to everyone who helped make `datatable` more stable by discovering
and reporting bugs that were fixed in this release:

- [Arno Candel][] (#1619, #1730, #1738, #1800, #1803, #1846, #1857),
- [Arno Candel][] (#1619, #1730, #1738, #1800, #1803, #1846, #1857, #1891),
- [Antorsae][] (#1639),
- [Olivier][] (#1872),
- [Hawk Berry][] (#1834),
Expand Down
18 changes: 8 additions & 10 deletions c/models/label_encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ void label_encode_fw(const Column* col, dtptr& dt_labels, dtptr& dt_encoded) {
outdata[irow] = labels_map[v];
} else {
lock.exclusive_start();
if (stype_to == SType::BOOL && labels_map.size() == 2) {
throw ValueError() << "Target column for binomial problem cannot "
"contain more than two labels";
}

if (labels_map.count(v) == 0) {
if (stype_to == SType::BOOL && labels_map.size() == 2) {
throw ValueError() << "Target column for binomial problem cannot "
"contain more than two labels";
}
size_t nlabels = labels_map.size();
labels_map[v] = static_cast<T_to>(nlabels);
outdata[irow] = labels_map[v];
Expand Down Expand Up @@ -192,12 +191,11 @@ void label_encode_str(const Column* col, dtptr& dt_labels, dtptr& dt_encoded) {
outdata[irow] = labels_map[v];
} else {
lock.exclusive_start();
if (stype_to == SType::BOOL && labels_map.size() == 2) {
throw ValueError() << "Target column for binomial problem cannot "
"contain more than two labels";
}

if (labels_map.count(v) == 0) {
if (stype_to == SType::BOOL && labels_map.size() == 2) {
throw ValueError() << "Target column for binomial problem cannot "
"contain more than two labels";
}
size_t nlabels = labels_map.size();
labels_map[v] = static_cast<T_to>(nlabels);
outdata[irow] = labels_map[v];
Expand Down