-
-
Notifications
You must be signed in to change notification settings - Fork 112
Tests: Simple sense test for linear regression #39
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
Conversation
Not relevant to this PR, but once #41 gets merged we'll have all the distributions 😄 |
Ahh cool, then we'll be able to do some other tests
…On Sat, Jan 12, 2019 at 6:05 PM George Ho ***@***.***> wrote:
Not relevant to this PR, but once #41
<#41> gets merged we'll have all
the distributions 😄
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#39 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8DiCLznWy7jVYVcijf5fOq-DcjDiDxks5vCiPSgaJpZM4Z8BvC>
.
--
Peadar Coyle
Interested in levelling up your Machine Learning skills? Here is my
Probabilistic
Programming Primer <https://probabilisticprogrammingprimer.podia.com/>!!!
Skype: springcoilarch
www.twitter.com/springcoil
peadarcoyle.wordpress.com
|
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.
Great work @springcoil! I know this looks like a boatload of comments, but most of them are just to do with readability and unnecessary code. I added suggestions where I could.
Just a few more comments though:
- We can't call this file
test_eight_schools
! 😅 Maybetest_example_linear_regression
? - Can you run black on this file, with the
--py36 -l 100
flags? Alternatively you could rebase onto master. - Currently we test that the logp of the samples are equal to some pre-computed value. Shouldn't we also test that the samples themselves are equal to their pre-computed values?
pymc4/tests/test_eight_schools.py
Outdated
import tensorflow as tf | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import pytest |
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.
Unused import
import pytest |
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.
We don't need to import pytest in our test files, do we? We don't do that in the PyMC3 test suite.
pymc4/tests/test_eight_schools.py
Outdated
|
||
forward_sample = sess.run(model.forward_sample()) | ||
|
||
forward_sample |
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.
Unneeded
forward_sample |
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.
Looks like it's still there :)
I called this test_eight schools? I'm clearly not the brightest, I even left my coffee in a cafe this morning :) |
I'll fix these this evening Eigenfoo. Thanks for the constructive and thorough feedback :) |
That was the plan - I could rename this though.
ᐧ
…On Mon, Jan 14, 2019 at 4:21 PM Ravin Kumar ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In test-requirments.txt
<#39 (comment)>:
> @@ -0,0 +1 @@
+pytest>=3.0.7
I would ask that we keep a requirements.txt and requirements-dev.txt or
requirements-test.txt separate. This way we don't burden end users
environment with things they don't need
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8DiC9piMjwJFGxGQ_H2-rZAOcX9kuZks5vDK5ugaJpZM4Z8BvC>
.
--
Peadar Coyle
Interested in levelling up your Machine Learning skills? Here is my
Probabilistic
Programming Primer <https://probabilisticprogrammingprimer.podia.com/>!!!
Skype: springcoilarch
www.twitter.com/springcoil
peadarcoyle.wordpress.com
|
I learned something today, @eigenfoo! This is a great idea for testing. |
e96bbb9
to
d1d9650
Compare
I've done the changes as he asked :)
Travis tests failed. You just need to format it with black! |
I don't think so. Maybe remove it.
…On Wed, 16 Jan 2019, 3:48 pm George Ho ***@***.*** wrote:
***@***.**** commented on this pull request.
------------------------------
In pymc4/tests/test_eight_schools.py
<#39 (comment)>:
> @@ -0,0 +1,49 @@
+import pymc4 as pm
+import pymc3 as pm3
+import tensorflow as tf
+import numpy as np
+import matplotlib.pyplot as plt
+import pytest
We don't need to import pytest in our test files, do we? We don't do that
in the PyMC3 test suite.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8DiNnUlWhJFGk8asL_e43VreLRvpIQks5vD0nSgaJpZM4Z8BvC>
.
|
0eb4aa0
to
7fc5dba
Compare
@eigenfoo I took your advice and added in a sample test :) |
|
||
model = linreg.configure() | ||
|
||
forward_sample = sess.run(model.forward_sample()) |
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.
Once #49 is merged should use that fixture.
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.
Agree wholeheartedly.
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.
Is this ready to merge?
we should port this to the new testing framework m |
Yeah that's fine, I'll have a look on Monday.
…On Sat, 19 Jan 2019, 1:44 pm Thomas Wiecki ***@***.*** wrote:
we should port this to the new testing framework m
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8DiD2uazmVty1JWMVt_YSjjrDymGJxks5vExMzgaJpZM4Z8BvC>
.
|
@canyon289 I might not have a lot of time over the next few weeks. So if you wanted to just copy and paste the test into your stuff - you can :) |
I can work on deconflicting this branch to prep for a merge in the next ~36 hours. Any naysayers for proposal? |
Go on ahead
…On Sat, 16 Feb 2019, 5:07 pm Ravin Kumar ***@***.*** wrote:
I can work on deconflicting this branch to prep for a merge in the next
~36 hours. Any naysayers for proposal?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8DiHd6G_pMNUF0ACETrv8cuc_VOaiTks5vOCzdgaJpZM4Z8BvC>
.
|
Adding renaming Adding linear regression again Fixing black errors
@springcoil Can you review and let me know if this still meets your intent? |
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.
Lgtm
Seems like there's just enough floating point error to cause the tests to fail. I'll make adjustments in the next couple of days. |
This is ready for review again |
@@ -0,0 +1,172 @@ | |||
import pymc4 as pm |
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 probably be called test_linear_regression_model.py
forward_sample = sess.run(model.forward_sample()) | ||
|
||
|
||
func = model.make_log_prob_function() |
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 these all hang out in the module namespace?
Agreed they should probably not be globals.
ᐧ
…On Tue, Feb 26, 2019 at 10:29 AM Thomas Wiecki ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pymc4/tests/test_linearregression_model.py
<#39 (comment)>:
> + # Define priors
+ sigma = pm.HalfNormal("sigma", scale=10)
+ intercept = pm.Normal("intercept", 0, scale=10)
+ x_coeff = pm.Normal("weight", 0, scale=5)
+ x = np.linspace(-5, 5, n_points)
+
+ # Define likelihood
+ y = pm.Normal("y", loc=intercept + x_coeff * x, scale=sigma)
+
+
+model = linreg.configure()
+
+forward_sample = sess.run(model.forward_sample())
+
+
+func = model.make_log_prob_function()
should these all hang out in the module namespace?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA8DiPQa6e_-fNhauHyNOkDk30iuofZnks5vRQyAgaJpZM4Z8BvC>
.
--
Peadar Coyle
Interested in levelling up your Machine Learning skills? Here is my
Probabilistic
Programming Primer <https://probabilisticprogrammingprimer.podia.com/>!!!
Skype: springcoilarch
www.twitter.com/springcoil
peadarcoyle.wordpress.com
|
Thanks @canyon289! |
And @springcoil |
I couldn't get the eight schools model to work - PyMC4 didn't have half normal.
However I did get this to work, and the test passes. Do we want to add a tests file to the travis CI? Or is that too soon?