Skip to content

Commit 4bed311

Browse files
committed
fix: Resolve all ruff linting errors
- Remove unused variables in test files - Fix undefined variable issue in catboost_wrapper.py - Update pre-commit config to allow larger notebook files - All pre-commit hooks now pass successfully
1 parent aea8c29 commit 4bed311

17 files changed

Lines changed: 895 additions & 389 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: check-yaml
1414
- id: check-added-large-files
15+
args: ['--maxkb=5000'] # Allow larger files for notebooks
1516
- id: check-merge-conflict
1617

1718
- repo: https://github.com/astral-sh/ruff-pre-commit

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ We can also visualize the score distribution between the events of interest.
9797
from xbooster import explainer
9898

9999
explainer.plot_score_distribution(
100-
y_test,
100+
y_test,
101101
credit_scores,
102-
num_bins=30,
102+
num_bins=30,
103103
figsize=(8, 3),
104104
dpi=100
105105
)
@@ -156,7 +156,7 @@ print(f"Rule reduction: {len(xgb_scorecard_with_points)} → {len(interval_score
156156
print("\nInterval format:")
157157
print(interval_scorecard[['Feature', 'Bin', 'Points', 'WOE']].head())
158158

159-
# Add Points at Even Odds/Points to Double the Odds (PEO/PDO)
159+
# Add Points at Even Odds/Points to Double the Odds (PEO/PDO)
160160
peo_pdo_scorecard = scorecard_constructor.create_points_peo_pdo(peo=600, pdo=50)
161161
print("\nPEO/PDO Points:")
162162
print(peo_pdo_scorecard[['Feature', 'Bin', 'Points_PEO_PDO']].head())
@@ -194,8 +194,8 @@ target = "Loan_Status"
194194

195195
# Initialize preprocessor
196196
preprocessor = DataPreprocessor(
197-
numerical_features,
198-
categorical_features,
197+
numerical_features,
198+
categorical_features,
199199
target
200200
)
201201

@@ -204,7 +204,7 @@ X, y = preprocessor.fit_transform(dataset)
204204

205205
# Get one-hot encoded feature names
206206
features_ohe = [
207-
col for col in X.columns
207+
col for col in X.columns
208208
if col not in numerical_features
209209
]
210210

@@ -281,9 +281,9 @@ woe_scores = constructor.predict_score(X, method="woe")
281281

282282
# Now create points for the scorecard
283283
scorecard_with_points = constructor.create_points(
284-
pdo=50,
285-
target_points=600,
286-
target_odds=19,
284+
pdo=50,
285+
target_points=600,
286+
target_odds=19,
287287
precision_points=0
288288
)
289289

@@ -529,4 +529,4 @@ For code contributions, please open a pull request.
529529
For a changelog, see [CHANGELOG](CHANGELOG.md).
530530

531531
## License 📄
532-
This project is licensed under the MIT License - see the LICENSE file for details.
532+
This project is licensed under the MIT License - see the LICENSE file for details.

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ jupyter notebook
5757

5858
3. Open the desired notebook and follow the instructions.
5959

60-
Note: The examples use sample data and may need to be adapted for your specific use case.
60+
Note: The examples use sample data and may need to be adapted for your specific use case.

examples/base-score.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"source": [
182182
"import numpy as np\n",
183183
"import xgboost as xgb\n",
184-
"from scipy.special import logit, expit\n",
184+
"from scipy.special import expit\n",
185185
"\n",
186186
"\n",
187187
"def calculate_results_xbooster(booster, X, base_score, logit_scale=True):\n",

examples/catboost-getting-started.ipynb

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@
426426
}
427427
],
428428
"source": [
429-
"import numpy as np\n",
430429
"from matplotlib import pyplot as plt\n",
430+
"\n",
431431
"%config InlineBackend.figure_format = 'retina'\n",
432432
"\n",
433433
"fig = plt.figure(figsize=(8, 6), dpi=120)\n",
@@ -438,21 +438,9 @@
438438
"bins = np.linspace(score_min, score_max, 20)\n",
439439
"\n",
440440
"# plot score hist based on y == 1\n",
441-
"ax.hist(\n",
442-
" points_scores[y == 1],\n",
443-
" bins=bins,\n",
444-
" color=\"blue\",\n",
445-
" alpha=0.5,\n",
446-
" label=\"Approved loans\"\n",
447-
")\n",
441+
"ax.hist(points_scores[y == 1], bins=bins, color=\"blue\", alpha=0.5, label=\"Approved loans\")\n",
448442
"# plot score hist based on y == 0\n",
449-
"ax.hist(\n",
450-
" points_scores[y == 0],\n",
451-
" bins=bins,\n",
452-
" color=\"red\",\n",
453-
" alpha=0.5,\n",
454-
" label=\"Declined loans\"\n",
455-
")\n",
443+
"ax.hist(points_scores[y == 0], bins=bins, color=\"red\", alpha=0.5, label=\"Declined loans\")\n",
456444
"ax.set_xlabel(\"Credit Score\")\n",
457445
"ax.set_ylabel(\"Frequency\")\n",
458446
"ax.set_title(\"Credit Score Distribution\")\n",

examples/xgboost-categorical-data.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
}
8989
],
9090
"source": [
91-
"import numpy as np\n",
9291
"import xgboost as xgb\n",
9392
"from sklearn.metrics import roc_auc_score # type: ignore\n",
9493
"\n",

examples/xgboost-getting-started.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
}
5858
],
5959
"source": [
60-
"import numpy as np\n",
6160
"import xgboost as xgb\n",
6261
"from sklearn.metrics import roc_auc_score\n",
6362
"\n",

0 commit comments

Comments
 (0)