Mercurial > hg > tvii
annotate tests/test_sigmoid.py @ 53:673a295fd09c
[documentation] cache coursera notes
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 24 Sep 2017 14:42:56 -0700 |
parents | 38aa9098bf2d |
children |
rev | line source |
---|---|
18 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
20
d6d2ecb33c95
[logistic regression] smoke tests
Jeff Hammel <k0scist@gmail.com>
parents:
19
diff
changeset
|
4 test sigmoid related functionality |
18 | 5 """ |
6 | |
7 import os | |
8 import unittest | |
42 | 9 from tvii.sigmoid import sigmoid, sigmoidprime |
18 | 10 |
11 | |
12 class TestSigmoid(unittest.TestCase): | |
13 | |
14 def test_basic(self): | |
15 """test two points of the sigmoid function""" | |
16 | |
17 answer = sigmoid([0,2]) | |
19
cd43ce453358
[numpy] of course we have to cast everything here too
Jeff Hammel <k0scist@gmail.com>
parents:
18
diff
changeset
|
18 assert len(answer) == 2 |
20
d6d2ecb33c95
[logistic regression] smoke tests
Jeff Hammel <k0scist@gmail.com>
parents:
19
diff
changeset
|
19 assert answer[0] == 0.5 |
d6d2ecb33c95
[logistic regression] smoke tests
Jeff Hammel <k0scist@gmail.com>
parents:
19
diff
changeset
|
20 assert abs(answer[1] - 0.88079708) < 1e-6 |
18 | 21 |
42 | 22 def test_derivative(self): |
23 | |
24 self.assertAlmostEqual(sigmoidprime(0), 0.25) | |
25 | |
18 | 26 if __name__ == '__main__': |
27 unittest.main() |