Browse Source

renamed some internal variables

main
Holger Frey 2 years ago
parent
commit
9bac352e05
  1. 19
      linear_regression.py

19
linear_regression.py

@ -63,12 +63,23 @@ def test_linear_regression(example_data): @@ -63,12 +63,23 @@ def test_linear_regression(example_data):
def test_regression_predict(example_data):
result = linear_regression(example_data, x="A", y="B")
regression = linear_regression(example_data, x="A", y="B")
prediction = result.predict(10)
prediction = regression.predict(10)
assert pytest.approx(30.7) == prediction
assert pytest.approx(10) == result.predict(y=prediction)
assert pytest.approx(10) == regression.predict(y=prediction)
with pytest.raises(TypeError, match="expects 1 argument"):
result.predict()
regression.predict()
def test_regression_to_dict(example_data):
regression = linear_regression(example_data, x="A", y="B")
result = regression.to_dict()
assert sorted(result.keys()) == ["coefficient", "intercept", "score"]
assert pytest.approx(2.96) == result["coefficient"]
assert pytest.approx(1.1) == result["intercept"]
assert pytest.approx(0.9996349) == result["score"]

Loading…
Cancel
Save