Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pre-commit hooks: formatting with ruff, format pyproject.toml #108

Merged
merged 14 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
# - id: check-added-large-files
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
rev: v0.1.3
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args:
- --fix
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
hooks:
- id: ruff
alias: isort
name: ruff (isort)
args: [--select=I001, --fix]
- repo: https://github.com/psf/black
rev: 22.10.0
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.3.0"
hooks:
- id: black
language_version: python3
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.10.1
rev: v0.15
hooks:
- id: validate-pyproject
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.12.0
hooks:
- id: commitizen-branch
stages: [push]
4 changes: 3 additions & 1 deletion docs/code/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@

print("✅ Predictions (multivariate):\n", y_pred.sort(entity_col))
print("💯 Scores (multivariate):\n", scores_with_exog.sort("smape"))
print("💯 Scores summary (multivariate):\n", scores_with_exog.select("smape").describe())
print(
"💯 Scores summary (multivariate):\n", scores_with_exog.select("smape").describe()
)

# Check uplift from Fourier features
uplift = (
Expand Down
62 changes: 15 additions & 47 deletions docs/notebooks/evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"y.select(\n",
" pl.all().exclude(\"price\").n_unique(),\n",
" pl.col(\"time\").min().dt.date().alias(\"start\"),\n",
" pl.col(\"time\").max().dt.date().alias(\"end\")\n",
" pl.col(\"time\").max().dt.date().alias(\"end\"),\n",
")"
]
},
Expand Down Expand Up @@ -243,10 +243,7 @@
}
],
"source": [
"ranks = rank_point_forecasts(\n",
" y_true=y_test,\n",
" y_pred=y_pred_bench\n",
")\n",
"ranks = rank_point_forecasts(y_true=y_test, y_pred=y_pred_bench)\n",
"ranks.head()"
]
},
Expand All @@ -273,7 +270,7 @@
" y_pred=y_pred_bench.filter(pl.col(entity_col).is_in(selected_entities)),\n",
" n_cols=2,\n",
" height=1000,\n",
" width=1200\n",
" width=1200,\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down Expand Up @@ -324,11 +321,7 @@
}
],
"source": [
"ranks = rank_point_forecasts(\n",
" y_true=y_test,\n",
" y_pred=y_pred_bench,\n",
" descending=True\n",
")\n",
"ranks = rank_point_forecasts(y_true=y_test, y_pred=y_pred_bench, descending=True)\n",
"ranks.head()"
]
},
Expand All @@ -355,7 +348,7 @@
" y_pred=y_pred_bench.filter(pl.col(entity_col).is_in(selected_entities)),\n",
" n_cols=2,\n",
" height=1000,\n",
" width=1200\n",
" width=1200,\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand All @@ -377,12 +370,7 @@
"source": [
"# Instantiate forecaster and backtest\n",
"forecaster = lightgbm(freq=\"1mo\", lags=48, target_transform=detrend())\n",
"y_preds, y_resids = forecaster.backtest(\n",
" y=y,\n",
" test_size=12,\n",
" step_size=12,\n",
" n_splits=5\n",
")\n",
"y_preds, y_resids = forecaster.backtest(y=y, test_size=12, step_size=12, n_splits=5)\n",
"y_pred = forecaster(fh=fh, y=y_train)"
]
},
Expand Down Expand Up @@ -462,7 +450,7 @@
" y_pred=y_preds.filter(pl.col(entity_col).is_in(selected_entities)),\n",
" n_cols=2,\n",
" height=1000,\n",
" width=1200\n",
" width=1200,\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down Expand Up @@ -513,11 +501,7 @@
}
],
"source": [
"ranks = rank_point_forecasts(\n",
" y_true=y,\n",
" y_pred=y_preds,\n",
" descending=True\n",
")\n",
"ranks = rank_point_forecasts(y_true=y, y_pred=y_preds, descending=True)\n",
"ranks.head()"
]
},
Expand All @@ -544,7 +528,7 @@
" y_pred=y_preds.filter(pl.col(entity_col).is_in(selected_entities)),\n",
" n_cols=2,\n",
" height=1000,\n",
" width=1200\n",
" width=1200,\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down Expand Up @@ -595,11 +579,7 @@
}
],
"source": [
"ranks = rank_residuals(\n",
" y_resids=y_resids,\n",
" sort_by=\"abs_bias\",\n",
" descending=True\n",
")\n",
"ranks = rank_residuals(y_resids=y_resids, sort_by=\"abs_bias\", descending=True)\n",
"ranks.head()"
]
},
Expand All @@ -625,7 +605,7 @@
" y_resids=y_resids.filter(pl.col(entity_col).is_in(selected_entities)),\n",
" n_bins=200,\n",
" height=800,\n",
" width=1000\n",
" width=1000,\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down Expand Up @@ -676,11 +656,7 @@
}
],
"source": [
"ranks = rank_residuals(\n",
" y_resids=y_resids,\n",
" sort_by=\"normality\",\n",
" descending=True\n",
")\n",
"ranks = rank_residuals(y_resids=y_resids, sort_by=\"normality\", descending=True)\n",
"ranks.head()"
]
},
Expand All @@ -706,7 +682,7 @@
" y_resids=y_resids.filter(pl.col(entity_col).is_in(selected_entities)),\n",
" n_bins=200,\n",
" height=800,\n",
" width=1000\n",
" width=1000,\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down Expand Up @@ -738,11 +714,7 @@
],
"source": [
"figure = plot_fva(\n",
" y_true=y_test,\n",
" y_pred=y_pred,\n",
" y_pred_bench=y_pred_bench,\n",
" height=900,\n",
" width=900\n",
" y_true=y_test, y_pred=y_pred, y_pred_bench=y_pred_bench, height=900, width=900\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down Expand Up @@ -774,11 +746,7 @@
],
"source": [
"figure = plot_comet(\n",
" y_train=y_train,\n",
" y_test=y_test,\n",
" y_pred=y_pred,\n",
" height=900,\n",
" width=900\n",
" y_train=y_train, y_test=y_test, y_pred=y_pred, height=900, width=900\n",
")\n",
"figure.show(renderer=\"svg\")"
]
Expand Down
15 changes: 8 additions & 7 deletions docs/notebooks/llm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"outputs": [],
"source": [
"import os\n",
"from IPython.display import display, Markdown\n",
"\n",
"from IPython.display import Markdown, display\n",
"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"...\" # Your API key here"
]
},
Expand Down Expand Up @@ -180,7 +182,9 @@
"metadata": {},
"outputs": [],
"source": [
"dataset_context = \"This dataset comprises of forecasted commodity prices between 2020 to 2023.\""
"dataset_context = (\n",
" \"This dataset comprises of forecasted commodity prices between 2020 to 2023.\"\n",
")"
]
},
{
Expand Down Expand Up @@ -230,7 +234,7 @@
"source": [
"analysis = y_pred.llm.analyze(\n",
" context=\"This dataset comprises of forecasted commodity prices between 2020 to 2023.\",\n",
" basket=[\"Aluminum\", \"Banana, Europe\"]\n",
" basket=[\"Aluminum\", \"Banana, Europe\"],\n",
")\n",
"display(Markdown(analysis))"
]
Expand Down Expand Up @@ -306,10 +310,7 @@
}
],
"source": [
"comparison = y_pred.llm.compare(\n",
" basket=basket_a,\n",
" other_basket=basket_b\n",
")\n",
"comparison = y_pred.llm.compare(basket=basket_a, other_basket=basket_b)\n",
"display(Markdown(comparison))"
]
}
Expand Down
Loading