Skip to content

Commit

Permalink
Fix smoke tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Ki Min <[email protected]>
  • Loading branch information
loomlike committed Dec 19, 2023
1 parent 649f1b2 commit 9ecf302
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
" mae,\n",
" rsquared,\n",
" exp_var,\n",
" map_at_k,\n",
" map,\n",
" ndcg_at_k,\n",
" precision_at_k,\n",
" recall_at_k,\n",
Expand Down Expand Up @@ -689,7 +689,7 @@
"source": [
"cols[\"col_prediction\"] = \"Count\"\n",
"\n",
"eval_map = map_at_k(test, baseline_recommendations, k=TOP_K, **cols)\n",
"eval_map = map(test, baseline_recommendations, k=TOP_K, **cols)\n",
"eval_ndcg = ndcg_at_k(test, baseline_recommendations, k=TOP_K, **cols)\n",
"eval_precision = precision_at_k(test, baseline_recommendations, k=TOP_K, **cols)\n",
"eval_recall = recall_at_k(test, baseline_recommendations, k=TOP_K, **cols)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"\n",
"from recommenders.datasets import movielens\n",
"from recommenders.datasets.python_splitters import python_random_split\n",
"from recommenders.evaluation.python_evaluation import map_at_k, ndcg_at_k, precision_at_k, recall_at_k\n",
"from recommenders.evaluation.python_evaluation import map, ndcg_at_k, precision_at_k, recall_at_k\n",
"from recommenders.models.cornac.cornac_utils import predict_ranking\n",
"from recommenders.utils.timer import Timer\n",
"from recommenders.utils.constants import SEED\n",
Expand Down Expand Up @@ -557,7 +557,7 @@
],
"source": [
"k = 10\n",
"eval_map = map_at_k(test, all_predictions, col_prediction='prediction', k=k)\n",
"eval_map = map(test, all_predictions, col_prediction='prediction', k=k)\n",
"eval_ndcg = ndcg_at_k(test, all_predictions, col_prediction='prediction', k=k)\n",
"eval_precision = precision_at_k(test, all_predictions, col_prediction='prediction', k=k)\n",
"eval_recall = recall_at_k(test, all_predictions, col_prediction='prediction', k=k)\n",
Expand Down
38 changes: 16 additions & 22 deletions tests/smoke/examples/test_notebooks_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def test_ncf_deep_dive_smoke(notebooks, output_notebook, kernel_name):
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(
TOP_K=10, MOVIELENS_DATA_SIZE="100k", EPOCHS=1, BATCH_SIZE=1024
),
parameters=dict(TOP_K=10, MOVIELENS_DATA_SIZE="100k", EPOCHS=1, BATCH_SIZE=1024),
)
results = read_notebook(output_notebook)

Expand Down Expand Up @@ -91,19 +89,15 @@ def test_xdeepfm_smoke(notebooks, output_notebook, kernel_name):
output_notebook,
kernel_name=kernel_name,
parameters=dict(
EPOCHS_FOR_SYNTHETIC_RUN=1,
EPOCHS_FOR_CRITEO_RUN=1,
BATCH_SIZE_SYNTHETIC=128,
BATCH_SIZE_CRITEO=512,
EPOCHS=1,
BATCH_SIZE=512,
RANDOM_SEED=42,
),
)
results = read_notebook(output_notebook)

assert results["res_syn"]["auc"] == pytest.approx(0.5043, rel=TOL, abs=ABS_TOL)
assert results["res_syn"]["logloss"] == pytest.approx(0.7046, rel=TOL, abs=ABS_TOL)
assert results["res_real"]["auc"] == pytest.approx(0.7251, rel=TOL, abs=ABS_TOL)
assert results["res_real"]["logloss"] == pytest.approx(0.508, rel=TOL, abs=ABS_TOL)
assert results["auc"] == pytest.approx(0.7251, rel=TOL, abs=ABS_TOL)
assert results["logloss"] == pytest.approx(0.508, rel=TOL, abs=ABS_TOL)


@pytest.mark.notebooks
Expand Down Expand Up @@ -140,14 +134,14 @@ def test_naml_smoke(notebooks, output_notebook, kernel_name):
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(epochs=1, seed=42, MIND_type="demo"),
parameters=dict(epochs=1, batch_size=64, seed=42, MIND_type="demo"),
)
results = read_notebook(output_notebook)

assert results["res_syn"]["group_auc"] == pytest.approx(
assert results["group_auc"] == pytest.approx(
0.5801, rel=TOL, abs=ABS_TOL
)
assert results["res_syn"]["mean_mrr"] == pytest.approx(0.2512, rel=TOL, abs=ABS_TOL)
assert results["mean_mrr"] == pytest.approx(0.2512, rel=TOL, abs=ABS_TOL)


@pytest.mark.notebooks
Expand All @@ -162,10 +156,10 @@ def test_nrms_smoke(notebooks, output_notebook, kernel_name):
)
results = read_notebook(output_notebook)

assert results["res_syn"]["group_auc"] == pytest.approx(
assert results["group_auc"] == pytest.approx(
0.5768, rel=TOL, abs=ABS_TOL
)
assert results["res_syn"]["mean_mrr"] == pytest.approx(0.2457, rel=TOL, abs=ABS_TOL)
assert results["mean_mrr"] == pytest.approx(0.2457, rel=TOL, abs=ABS_TOL)


@pytest.mark.notebooks
Expand All @@ -176,14 +170,14 @@ def test_npa_smoke(notebooks, output_notebook, kernel_name):
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(epochs=1, seed=42, MIND_type="demo"),
parameters=dict(epochs=1, batch_size=64, seed=42, MIND_type="demo"),
)
results = read_notebook(output_notebook)

assert results["res_syn"]["group_auc"] == pytest.approx(
assert results["group_auc"] == pytest.approx(
0.5861, rel=TOL, abs=ABS_TOL
)
assert results["res_syn"]["mean_mrr"] == pytest.approx(0.255, rel=TOL, abs=ABS_TOL)
assert results["mean_mrr"] == pytest.approx(0.255, rel=TOL, abs=ABS_TOL)


@pytest.mark.notebooks
Expand All @@ -194,14 +188,14 @@ def test_lstur_smoke(notebooks, output_notebook, kernel_name):
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(epochs=1, seed=40, MIND_type="demo"),
parameters=dict(epochs=1, batch_size=64, seed=40, MIND_type="demo"),
)
results = read_notebook(output_notebook)

assert results["res_syn"]["group_auc"] == pytest.approx(
assert results["group_auc"] == pytest.approx(
0.5977, rel=TOL, abs=ABS_TOL
)
assert results["res_syn"]["mean_mrr"] == pytest.approx(0.2618, rel=TOL, abs=ABS_TOL)
assert results["mean_mrr"] == pytest.approx(0.2618, rel=TOL, abs=ABS_TOL)


@pytest.mark.notebooks
Expand Down

0 comments on commit 9ecf302

Please sign in to comment.