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

style: update prediction type to all caps #4237

Merged
merged 10 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions .vscode/new_reduction.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
" auto* base = VW::LEARNER::as_singleline(stack_builder.setup_base_learner());",
" auto* learner = VW::LEARNER::make_reduction_learner(",
" std::move(data), base, learn, predict, stack_builder.get_setupfn_name(reduction_setup))",
" .set_output_prediction_type(VW::prediction_type_t::scalar)",
" .set_output_prediction_type(VW::prediction_type_t::SCALAR)",
" .set_input_label_type(VW::label_type_t::simple)",
" .set_finish_example(finish_example)",
" .build();",
Expand Down Expand Up @@ -123,7 +123,7 @@
" auto* base = VW::LEARNER::as_multiline(stack_builder.setup_base_learner());",
" auto* learner = VW::LEARNER::make_reduction_learner(",
" std::move(data), base, learn, predict, stack_builder.get_setupfn_name(reduction_setup))",
" .set_output_prediction_type(prediction_type_t::scalar)",
" .set_output_prediction_type(prediction_type_t::SCALAR)",
" .set_input_label_type(label_type_t::simple)",
" .set_finish_example(finish_example)",
" .build();",
Expand Down
22 changes: 11 additions & 11 deletions cs/cli/vw_prediction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ uint32_t VowpalWabbitMulticlassPredictionFactory::Create(VW::workspace* vw, exam
}

cli::array<int>^ VowpalWabbitMultilabelPredictionFactory::Create(VW::workspace* vw, example* ex)
{ CheckExample(vw, ex, prediction_type_t::multilabels);
{ CheckExample(vw, ex, prediction_type_t::MULTILABELS);

size_t length;
uint32_t* labels;
Expand Down Expand Up @@ -163,7 +163,7 @@ cli::array<float>^ VowpalWabbitTopicPredictionFactory::Create(VW::workspace* vw,

VowpalWabbitActiveMulticlass^ VowpalWabbitActiveMulticlassPredictionFactory::Create(VW::workspace* vw, example* ex)
{
CheckExample(vw, ex, prediction_type_t::active_multiclass);
CheckExample(vw, ex, prediction_type_t::ACTIVE_MULTICLASS);
auto struct_obj = gcnew VowpalWabbitActiveMulticlass();
const auto length = ex->pred.active_multiclass.more_info_required_for_classes.size();
struct_obj->more_info_required_for_classes = gcnew cli::array<int>((int)length);
Expand All @@ -184,23 +184,23 @@ System::Object^ VowpalWabbitDynamicPredictionFactory::Create(VW::workspace* vw,
throw gcnew ArgumentNullException("ex");

switch (vw->l->get_output_prediction_type())
{ case prediction_type_t::scalar:
{ case prediction_type_t::SCALAR:
return VowpalWabbitPredictionType::Scalar->Create(vw, ex);
case prediction_type_t::scalars:
case prediction_type_t::SCALARS:
return VowpalWabbitPredictionType::Scalars->Create(vw, ex);
case prediction_type_t::multiclass:
case prediction_type_t::MULTICLASS:
return VowpalWabbitPredictionType::Multiclass->Create(vw, ex);
case prediction_type_t::multilabels:
case prediction_type_t::MULTILABELS:
return VowpalWabbitPredictionType::Multilabel->Create(vw, ex);
case prediction_type_t::action_scores:
case prediction_type_t::ACTION_SCORES:
return VowpalWabbitPredictionType::ActionScore->Create(vw, ex);
case prediction_type_t::action_probs:
case prediction_type_t::ACTION_PROBS:
return VowpalWabbitPredictionType::ActionProbabilities->Create(vw, ex);
case prediction_type_t::prob:
case prediction_type_t::PROB:
return VowpalWabbitPredictionType::Probability->Create(vw, ex);
case prediction_type_t::multiclassprobs:
case prediction_type_t::MULTICLASSprobs:
return VowpalWabbitPredictionType::MultiClassProbabilities->Create(vw, ex);
case prediction_type_t::active_multiclass:
case prediction_type_t::ACTIVE_MULTICLASS:
return VowpalWabbitPredictionType::ActiveMulticlass->Create(vw, ex);
default:
{ auto sb = gcnew StringBuilder();
Expand Down
22 changes: 11 additions & 11 deletions cs/cli/vw_prediction.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public ref class VowpalWabbitScalarPredictionFactory sealed : IVowpalWabbitPredi
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::scalar; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::SCALAR; }
}
};

Expand Down Expand Up @@ -101,7 +101,7 @@ public ref class VowpalWabbitScalarConfidencePredictionFactory sealed : IVowpalW
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::scalar; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::SCALAR; }
}
};

Expand All @@ -121,7 +121,7 @@ public ref class VowpalWabbitScalarsPredictionFactory sealed : IVowpalWabbitPred
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::scalars; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::SCALARS; }
}
};

