本文整理汇总了C++中PJsonVal::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ PJsonVal::Empty方法的具体用法?C++ PJsonVal::Empty怎么用?C++ PJsonVal::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PJsonVal
的用法示例。
在下文中一共展示了PJsonVal::Empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExplainPositive
PJsonVal TDecisionTree::ExplainPositive() const {
if (!HasRoot()) { return TJsonVal::NewArr(); }
PJsonVal Result = Root->ExplainLabel(1);
if (Result.Empty()) { return TJsonVal::NewArr(); }
return Result;
}
示例2: PJsonVal
PJsonVal TDecisionTree::TNode::ExplainLabel(const int& Label) const {
if (IsLeaf()) {
if (ClassHist[Label] <= ClassHist[1 - Label]) {
return PJsonVal();
} else {
const double Prob = ClassHist[Label];
PJsonVal Result = TJsonVal::NewArr();
PJsonVal IntersectJson = TJsonVal::NewObj();
IntersectJson->AddToObj("covered", int(NExamples*Prob));
IntersectJson->AddToObj("purity", Prob);
IntersectJson->AddToObj("terms", TJsonVal::NewArr());
Result->AddToArr(IntersectJson);
return Result;
}
}
PJsonVal Result = TJsonVal::NewArr();
if (HasLeft()) {
PJsonVal LeftUnion = Left->ExplainLabel(Label);
if (!LeftUnion.Empty()) {
if (LeftUnion->GetArrVals() == 0) {
LeftUnion->AddToArr(TJsonVal::NewArr());
}
for (int i = 0; i < LeftUnion->GetArrVals(); i++) {
PJsonVal IntersectJson = LeftUnion->GetArrVal(i);
PJsonVal TermsJson = IntersectJson->GetObjKey("terms");
bool HadFtr = false;
for (int TermN = 0; TermN < TermsJson->GetArrVals(); TermN++) {
PJsonVal TermJson = TermsJson->GetArrVal(TermN);
const int TermFtrN = TermJson->GetObjInt("ftrId");
if (TermFtrN == CutFtrN) {
HadFtr = true;
if (TermJson->GetObjNum("le") == TFlt::PInf) {
TermJson->AddToObj("le", CutFtrVal);
}
}
}
if (!HadFtr) {
PJsonVal TermJson = TJsonVal::NewObj();
TermJson->AddToObj("ftrId", CutFtrN);
TermJson->AddToObj("le", CutFtrVal);
TermJson->AddToObj("gt", TFlt::NInf);
TermsJson->AddToArr(TermJson);
}
Result->AddToArr(IntersectJson);
}
}
}
if (HasRight()) {
PJsonVal RightUnion = Right->ExplainLabel(Label);
if (!RightUnion.Empty()) {
if (RightUnion->GetArrVals() == 0) {
RightUnion->AddToArr(TJsonVal::NewArr());
}
for (int i = 0; i < RightUnion->GetArrVals(); i++) {
PJsonVal IntersectJson = RightUnion->GetArrVal(i);
PJsonVal TermsJson = IntersectJson->GetObjKey("terms");
bool HadFtr = false;
for (int TermN = 0; TermN < TermsJson->GetArrVals(); TermN++) {
PJsonVal TermJson = TermsJson->GetArrVal(TermN);
const int TermFtrN = TermJson->GetObjInt("ftrId");
if (TermFtrN == CutFtrN) {
HadFtr = true;
if (TermJson->GetObjNum("gt") == TFlt::NInf) {
TermJson->AddToObj("gt", CutFtrVal);
}
}
}
if (!HadFtr) {
PJsonVal TermJson = TJsonVal::NewObj();
TermJson->AddToObj("ftrId", CutFtrN);
TermJson->AddToObj("le", TFlt::PInf);
TermJson->AddToObj("gt", CutFtrVal);
TermsJson->AddToArr(TermJson);
}
Result->AddToArr(IntersectJson);
}
}
}
return Result->GetArrVals() > 0 ? Result : PJsonVal();
}