Skip to content

Commit

Permalink
Fix ipynb ruff linting pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Silva authored and Francisco Silva committed Nov 13, 2024
1 parent 58f0abe commit feee80f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
rev: v0.7.3
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down
1 change: 0 additions & 1 deletion notebooks/eda.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"from pipeline import Preprocess"
]
},
Expand Down
21 changes: 10 additions & 11 deletions notebooks/modeling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"outputs": [],
"source": [
"import datetime as dt\n",
"import polars as pl\n",
"import plotly.express as px\n",
"\n",
"from model import XGBoostModel\n",
"from config import get_config"
"import plotly.express as px\n",
"import polars as pl\n",
"from config import get_config\n",
"from model import XGBoostModel"
]
},
{
Expand Down Expand Up @@ -1169,9 +1169,7 @@
" width=1000,\n",
" height=1200,\n",
")\n",
"fig.update_layout(\n",
" yaxis={\"tickfont\": {\"size\": 10}}, showlegend=False, margin=dict(l=200)\n",
")\n",
"fig.update_layout(yaxis={\"tickfont\": {\"size\": 10}}, showlegend=False, margin={\"l\": 200})\n",
"fig.add_vline(x=0, line_dash=\"dash\", line_color=\"gray\")\n",
"fig.show()"
]
Expand Down Expand Up @@ -1709,9 +1707,9 @@
}
],
"source": [
"import sklearn.metrics as skm\n",
"from sklearn.feature_selection import RFE\n",
"from xgboost import XGBClassifier\n",
"import sklearn.metrics as skm\n",
"\n",
"params = {\n",
" \"objective\": \"binary:logistic\",\n",
Expand Down Expand Up @@ -1821,7 +1819,6 @@
"baseline = float(len(val.filter(pl.col(target_col) == 1)) / len(val))\n",
"\n",
"pr_auc = model.evaluate(X_val, y_val)[\"pr_auc\"]\n",
"pr_auc\n",
"\n",
"print(f\"Baseline {baseline}, PR-AUC = {pr_auc}\")"
]
Expand Down Expand Up @@ -2101,15 +2098,17 @@
}
],
"source": [
"import shap\n",
"import numpy as np\n",
"import shap\n",
"\n",
"explainer = shap.TreeExplainer(model.model)\n",
"shap_values = explainer(X_train)\n",
"\n",
"feature_names = [\n",
" a + \": \" + str(b)\n",
" for a, b in zip(X_train.columns, np.abs(shap_values.values).mean(0).round(2))\n",
" for a, b in zip(\n",
" X_train.columns, np.abs(shap_values.values).mean(0).round(2), strict=False\n",
" )\n",
"]\n",
"\n",
"shap.summary_plot(\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["pytest", "pytest-cov", "ruff"]
dev = ["pytest", "pytest-cov", "ruff", "nbqa"]

[build-system]
requires = ["setuptools"]
Expand Down
1 change: 1 addition & 0 deletions scripts/install-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Install pre-commit hooks
pre-commit install
pre-commit autoupdate

# Make sure the script is executable
chmod +x .git/hooks/pre-commit
Expand Down

0 comments on commit feee80f

Please sign in to comment.