annotate tests/test_sigmoid.py @ 44:857a606783e1

[documentation] notes + stubs on gradient descent
author Jeff Hammel <k0scist@gmail.com>
date Mon, 04 Sep 2017 15:06:38 -0700
parents 38aa9098bf2d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
20
d6d2ecb33c95 [logistic regression] smoke tests
Jeff Hammel <k0scist@gmail.com>
parents: 19
diff changeset
4 test sigmoid related functionality
18
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import os
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import unittest
42
38aa9098bf2d derivative of sigmoid
Jeff Hammel <k0scist@gmail.com>
parents: 20
diff changeset
9 from tvii.sigmoid import sigmoid, sigmoidprime
18
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 class TestSigmoid(unittest.TestCase):
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def test_basic(self):
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 """test two points of the sigmoid function"""
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
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
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21
42
38aa9098bf2d derivative of sigmoid
Jeff Hammel <k0scist@gmail.com>
parents: 20
diff changeset
22 def test_derivative(self):
38aa9098bf2d derivative of sigmoid
Jeff Hammel <k0scist@gmail.com>
parents: 20
diff changeset
23
38aa9098bf2d derivative of sigmoid
Jeff Hammel <k0scist@gmail.com>
parents: 20
diff changeset
24 self.assertAlmostEqual(sigmoidprime(0), 0.25)
38aa9098bf2d derivative of sigmoid
Jeff Hammel <k0scist@gmail.com>
parents: 20
diff changeset
25
18
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 if __name__ == '__main__':
e92fc4a17336 add failing test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 unittest.main()