Commit 505f7d6f authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Bug Fix: standardized values changes should now work

use stand_val everywhere
correct condition for pearson
parent 23f9e11d
......@@ -1136,7 +1136,7 @@ void FeatureSpace::generate_and_project(std::shared_ptr<LossFunction> loss, std:
{
if(
((phi_sel.size() < _n_sis_select) || (scores_sel_private[sc] < scores_sel[worst_score_ind])) &&
_is_valid_feat_list(phi_sel_private[sc]->value_ptr(), _n_samp_train, _cross_cor_max, phi_sel, scores_sel, scores_sel_private[sc])
_is_valid_feat_list(phi_sel_private[sc]->stand_value_ptr(), _n_samp_train, _cross_cor_max, phi_sel, scores_sel, scores_sel_private[sc])
)
{
if(phi_sel.size() == _n_sis_select)
......
......@@ -189,7 +189,6 @@ bool comp_feats::valid_feature_against_selected_pearson(
DGEMV_OUT.resize(end_sel - start_sel);
double base_val = std::inner_product(val_ptr, val_ptr + n_samp, val_ptr, 0.0) / static_cast<double>(n_samp);
volatile bool is_valid = true;
dgemv_(
'N',
DGEMV_OUT.size(),
......@@ -207,9 +206,7 @@ bool comp_feats::valid_feature_against_selected_pearson(
double comp_value = (
base_val - std::abs(DGEMV_OUT[idamax_(DGEMV_OUT.size(), DGEMV_OUT.data(), 1) - 1])
);
// std::cout << *val_ptr << '\t' << util_funcs::mean(val_ptr, n_samp) << '\t' << util_funcs::stand_dev(val_ptr, n_samp) << std::endl;
std::cout << comp_value << '\t' << base_val << '\t' << DGEMV_OUT[0] << std::endl;
return comp_value < (1.0 - cross_cor_max + 5.0e-9);
return std::abs(comp_value) >= (1.0 - cross_cor_max + 5.0e-9);
}
bool comp_feats::valid_feature_against_selected_pearson_feat_list(
......@@ -223,10 +220,10 @@ bool comp_feats::valid_feature_against_selected_pearson_feat_list(
{
double base_val = std::inner_product(val_ptr, val_ptr + n_samp, val_ptr, 0.0);
for(auto& feat : selected)
for(int ff = 0; ff < selected.size(); ++ff)
{
double comp_value = 1.0 / static_cast<double>(n_samp) * std::abs(
std::inner_product(val_ptr, val_ptr + n_samp, feat->stand_value_ptr(true), -base_val)
std::inner_product(val_ptr, val_ptr + n_samp, selected[ff]->stand_value_ptr(true), -base_val)
);
if(std::abs(comp_value) < (1.0 - cross_cor_max + 5.0e-9))
......
......@@ -23,6 +23,16 @@ namespace {
std::vector<double> val_1 = {1.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> stand_val_1(4, 0);
util_funcs::standardize(val_1.data(), 4, stand_val_1.data());
std::vector<double> stand_val_2(4, 0);
util_funcs::standardize(val_2.data(), 4, stand_val_2.data());
std::vector<double> stand_val_3(4, 0);
util_funcs::standardize(val_3.data(), 4, stand_val_3.data());
std::vector<double> target = {1.0, 3.0, 5.0, 6.0};
std::vector<double> scores = {0.9897782665572893};
......@@ -36,38 +46,39 @@ namespace {
node_value_arrs::resize_d_matrix_arr(1);
std::copy_n(val_3.data(), val_3.size(), node_value_arrs::get_d_matrix_ptr(0));
std::copy_n(stand_val_3.data(), stand_val_3.size(), node_value_arrs::get_stand_d_matrix_ptr(0));
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_max_corr_1(stand_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(stand_val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(stand_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_FALSE(comp_feats::valid_feature_against_selected_pearson(stand_val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_feat_list(stand_val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_mpi_op(stand_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_max_corr_1(stand_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(stand_val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(stand_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_TRUE(comp_feats::valid_feature_against_selected_pearson(stand_val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_feat_list(stand_val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_mpi_op(stand_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_max_corr_1(stand_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(stand_val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(stand_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_FALSE(comp_feats::valid_feature_against_selected_spearman(stand_val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_feat_list(stand_val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_mpi_op(stand_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_max_corr_1(stand_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(stand_val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(stand_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));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman(stand_val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_feat_list(stand_val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_mpi_op(stand_val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884));
node_value_arrs::finalize_values_arr();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment