def test_regression_pred(): print 'LinearProbabilityModel.predict Check:\n----------------------' try: clf = LinearProbabilityModel() clf.fit(np.reshape(range(30), (10, 3)) ** 2, 5 * [0, 1]) yhat = clf.predict(np.reshape(range(30), (10, 3)) ** 2) if not all(yhat == [False, False, False, False, False, True, True, True, True, True]): print '[FAILED], incorrect prediction' return False else: print '[PASSED]' return True except Exception: print '[FAILED], error in calculation' return False
def test_regression_theta(): print 'LinearProbabilityModel.theta Check:\n----------------------' try: clf = LinearProbabilityModel() clf.fit(np.reshape(range(30), (10, 3)) ** 2, 5 * [0, 1]) if not np.allclose(clf.theta, [ 0.17424242, -0.35353535, 0.17929293]): print '[FAILED], incorrect theta calculation' return False else: print '[PASSED]' return True except Exception: print '[FAILED], error in calculation' return False