Expand All @@ -141,7 +141,7 @@ public ref class VowpalWabbitProbabilityPredictionFactory sealed : IVowpalWabbit
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::prob; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::PROB; }
}
};

Expand All @@ -161,7 +161,7 @@ public ref class VowpalWabbitCostSensitivePredictionFactory sealed : IVowpalWabb
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::multiclass; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::MULTICLASS; }
}
};

Expand All @@ -181,7 +181,7 @@ public ref class VowpalWabbitMulticlassPredictionFactory sealed : IVowpalWabbitP
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::multiclass; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::MULTICLASS; }
}
};

Expand All @@ -202,7 +202,7 @@ public ref class VowpalWabbitMulticlassProbabilitiesPredictionFactory sealed : I
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::multiclassprobs; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::MULTICLASSprobs; }
}
};

Expand All @@ -222,7 +222,7 @@ public ref class VowpalWabbitMultilabelPredictionFactory sealed : IVowpalWabbitP
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::multilabels; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::MULTILABELS; }
}
};

Expand Down Expand Up @@ -265,7 +265,7 @@ public ref class VowpalWabbitActionScorePredictionFactory sealed
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() override sealed { return VW::prediction_type_t::action_scores; }
virtual VW::prediction_type_t get() override sealed { return VW::prediction_type_t::ACTION_SCORES; }
}
};

Expand All @@ -281,7 +281,7 @@ public ref class VowpalWabbitActionProbabilitiesPredictionFactory sealed
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() override sealed { return VW::prediction_type_t::action_probs; }
virtual VW::prediction_type_t get() override sealed { return VW::prediction_type_t::ACTION_PROBS; }
}
};

Expand Down Expand Up @@ -330,7 +330,7 @@ ref class VowpalWabbitActiveMulticlassPredictionFactory sealed
/// </summary>
property VW::prediction_type_t PredictionType
{
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::active_multiclass; }
virtual VW::prediction_type_t get() sealed { return VW::prediction_type_t::ACTIVE_MULTICLASS; }
}
};

