-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
pipeline
test and fix important errors
- Loading branch information
1 parent
09481f3
commit acaee31
Showing
7 changed files
with
216 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
import pipeline_lib | ||
|
||
|
||
def test_simple_train_pipeline(): | ||
"""Test that the pipeline can be trained.""" | ||
pipeline = pipeline_lib.Pipeline.from_json("tests/data/test.json") | ||
pipeline.train() | ||
|
||
zip_file = pipeline.save_data_path + ".zip" | ||
os.remove(zip_file) | ||
|
||
|
||
def test_simple_predict_pipeline(): | ||
"""Test that the pipeline can be trained and predicted.""" | ||
pipeline = pipeline_lib.Pipeline.from_json("tests/data/test.json") | ||
pipeline.train() | ||
pipeline.predict() | ||
|
||
zip_file = pipeline.save_data_path + ".zip" | ||
os.remove(zip_file) | ||
|
||
|
||
def test_predict_raises_error_with_no_predict_path_and_df(): | ||
"""Test that the pipeline raises an error when no predict path is provided | ||
and no dataframe is provided.""" | ||
pipeline = pipeline_lib.Pipeline.from_json("tests/data/test_without_predict_path.json") | ||
pipeline.train() | ||
|
||
# check that this raies an error | ||
with pytest.raises(ValueError): | ||
try: | ||
pipeline.predict() | ||
finally: | ||
zip_file = pipeline.save_data_path + ".zip" | ||
if os.path.exists(zip_file): | ||
os.remove(zip_file) | ||
|
||
|
||
def test_predict_with_df(): | ||
pipeline = pipeline_lib.Pipeline.from_json("tests/data/test_without_predict_path.json") | ||
data = pipeline.train() | ||
|
||
df = data.raw.drop(columns=[pipeline.target]) | ||
pipeline.predict(df) | ||
|
||
zip_file = pipeline.save_data_path + ".zip" | ||
os.remove(zip_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"pipeline": { | ||
"name": "XGBoostTrainingPipeline", | ||
"description": "Training pipeline for XGBoost models.", | ||
"parameters": { | ||
"save_data_path": "tests/data/test.pkl", | ||
"target": "target" | ||
}, | ||
"steps": [ | ||
{ | ||
"step_type": "GenerateStep", | ||
"parameters": { | ||
"train_path": "tests/data/train.csv", | ||
"test_path": "tests/data/test.csv", | ||
"predict_path": "tests/data/predict.csv" | ||
} | ||
}, | ||
{ | ||
"step_type": "TabularSplitStep", | ||
"parameters": { | ||
"train_percentage": 0.8 | ||
} | ||
}, | ||
{ | ||
"step_type": "CleanStep" | ||
}, | ||
{ | ||
"step_type": "CalculateFeaturesStep", | ||
"parameters": { | ||
"datetime_columns": "date", | ||
"features": [ | ||
"year", | ||
"month", | ||
"day" | ||
] | ||
} | ||
}, | ||
{ | ||
"step_type": "EncodeStep", | ||
"parameters": { | ||
"feature_encoders": { | ||
"category_high": { | ||
"encoder": "TargetEncoder" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"step_type": "ModelStep", | ||
"parameters": { | ||
"model_class": "XGBoost", | ||
"model_parameters": { | ||
"n_estimators": 3, | ||
"max_depth": 3 | ||
} | ||
} | ||
}, | ||
{ | ||
"step_type": "CalculateMetricsStep" | ||
}, | ||
{ | ||
"step_type": "ExplainerDashboardStep", | ||
"parameters": { | ||
"enable_step": false | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"pipeline": { | ||
"name": "XGBoostTrainingPipeline", | ||
"description": "Training pipeline for XGBoost models.", | ||
"parameters": { | ||
"save_data_path": "tests/data/test_2.pkl", | ||
"target": "target" | ||
}, | ||
"steps": [ | ||
{ | ||
"step_type": "GenerateStep", | ||
"parameters": { | ||
"train_path": "tests/data/train.csv", | ||
"test_path": "tests/data/test.csv" | ||
} | ||
}, | ||
{ | ||
"step_type": "TabularSplitStep", | ||
"parameters": { | ||
"train_percentage": 0.8 | ||
} | ||
}, | ||
{ | ||
"step_type": "CleanStep" | ||
}, | ||
{ | ||
"step_type": "CalculateFeaturesStep", | ||
"parameters": { | ||
"datetime_columns": "date", | ||
"features": [ | ||
"year", | ||
"month", | ||
"day" | ||
] | ||
} | ||
}, | ||
{ | ||
"step_type": "EncodeStep", | ||
"parameters": { | ||
"feature_encoders": { | ||
"category_high": { | ||
"encoder": "TargetEncoder" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"step_type": "ModelStep", | ||
"parameters": { | ||
"model_class": "XGBoost", | ||
"model_parameters": { | ||
"n_estimators": 3, | ||
"max_depth": 3 | ||
} | ||
} | ||
}, | ||
{ | ||
"step_type": "CalculateMetricsStep" | ||
}, | ||
{ | ||
"step_type": "ExplainerDashboardStep", | ||
"parameters": { | ||
"enable_step": false | ||
} | ||
} | ||
] | ||
} | ||
} |