diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp index a7aa799b0c2b7882e802484854ca2fb21f6e31ce..c4e23edd82e7c0df008ebe142ac84ff78eb51a63 100644 --- a/src/feature_creation/feature_space/FeatureSpace.cpp +++ b/src/feature_creation/feature_space/FeatureSpace.cpp @@ -1061,11 +1061,11 @@ void FeatureSpace::sis(std::shared_ptr<LossFunction> loss) // Generate features on the fly and get the best features for this rank if(_n_rung_generate > 0) { -#ifdef PARAMETERIZE + #ifdef PARAMETERIZE _phi.resize(_n_feat); _phi.insert(_phi.end(), _phi_reparam.begin() + _start_rung_reparam.back(), _phi_reparam.end()); _scores.resize(_phi.size()); -#endif + #endif start_time = omp_get_wtime(); phi_sel.resize(cur_feat_local); scores_sel.resize(cur_feat_local); diff --git a/tests/googletest/utils/test_compare_features.cc b/tests/googletest/utils/test_compare_features.cc index a976b7231d6f969bc7795dfbc08c6488f30a60ee..cbf0ff1af25616eba94e2e83b06e802dbfd3d790 100644 --- a/tests/googletest/utils/test_compare_features.cc +++ b/tests/googletest/utils/test_compare_features.cc @@ -12,22 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "gtest/gtest.h" -#include <utils/compare_features.hpp> -#include <feature_creation/node/ModelNode.hpp> +#include "feature_creation/node/ModelNode.hpp" +#include "mpi_interface/MPI_Ops.hpp" +#include "utils/compare_features.hpp" namespace { //test mean calculations TEST(CompFeats, CompFeatTest) { std::vector<double> val_1 = {1.0, 2.0, 3.0, 4.0}; - std::vector<double> val_2 = {2.0, 2.0, 3.0, 4.0}; + std::vector<double> val_2 = {2.0, 1.0, 3.0, 4.0}; std::vector<double> val_3 = {2.0, 4.0, 6.0, 8.0}; std::vector<double> target = {1.0, 3.0, 5.0, 6.0}; std::vector<double> scores = {0.9897782665572893}; + std::vector<node_ptr> selected(1); + std::vector<node_sc_pair> mpi_op_sel(1); node_value_arrs::initialize_values_arr({4}, {0}, 1, 0, false); selected[0] = std::make_shared<FeatureNode>(0, "A", val_3, std::vector<double>(), Unit()); + mpi_op_sel[0] = mpi_reduce_op::make_node_sc_pair(selected[0], scores[0]); node_value_arrs::initialize_d_matrix_arr(); node_value_arrs::resize_d_matrix_arr(1); @@ -36,13 +40,36 @@ namespace { EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893)); EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884)); + + EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893)); + + EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893)); + + EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884)); + + EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884)); + node_value_arrs::finalize_values_arr(); } }