Expand Down
20 changes: 10 additions & 10 deletions java/src/main/c++/jni_spark_vw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ jobject getJavaPrediction(JNIEnv* env, VW::workspace* all, example* ex)
jmethodID ctr;
switch (all->l->get_output_prediction_type())
{
case VW::prediction_type_t::scalar:
case VW::prediction_type_t::SCALAR:
predClass = env->FindClass("org/vowpalwabbit/spark/prediction/ScalarPrediction");
CHECK_JNI_EXCEPTION(nullptr);

Expand All @@ -1009,7 +1009,7 @@ jobject getJavaPrediction(JNIEnv* env, VW::workspace* all, example* ex)

return env->NewObject(predClass, ctr, VW::get_prediction(ex), ex->confidence);

case VW::prediction_type_t::prob:
case VW::prediction_type_t::PROB:
predClass = env->FindClass("java/lang/Float");
CHECK_JNI_EXCEPTION(nullptr);

Expand All @@ -1018,7 +1018,7 @@ jobject getJavaPrediction(JNIEnv* env, VW::workspace* all, example* ex)

return env->NewObject(predClass, ctr, ex->pred.prob);

case VW::prediction_type_t::multiclass:
case VW::prediction_type_t::MULTICLASS:
predClass = env->FindClass("java/lang/Integer");
CHECK_JNI_EXCEPTION(nullptr);

Expand All @@ -1027,25 +1027,25 @@ jobject getJavaPrediction(JNIEnv* env, VW::workspace* all, example* ex)

return env->NewObject(predClass, ctr, ex->pred.multiclass);

case VW::prediction_type_t::scalars:
case VW::prediction_type_t::SCALARS:
return scalars_predictor(ex, env);

case VW::prediction_type_t::action_probs:
case VW::prediction_type_t::ACTION_PROBS:
return action_probs_prediction(ex, env);

case VW::prediction_type_t::action_scores:
case VW::prediction_type_t::ACTION_SCORES:
return action_scores_prediction(ex, env);

case VW::prediction_type_t::multilabels:
case VW::prediction_type_t::MULTILABELS:
return multilabel_predictor(ex, env);

case VW::prediction_type_t::decision_probs:
case VW::prediction_type_t::DECISION_PROBS:
return decision_scores_prediction(ex, env);

case VW::prediction_type_t::pdf:
case VW::prediction_type_t::PDF:
return probability_density_function(ex, env);

case VW::prediction_type_t::action_pdf_value:
case VW::prediction_type_t::ACTION_PDF_VALUE:
return probability_density_function_value(ex, env);

default:
Expand Down
16 changes: 8 additions & 8 deletions java/src/main/c++/vowpalWabbit_learner_VWLearners.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,28 @@ JNIEXPORT jobject JNICALL Java_vowpalWabbit_learner_VWLearners_getReturnType(JNI
VW::workspace* vwInstance = (VW::workspace*)vwPtr;
switch (vwInstance->l->get_output_prediction_type())
{
case VW::prediction_type_t::action_probs:
case VW::prediction_type_t::ACTION_PROBS:
field = env->GetStaticFieldID(clVWReturnType, "ActionProbs", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::action_scores:
case VW::prediction_type_t::ACTION_SCORES:
field = env->GetStaticFieldID(clVWReturnType, "ActionScores", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::multiclass:
case VW::prediction_type_t::MULTICLASS:
field = env->GetStaticFieldID(clVWReturnType, "Multiclass", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::multilabels:
case VW::prediction_type_t::MULTILABELS:
field = env->GetStaticFieldID(clVWReturnType, "Multilabels", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::prob:
case VW::prediction_type_t::PROB:
field = env->GetStaticFieldID(clVWReturnType, "Prob", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::scalar:
case VW::prediction_type_t::SCALAR:
field = env->GetStaticFieldID(clVWReturnType, "Scalar", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::scalars:
case VW::prediction_type_t::SCALARS:
field = env->GetStaticFieldID(clVWReturnType, "Scalars", RETURN_TYPE_INSTANCE);
break;
case VW::prediction_type_t::decision_probs:
case VW::prediction_type_t::DECISION_PROBS:
field = env->GetStaticFieldID(clVWReturnType, "DecisionProbs", RETURN_TYPE_INSTANCE);
break;
default:
Expand Down
26 changes: 13 additions & 13 deletions python/pylibvw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,31 +463,31 @@ size_t my_get_prediction_type(vw_ptr all)
{
switch (all->l->get_output_prediction_type())
{
case VW::prediction_type_t::scalar:
case VW::prediction_type_t::SCALAR:
return pSCALAR;
case VW::prediction_type_t::scalars:
case VW::prediction_type_t::SCALARS:
return pSCALARS;
case VW::prediction_type_t::action_scores:
case VW::prediction_type_t::ACTION_SCORES:
return pACTION_SCORES;
case VW::prediction_type_t::action_probs:
case VW::prediction_type_t::ACTION_PROBS:
return pACTION_PROBS;
case VW::prediction_type_t::multiclass:
case VW::prediction_type_t::MULTICLASS:
return pMULTICLASS;
case VW::prediction_type_t::multilabels:
case VW::prediction_type_t::MULTILABELS:
return pMULTILABELS;
case VW::prediction_type_t::prob:
case VW::prediction_type_t::PROB:
return pPROB;
case VW::prediction_type_t::multiclassprobs:
case VW::prediction_type_t::MULTICLASSprobs:
bassmang marked this conversation as resolved.
Show resolved Hide resolved
return pMULTICLASSPROBS;
case VW::prediction_type_t::decision_probs:
case VW::prediction_type_t::DECISION_PROBS:
return pDECISION_SCORES;
case VW::prediction_type_t::action_pdf_value:
case VW::prediction_type_t::ACTION_PDF_VALUE:
return pACTION_PDF_VALUE;
case VW::prediction_type_t::pdf:
case VW::prediction_type_t::PDF:
return pPDF;
case VW::prediction_type_t::active_multiclass:
case VW::prediction_type_t::ACTIVE_MULTICLASS:
return pACTIVE_MULTICLASS;
case VW::prediction_type_t::nopred:
case VW::prediction_type_t::NOPRED:
return pNOPRED;
default:
THROW("unsupported prediction type used");
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/cats_tree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ learner<T, VW::example>* get_test_harness_reduction(const predictions_t& base_re
std::move(test_harness), // Data structure passed by vw_framework into test_harness predict/learn calls
reduction_test_harness::learn, // test_harness learn
reduction_test_harness::predict, // test_harness predict
"test_learner", VW::prediction_type_t::scalar, VW::label_type_t::CB)
"test_learner", VW::prediction_type_t::SCALAR, VW::label_type_t::CB)
.build(); // Create a learner using the base reduction.
return test_learner;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/offset_tree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test_learner_t* get_test_harness_reduction(const predictions_t& base_reduction_p
std::move(test_harness), // Data structure passed by vw_framework into test_harness predict/learn calls
reduction_test_harness::learn, // test_harness learn
reduction_test_harness::predict, // test_harness predict
"test_learner", VW::prediction_type_t::action_scores, VW::label_type_t::CB)
"test_learner", VW::prediction_type_t::ACTION_SCORES, VW::label_type_t::CB)
.build(); // Create a learner using the base reduction.
return test_learner;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/pmf_to_pdf_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test_learner_t* get_test_harness_reduction(const predictions_t& base_reduction_p
std::move(test_harness), // Data structure passed by vw_framework into test_harness predict/learn calls
reduction_test_harness::learn, // test_harness learn
reduction_test_harness::predict, // test_harness predict
"test_learner", VW::prediction_type_t::action_scores, VW::label_type_t::CONTINUOUS)
"test_learner", VW::prediction_type_t::ACTION_SCORES, VW::label_type_t::CONTINUOUS)
.build(); // Create a learner using the base reduction.
return test_learner;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/slates_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ VW::LEARNER::learner<test_base<LearnFunc, PredictFunc>, VW::multi_ex>* make_test
auto learn_fptr = &test_base<LearnFunc, PredictFunc>::invoke_learn;
auto predict_fptr = &test_base<LearnFunc, PredictFunc>::invoke_predict;
return VW::LEARNER::make_base_learner(std::move(test_base_data), static_cast<func>(learn_fptr),
static_cast<func>(predict_fptr), "mock_reduction", VW::prediction_type_t::decision_probs, VW::label_type_t::CCB)
static_cast<func>(predict_fptr), "mock_reduction", VW::prediction_type_t::DECISION_PROBS, VW::label_type_t::CCB)
.build();
}

Expand Down
2 changes: 1 addition & 1 deletion vowpalwabbit/core/include/vw/core/learner.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ class base_learner_builder

super::set_input_label_type(in_label_type);
super::set_output_label_type(label_type_t::NOLABEL);
super::set_input_prediction_type(prediction_type_t::nopred);
super::set_input_prediction_type(prediction_type_t::NOPRED);
super::set_output_prediction_type(out_pred_type);

set_params_per_weight(1);
Expand Down
Loading