def test_dot(self): # Note: theta^T . X === X^T . theta dot = np.dot( self.theta, self.X.T ) # need to use np dot function as pandas only allows you to do the dot if columns have same name print(dot) sig = Classification._sigmoid(dot) print(sig)
def test_sigmoid_vector(self): small_sig = Classification._sigmoid(np.array([-10000, -10000, -10000])) large_sig = Classification._sigmoid(np.array([10000, 10000, 10000])) for s_val, l_val in zip(small_sig, large_sig): self.assertAlmostEqual(s_val, 0) self.assertAlmostEqual(l_val, 1)
def test_sigmoid_scalar(self): # for very negative numbers, sigmoid should equal zero, for very large, it should be 1 self.assertAlmostEqual(Classification._sigmoid(-1000000), 0) self.assertAlmostEqual(Classification._sigmoid(1000000), 1)