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
def test_get_family_size(): | |
df = get_production_sample(pct=0.1) | |
func = lambda x: get_family_size(x['SibSp'], x['Parch']) | |
sizes = df.apply(func, axis=1) | |
assert all(size >= 1 for size in sizes) |
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
@given(st.integers(), st.integers()) | |
@example(-1, 0) | |
def test_get_family_size(sib, parch): | |
fs = get_family_size(sib, parch) | |
assert fs >= 1 |
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
@given(st.integers(), st.integers()) | |
def test_get_family_size(sib, parch): | |
fs = get_family_size(sib, parch) | |
assert fs >= 1 |
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
def get_family_size(sib, parch): | |
return sib_sp + parch + 1 | |
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
def test_get_family_size(): | |
sib = 2 | |
parent = 2 | |
actual = get_family_size(sib, parent) | |
assert actual == 5 |
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
def is_royal(name): | |
title = name.split(",")[1].split(".")[0] | |
title = parsed_name.strip() | |
return title in ['the Countess', 'Lady', 'Sir'] | |
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
def test_queries_synatx(): | |
queries = glob.glob('**/*.sql',recursive=True) | |
engine = create_engine('<COOL_CONNECTION_STR>') | |
with engine.connect() as con: | |
for query_file in queries_list: | |
with open(query_file) as f: | |
query = f.read() | |
test_query = f"Explain {query}" | |
con.execute(test_query) |
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
def test_model_performance(): | |
model = get_trained_model(model) | |
base = get_production_sample(pct=0.1) | |
base = feature_engineering(input) | |
base_preds = model.predict(base) | |
labels = get_true_labels(base) | |
auc = roc_auc_score(true_labels, base_preds) | |
assert auc > 0.8 |
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
def test_inference_latency(): | |
model = get_trained_model(model) | |
base = get_production_sample(pct=0.1) | |
base = feature_engineering(input) | |
start_time = time.time() | |
base_preds = model.predict(base) | |
end_time = time.time() | |
assert (end_time - start_time) <= 200 |
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
def test_model_bias(): | |
model = get_trained_model(model) | |
base = get_production_sample(pct=0.1) | |
base = feature_engineering(input) | |
base_preds = model.predict(base) | |
embark_b = base.copy() | |
embark_b["Embarked"] = "B" | |
embark_b_preds = model.predict(embark_b) | |
assert average(abs(embark_b_preds - base_preds)) < 0.1 |
NewerOlder