From 91bd2ba9a9f11b05ca8e433ca51476f9f471f99c Mon Sep 17 00:00:00 2001 From: "ataymano@microsoft.com" Date: Fri, 22 Sep 2023 09:54:31 -0400 Subject: [PATCH] anchor features cleanup --- vowpalwabbit/core/src/reductions/interact.cc | 24 +------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/vowpalwabbit/core/src/reductions/interact.cc b/vowpalwabbit/core/src/reductions/interact.cc index 3c10b48ec80..2afbb72474a 100644 --- a/vowpalwabbit/core/src/reductions/interact.cc +++ b/vowpalwabbit/core/src/reductions/interact.cc @@ -28,28 +28,6 @@ class interact size_t num_features = 0; }; -bool contains_valid_namespaces(VW::features& f_src1, VW::features& f_src2, interact& in, VW::io::logger& logger) -{ - // first feature must be 1 so we're sure that the anchor feature is present - if (f_src1.size() == 0 || f_src2.size() == 0) { return false; } - - if (f_src1.values[0] != 1) - { - // Anchor feature must be a number instead of text so that the relative offsets functions correctly but I don't - // think we are able to test for this here. - logger.err_error("Namespace '{}' misses anchor feature with value 1", static_cast(in.n1)); - return false; - } - - if (f_src2.values[0] != 1) - { - logger.err_error("Namespace '{}' misses anchor feature with value 1", static_cast(in.n2)); - return false; - } - - return true; -} - void multiply(VW::features& f_dest, VW::features& f_src2, interact& in) { f_dest.clear(); @@ -102,7 +80,7 @@ void predict_or_learn(interact& in, VW::LEARNER::learner& base, VW::example& ec) VW::features& f1 = ec.feature_space[in.n1]; VW::features& f2 = ec.feature_space[in.n2]; - if (!contains_valid_namespaces(f1, f2, in, in.all->logger)) + if (f1.empty() || f2.empty()) { if (is_learn) { base.learn(ec); } else { base.predict(ec); }