Skip to content

Commit

Permalink
Fix checking for const label github #1933
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgueni-Petrov-aka-espetrov committed Jan 17, 2024
1 parent 9063f6a commit 79f1702
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions catboost/private/libs/target/target_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,8 @@ namespace NCB {

class TMakeClassLabelsTargetConverter : public ITargetConverter {
public:
TMakeClassLabelsTargetConverter(bool isMultiClass)
: IsMultiClass(isMultiClass)
, TargetType(ERawTargetType::None) // just some default
TMakeClassLabelsTargetConverter()
: TargetType(ERawTargetType::None) // just some default
{}

TVector<float> Process(
Expand Down Expand Up @@ -371,14 +370,6 @@ namespace NCB {
}

private:
void CheckUniqueLabelsSize(size_t size) const {
CB_ENSURE(size > 1, "Target contains only one unique value");
CB_ENSURE(
IsMultiClass || (size == 2),
"Target with classes must contain only 2 unique values for binary classification"
);
}

TVector<float> ProcessMakeClassLabelsImpl(const ITypedSequencePtr<float>& labels,
NPar::ILocalExecutor* localExecutor) {
CB_ENSURE_INTERNAL(
Expand All @@ -394,8 +385,6 @@ namespace NCB {
uniqueLabelsSet.insert(value);
}

CheckUniqueLabelsSize(uniqueLabelsSet.size());

TVector<float> uniqueLabels(uniqueLabelsSet.begin(), uniqueLabelsSet.end());
Sort(uniqueLabels);

Expand Down Expand Up @@ -436,7 +425,6 @@ namespace NCB {
);

THashSet<TString> uniqueLabelsSet(labels.begin(), labels.end());
CheckUniqueLabelsSize(uniqueLabelsSet.size());

TVector<TString> uniqueLabels(uniqueLabelsSet.begin(), uniqueLabelsSet.end());
// Kind of heuristic for proper ordering class names if they all are numeric
Expand Down Expand Up @@ -470,8 +458,6 @@ namespace NCB {
}

private:
bool IsMultiClass;

ERawTargetType TargetType;

// which map is used depends on source target data type
Expand Down Expand Up @@ -638,7 +624,7 @@ namespace NCB {
}


return MakeHolder<TMakeClassLabelsTargetConverter>(isMultiClass);
return MakeHolder<TMakeClassLabelsTargetConverter>();
}

} // NCB

0 comments on commit 79f1702

Please sign in to comment.