Skip to content

Commit

Permalink
various minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fradav committed Jun 3, 2021
1 parent 3bc21cf commit a80949e
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions src/EstimParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ EstimParamResults EstimParam_fun(Reftable<MatrixType> &myread,
if (!quiet) {
std::cout << "Computing PLS axis" << std::endl;
}
const std::string &pls_filename = outfile + ".plsvar";
std::ofstream pls_file;
if (!quiet)
pls_file.open(pls_filename, std::ios::out);

auto validvars = filterConstantVars(myread.stats);
if (plsmaxvar == 0.0)
Expand Down Expand Up @@ -145,16 +141,17 @@ EstimParamResults EstimParam_fun(Reftable<MatrixType> &myread,
}

//res.plsvar = std::vector<double>(percentYvar.size());
for (auto p : res.plsvar)
if (!quiet)
{
pls_file << p << std::endl;
pls_file.close();
}
if (!quiet) {
const std::string &pls_filename = outfile + ".plsvar";
std::ofstream pls_file;
pls_file.open(pls_filename, std::ios::out);
for (auto p : res.plsvar) pls_file << p << std::endl;
pls_file.close();

if (!quiet)
std::cout << std::endl << "Selecting only " << nComposante_sel << " pls components." << std::endl;

}

double sumPlsweights = Projection.col(0).array().abs().sum();
auto weightedPlsfirst = Projection.col(0) / sumPlsweights;

Expand Down Expand Up @@ -460,39 +457,41 @@ EstimParamResults EstimParam_fun(Reftable<MatrixType> &myread,
normalize = (m != "mean") ? ntest : nref;
else
normalize = (m == "median") ? sumw[j] : 1;
if (m != "ci")
{
os << mean_median_ci[m] << std::endl;
for (auto n : computed)
if (normalize > 0.0) {
if (m != "ci")
{
res.errors[g_l.first][j][m][n] /= static_cast<double>(normalize);
os << fmt::format("{:>25} : {:<13}", n, res.errors[g_l.first][j][m][n]) << std::endl;
os << mean_median_ci[m] << std::endl;
for (auto n : computed)
{
res.errors[g_l.first][j][m][n] /= static_cast<double>(normalize);
os << fmt::format("{:>25} : {:<13}", n, res.errors[g_l.first][j][m][n]) << std::endl;
}
}
}
else
{
if (g_l.first == "global")
else
{
os << mean_median_ci[m] << std::endl;
for (auto c : ci)
if (g_l.first == "global")
{
if (c.first == "cov")
{
acc = res.errors[g_l.first][j][m][c.first] / static_cast<double>(normalize);
}
else
os << mean_median_ci[m] << std::endl;
for (auto c : ci)
{
if (c.first == "meanCI")
acc = ranges::accumulate(rCI, 0.0) / static_cast<double>(normalize);
else if (c.first == "meanRCI")
acc = ranges::accumulate(relativeCI, 0.0) / static_cast<double>(normalize);
else if (c.first == "medianCI")
acc = median(rCI);
else if (c.first == "medianRCI")
acc = median(relativeCI);
if (c.first == "cov")
{
acc = res.errors[g_l.first][j][m][c.first] / static_cast<double>(normalize);
}
else
{
if (c.first == "meanCI")
acc = ranges::accumulate(rCI, 0.0) / static_cast<double>(normalize);
else if (c.first == "meanRCI")
acc = ranges::accumulate(relativeCI, 0.0) / static_cast<double>(normalize);
else if (c.first == "medianCI")
acc = median(rCI);
else if (c.first == "medianRCI")
acc = median(relativeCI);
}
res.errors[g_l.first][j][m][c.first] = acc;
os << fmt::format("{:>25} : {:<13}", c.second, acc) << std::endl;
}
res.errors[g_l.first][j][m][c.first] = acc;
os << fmt::format("{:>25} : {:<13}", c.second, acc) << std::endl;
}
}
}
Expand Down

0 comments on commit a80949e

Please sign in to comment.