forked from probsys/hierarchical-irm
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Restore pclean's ability to output its clusters #223
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0afe3e4
Restore pclean's ability to output its clusters
ThomasColthurst a73c4ea
Merge branch 'master' into 021024-thomaswc-gendb_encoding
ThomasColthurst a1a4a2f
Fix post-merge build errors and expand test
ThomasColthurst ca3d975
Add another test
ThomasColthurst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,3 +166,61 @@ observe | |
BOOST_TEST(samples.data["City"].size() == 10); | ||
BOOST_TEST(samples.data["State"].size() == 10); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(test_make_pclean_samples) { | ||
std::mt19937 prng; | ||
|
||
std::stringstream ss(R"""( | ||
class School | ||
name ~ string | ||
degree_dist ~ categorical(k=100) | ||
|
||
class Physician | ||
school ~ School | ||
degree ~ stringcat(strings="MD PT NP DO PHD") | ||
specialty ~ stringcat(strings="Family Med:Internal Med:Physical Therapy", delim=":") | ||
# observed_degree ~ maybe_swap(degree) | ||
|
||
class City | ||
name ~ string | ||
state ~ stringcat(strings="AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY") | ||
|
||
class Practice | ||
city ~ City | ||
|
||
class Record | ||
physician ~ Physician | ||
location ~ Practice | ||
|
||
observe | ||
physician.specialty as Specialty | ||
physician.school.name as School | ||
physician.degree as Degree | ||
location.city.name as City | ||
location.city.state as State | ||
from Record | ||
)"""); | ||
|
||
PCleanSchema pclean_schema; | ||
BOOST_TEST(read_schema(ss, &pclean_schema)); | ||
|
||
GenDB gendb(&prng, pclean_schema); | ||
|
||
T_encoding enc = make_dummy_encoding_from_gendb(gendb); | ||
|
||
BOOST_TEST(enc.second.size() == 0); | ||
|
||
std::map<std::string, ObservationVariant> obs = { | ||
{"Specialty", "Internal Med"}, | ||
{"School", "Harvard"}, | ||
{"Degree", "MD"}, | ||
{"City", "Cambridge"}, | ||
{"State", "MA"}}; | ||
|
||
gendb.incorporate(prng, {0, obs}, true); | ||
|
||
BOOST_TEST(enc.second["School"][0] == "School:0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider looping over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
BOOST_TEST(enc.second["Physician"][0] == "Physician:0"); | ||
BOOST_TEST(enc.second["City"][0] == "City:0"); | ||
BOOST_TEST(enc.second["Practice"][0] == "Practice:0"); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this include max table? (i.e. <= instead of <)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Fixed.