Skip to content

Commit

Permalink
[pipy] remove wip allproba and upgrade CI to macos ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
fradav committed Apr 25, 2024
1 parent e38289e commit e74327d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-11, windows-latest]
os: [ubuntu-22.04, macos-latest, windows-latest]
include:
- os: windows-latest
shortos: windows
Expand Down
6 changes: 3 additions & 3 deletions abcranger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
int main(const int argc, const char* argv[]) {
size_t nref, chosenscen;
std::string headerfile,reftablefile,statobsfile;

try {
size_t nref;
cxxopts::Options options(argv[0], " - ABC Random Forest - Model choice or parameter estimation command line options");
Expand Down Expand Up @@ -92,9 +92,9 @@ int main(const int argc, const char* argv[]) {



} catch (const cxxopts::OptionException& e)
} catch (const cxxopts::exceptions::exception& e)
{
std::cout << "error parsing options: " << e.what() << std::endl;
exit(1);
}
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ before-build = "pip install cmake & IF EXIST {project}\\build\\CMakeCache.txt DE

[tool.poetry]
name = "pyabcranger"
version = "0.70"
version = "0.71"
description = "Python bindings for the ABC-Ranger library"
authors = ["François-David Collin <Francois-David.Collin@umontpellier.fr>"]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setup(
name="pyabcranger",
version="0.0.70",
version="0.0.71",
author="François-David Collin",
author_email="fradav@gmail.com",
description="ABC random forests for model choice and parameter estimation, python wrapper",
Expand Down
80 changes: 60 additions & 20 deletions src/ModelChoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,67 @@ ModelChoiceResults ModelChoice_fun(Reftable<MatrixType> &myread,

myread.stats_names.resize(nstat);

// std::ostringstream os;
// if (num_samples > 1)
// os << fmt::format("{:>14}", "Target n°");
// for (auto i = 0; i < K; i++)
// {
// os << fmt::format("{:>14}", fmt::format("model{0}", i + 1));
// }
// os << fmt::format(" selected model");
// os << fmt::format(" post proba\n");
// for (auto j = 0; j < num_samples; j++)
// {
// if (num_samples > 1)
// os << fmt::format("{:>14}", j + 1);
// for (auto i = 0; i < K; i++)
// // os << fmt::format(" {:>13}", res.votes[j][i]);
// os << fmt::format("{:14.3f}", static_cast<double>(res.votes[j][i])/ntree);
// os << fmt::format("{:>15}", res.predicted_model[j] + 1);
// os << fmt::format("{:12.3f}\n", res.post_proba[j]);
// for (auto i = 0; i < K; i++)
// os << fmt::format("{:14.3f}", res.post_proba_all3[j][i]);
// os << fmt::format("{:>15}", res.predicted_model[j] + 1);
// os << fmt::format("{:12.3f}\n", total_postproba3[j]);
// for (auto i = 0; i < K; i++)
// os << fmt::format("{:14.3f}", res.post_proba_all[j][i]);
// os << fmt::format("{:>15}", res.predicted_model[j] + 1);
// os << fmt::format("{:12.3f}\n", total_postproba[j]);
// if (postproba_all) {
// // os << fmt::format("{:>14}"," post proba all:");
// for (auto i = 0; i < K; i++)
// os << fmt::format("{:14.3f}", res.post_proba_all2[j][i]);
// os << std::endl;

// }
// }
// if (!quiet)
// std::cout << os.str();
// std::cout.flush();

// std::ofstream predict_file;
// if (!quiet)
// {
// predict_file.open(predict_filename, std::ios::out);
// if (!predict_file.good())
// {
// throw std::runtime_error("Could not write to prediction file: " + predict_filename + ".");
// }
// predict_file << os.str();
// predict_file.flush();
// predict_file.close();
// }

res.post_proba = std::vector<double>(num_samples);
for (auto i = 0; i < num_samples; i++)
res.post_proba[i] = predserr[1][0][i];

std::ostringstream os;
if (num_samples > 1)
os << fmt::format("{:>14}", "Target n°");
for (auto i = 0; i < K; i++)
{
os << fmt::format("{:>14}", fmt::format("model{0}", i + 1));
os << fmt::format("{:>14}", fmt::format("votes model{0}", i + 1));
}
os << fmt::format(" selected model");
os << fmt::format(" post proba\n");
Expand All @@ -438,25 +493,11 @@ ModelChoiceResults ModelChoice_fun(Reftable<MatrixType> &myread,
if (num_samples > 1)
os << fmt::format("{:>14}", j + 1);
for (auto i = 0; i < K; i++)
// os << fmt::format(" {:>13}", res.votes[j][i]);
os << fmt::format("{:14.3f}", static_cast<double>(res.votes[j][i])/ntree);
os << fmt::format("{:>15}", res.predicted_model[j] + 1);
os << fmt::format("{:12.3f}\n", res.post_proba[j]);
for (auto i = 0; i < K; i++)
os << fmt::format("{:14.3f}", res.post_proba_all3[j][i]);
os << fmt::format("{:>15}", res.predicted_model[j] + 1);
os << fmt::format("{:12.3f}\n", total_postproba3[j]);
for (auto i = 0; i < K; i++)
os << fmt::format("{:14.3f}", res.post_proba_all[j][i]);
os << fmt::format("{:>15}", res.predicted_model[j] + 1);
os << fmt::format("{:12.3f}\n", total_postproba[j]);
if (postproba_all) {
// os << fmt::format("{:>14}"," post proba all:");
for (auto i = 0; i < K; i++)
os << fmt::format("{:14.3f}", res.post_proba_all2[j][i]);
os << std::endl;

{
os << fmt::format(" {:>13}", res.votes[j][i]);
}
os << fmt::format("{:>15}", res.predicted_model[j] + 1);
os << fmt::format("{:12.3f}\n", 1 - res.post_proba[j]);
}
if (!quiet)
std::cout << os.str();
Expand All @@ -474,7 +515,6 @@ ModelChoiceResults ModelChoice_fun(Reftable<MatrixType> &myread,
predict_file.flush();
predict_file.close();
}

// Pour Arnaud
// Global_error_rate Local_error rate* Vote_S1 Vote_S2 Vote_S2 Vote_S3 Vote_S5 Vote_S6 Posterior_probability_S3(best)
// std::ofstream mer_file;
Expand Down

0 comments on commit e74327d

Please sign in to comment.