MCPcopy Create free account
hub / github.com/catboost/catboost / CheckRawTarget

Function CheckRawTarget

catboost/libs/data/target.cpp:58–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58static void CheckRawTarget(ERawTargetType targetType, const TVector<TRawTarget>& target, ui32 objectCount) {
59 CB_ENSURE_INTERNAL(
60 !target.empty() || (targetType == ERawTargetType::None),
61 "Target data is specified but targetType is None"
62 );
63
64 for (auto i : xrange(target.size())) {
65 if (const ITypedSequencePtr<float>* typedSequence = std::get_if<ITypedSequencePtr<float>>(&target[i])) {
66 CB_ENSURE_INTERNAL(
67 (targetType == ERawTargetType::Boolean) ||
68 (targetType == ERawTargetType::Float) ||
69 (targetType == ERawTargetType::Integer),
70 "target data contains float values but targetType is " << targetType
71 );
72 CheckDataSize(
73 (*typedSequence)->GetSize(),
74 objectCount,
75 "Target[" + ToString(i) + "]",
76 false
77 );
78 if (targetType == ERawTargetType::Boolean) {
79 CheckContainsOnly01s(**typedSequence);
80 } else if (targetType == ERawTargetType::Integer) {
81 CheckContainsOnlyIntegers(**typedSequence);
82 }
83 } else {
84 CB_ENSURE_INTERNAL(
85 targetType == ERawTargetType::String,
86 "target data contains float values but targetType is " << targetType
87 );
88 const TVector<TString>& stringVector = std::get<TVector<TString>>(target[i]);
89 CheckDataSize(stringVector.size(), (size_t)objectCount, "Target[" + ToString(i) + "]", false);
90 for (auto j : xrange(stringVector.size())) {
91 CB_ENSURE(!stringVector[j].empty(), "Target[" << i << ", " << j << "] is empty");
92 }
93 }
94 }
95}
96
97
98static void CheckOneBaseline(TConstArrayRef<float> baseline, size_t idx, ui32 objectCount) {

Callers 1

CheckMethod · 0.85

Calls 8

xrangeFunction · 0.85
CheckDataSizeFunction · 0.85
CheckContainsOnly01sFunction · 0.85
ToStringFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected