Skip to content

added unit testing for ContextualizedClassifier models#153

Merged
cnellington merged 3 commits into
devfrom
loss#140
Dec 12, 2022
Merged

added unit testing for ContextualizedClassifier models#153
cnellington merged 3 commits into
devfrom
loss#140

Conversation

@juwaynilucman

@juwaynilucman juwaynilucman commented Dec 6, 2022

Copy link
Copy Markdown
Contributor

This is a follow-up on ContextualizedClassifier with BCELoss #140

test_classifier checks:

  • initial loss > final loss
  • predicted parameters are not Nan

Note: ran black on contextualized and made a new pylint badge

@cnellington cnellington left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! One comment to address.

alpha=1e-1, encoder_type='mlp'
)
self._quicktest(
model, C, X, Y, max_epochs=10

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Has 10 epochs been enough in your experience to get NaN values from the old classifier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using the sciPlex2 dataset, I used to get NaN values within the first epoch, so I assume 10 epochs will be enough for this test case.

Also, in my local machine, there are times when training in test_classifier.py and test_regressor.py ends before it reaches the assigned number of epochs. I am not sure why it happens, but could you confirm if it also happens in your machine?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Early stopping is enabled by default for the easy modules, but we should turn this off when testing the regression and classifier modules. Here's the relevant kwargs/callback constructor: https://github.com/cnellington/Contextualized/blob/30cb09c0261899584c61eb93997f1ca8a624ca3e/contextualized/easy/wrappers/SKLearnWrapper.py#L167
You should be able to disable this by setting es_patience to something like -1 or inf.

self._quicktest(
model, C, X, Y, max_epochs=10, es_patience=float('inf')
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lots of whitespace, let's run black and make a new pylint badge for this update. Tests look great though.

@cnellington cnellington left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great!

@cnellington cnellington merged commit e99d6b8 into dev Dec 12, 2022
@cnellington cnellington deleted the loss#140 branch December 12, 2022 01:10
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