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

Add testing #102

Merged
Merged

Conversation

jrbalch543
Copy link

This should lock in what currently is getting returned, with a little room for variance. Asserts everything exists and is reasonable. Can certainly be edited, this isn't exactly exhaustive testing.

Copy link
Contributor

@riley-harper riley-harper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One minor stylistic comment. I will run the GitHub Actions workflow on this PR and then we can merge it into the fix_get_feature_importances branch and that branch's PR will also be ready for review.

tf = spark.table("training_feature_importances").toPandas()
for var in training_conf["training"]["independent_vars"]:
assert not tf.loc[tf["feature_name"].str.startswith(f"{var}", na=False)].empty
assert all([col in ['feature_name', 'coefficient_or_importance'] for col in tf.columns])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should be able to use a generator expression instead of a list comprehension, which means we can drop the outermost pair of [s. This is not a big deal, but a nice style thing.

@@ -88,7 +88,7 @@ def _run(self):
features_df = self.task.spark.createDataFrame(
zip(column_names, feature_importances),
"feature_name: string, coefficient_or_importance: double",
).sort("importance", ascending=False)
).sort("coefficient_or_importance", ascending=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This small bug fix was made on the target branch too, looks good. 👍

@riley-harper riley-harper merged commit 440cdff into ipums:fix_get_feature_importances Oct 23, 2023
2 checks passed
@jrbalch543 jrbalch543 deleted the add_testing branch October 24, 2023 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants