Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Skellam out of domain bug; re-enable hospital integration test #166

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cxx/assets/hospital_dirty.10.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ProviderNumber,HospitalName,Address1,Address2,Address3,City,State,ZipCode,CountyName,PhoneNumber,HospitalType,HospitalOwner,EmergencyService,Condition,MeasureCode,MeasureName,Score,Sample,Stateavg
10018,callahan eye foundation hospital,1720 university blvd,,,birmingham,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-card-2,surgery patients who were taking heart drugs caxxed beta bxockers before coming to the hospitax who were kept on the beta bxockers during the period just before and after their surgery,,,al_scip-card-2
10018,callahan eye foundation hospital,1720 university blvd,,,birmingham,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-inf-1,surgery patients who were given an antibiotic at the right time (within one hour before surgery) to help prevent infection,,,al_scip-inf-1
10018,callahan eye foundation hospital,1720 university blvd,,,birmingham,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-inf-2,surgery patients who were given the right kind of antibiotic to help prevent infection,,,al_scip-inf-2
10018,callahan eye foundation hospital,1720 university blvd,,,birminghxm,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-inf-3,surgery patients whose preventive antibiotics were stopped at the right time (within 24 hours after surgery),,,al_scip-inf-3
10018,callahan eye foundation hospital,1720 university blvd,,,birmingham,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-inf-4,all heart surgery patients whose blood sugar (blood glucose) is kept under good control in the days right after surgery,,,al_scip-inf-4
10018,callahan eye foundation hospital,1720 university blvd,,,birmingham,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-inf-6,surgery patients needing hair removed from the surgical area before surgery who had hair removed using a safer method (electric clippers or hair removal cream c not a razor),,,al_scip-inf-6
10018,callahan eye foundation hospital,1720 university blvd,,,birmingham,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-vte-1,surgery patients whose doctors ordered treatments to prevent blood clots after certain types of surgeries,,,al_scip-vte-1
10018,callahan eye foundation hospital,1720 university blvd,,,birmingxam,al,35233,jefferson,2053258100,acute care hospitals,voluntary non-profit - private,yes,surgical infection prevention,scip-vte-2,patients who got treatment at the right time (within 24 hours before or after their surgery) to help prevent blood clots after certain types of surgery,,,al_scip-vte-2
10019,helen keller memorial hospital,1300 south montgomery avenue,,,sheffield,al,35660,jefferson,2563864556,acute care hospitals,government - hospital district or authority,yes,heart attack,ami-1,heart attack patients given aspirin at arrival,97%,33 patients,al_ami-1
2 changes: 1 addition & 1 deletion cxx/distributions/skellam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ double lognormal_logp(double x, double mean, double stddev) {
double Skellam::logp(const int&x) const {
return -mu1 - mu2 + (x / 2.0) * std::log(mu1 / mu2)
// TODO(thomaswc): Replace this with something more numerically stable.
+ std::log(std::cyl_bessel_i(x, 2.0 * std::sqrt(mu1 * mu2)));
+ std::log(std::cyl_bessel_i(std::abs(x), 2.0 * std::sqrt(mu1 * mu2)));
}

int Skellam::sample(std::mt19937* prng) {
Expand Down
4 changes: 4 additions & 0 deletions cxx/inference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void inference_irm(std::mt19937* prng, IRM* irm, int iters, int timeout,
clock_t t_begin = clock();
double t_total = 0;
for (int i = 0; i < iters; ++i) {
printf("Starting iteration %d, model score = %f\n",
i+1, irm->logp_score());
CHECK_TIMEOUT(timeout, t_begin);
single_step_irm_inference(prng, irm, t_total, verbose, 10, true);
}
Expand All @@ -42,6 +44,8 @@ void inference_hirm(std::mt19937* prng, HIRM* hirm, int iters, int timeout,
clock_t t_begin = clock();
double t_total = 0;
for (int i = 0; i < iters; ++i) {
printf("Starting iteration %d, model score = %f\n",
i+1, hirm->logp_score());
CHECK_TIMEOUT(timeout, t_begin);
// TRANSITION LATENT VALUES.
for (const auto& [rel, nrels] : hirm->base_to_noisy_relations) {
Expand Down
5 changes: 3 additions & 2 deletions cxx/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ set -e
set -x

# Run integration test suite
bazel build :hirm pclean:pclean tests:test_hirm_animals tests:test_irm_two_relations tests:test_misc
bazel build tests:test_hirm_animals tests:test_irm_two_relations tests:test_misc
./bazel-bin/tests/test_hirm_animals
./bazel-bin/tests/test_irm_two_relations
./bazel-bin/tests/test_misc
bazel build -c opt :hirm pclean:pclean
./bazel-bin/hirm --mode=irm --iters=5 assets/animals.binary
./bazel-bin/hirm --seed=1 --iters=5 assets/animals.unary
./bazel-bin/hirm --iters=5 --load=assets/animals.unary.1.hirm assets/animals.unary
#./bazel-bin/pclean/pclean --schema=assets/flights.schema --obs=assets/flights_dirty.100.csv --iters=5
#./bazel-bin/pclean/pclean --schema=assets/hospitals.schema --obs=assets/hospital_dirty.100.csv --iters=5
./bazel-bin/pclean/pclean --schema=assets/hospitals.schema --obs=assets/hospital_dirty.10.csv --iters=5
#./bazel-bin/pclean/pclean --schema=assets/rents.schema --obs=assets/rents_dirty.100.csv --iters=5
1 change: 1 addition & 0 deletions cxx/pclean/pclean.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ int main(int argc, char** argv) {
// Save results
if (result.count("output") > 0) {
std::string out_fn = result["output"].as<std::string>();
std::cout << "Savings results to " << out_fn << "\n";
to_txt(out_fn, hirm, encoding);
}

Expand Down