-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allowing to use Memory
in Pipeline
#52
Allowing to use Memory
in Pipeline
#52
Conversation
…ing-memory' into 51-pipeline-does-fails-when-setting-memory
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.
I have some problems with the design of unit test. These should be fixed before merging.
tests/test_pipeline.py
Outdated
|
||
# Compare results | ||
self.assertTrue(np.allclose(pred1, pred2)) | ||
self.assertLess(time2, time1) |
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.
Testing timings in unit tests is considered a bad thing. Timings depend on many external circumstances. Our code can be correct even when these external circumstances lead to bad runtimes. Instead, I would just test to ensure that the results are correct.
You could also add a test that tests that the cached element is used and not recreated every time the pipeline is called. Maybe wrap the featurization-element in a Wrapper class that counts executions of the fit_transform method, like:
class MyWrapper:
def __init__(element):
self.counter = 0
self.element = element
def fit_transform(X, y):
self.counter += 1
return self.element.fit_transform(X, y)
featurization_element_wrapped = MyWrapper(MorganFP())
pipeline = Pipeline([
..,
("featurizater", featurization_element_wrapped),
..]
pipeline.fit(X,y)
self.assertEqual(featurization_element_wrapped.counter, 1)
Note that this should only work when you don't parallelize the execution.
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.
Implemented. I had to make the counter
var a global var, as otherwise the hash of the object would be changed. It is kind of ugly, do you have a better idea?
Currently fails docsig. Assumingly, this is a docsig error, as this only occurs for 0.59.0. See this issue. |
No description provided.