-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_pipeline.py
35 lines (26 loc) · 882 Bytes
/
test_pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris
@pytest.mark.skip(reason="Not implemented yet")
def test_pipeline():
# Load the iris dataset
X, y = load_iris(return_X_y=True)
# Create a pipeline with a logistic regression model
model = Pipeline([
('lr', LogisticRegression())
])
# Fit the model on the training data
model.fit(X, y)
# Use the model to make predictions on the test data
y_pred = model.predict(X)
# Assert that the model has a high accuracy
assert accuracy_score(y, y_pred) >= 0.9
# this will not run by pytest
if __name__ == "__main__":
import sys
# Add --cov flag if not already present
if "--cov" not in sys.argv:
sys.argv.append("--cov")
# Run the tests
pytest.main(sys.argv)