Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Quantco/metalearners into mkdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
kklein committed Feb 13, 2025
2 parents 1bf0671 + 3794f05 commit 57cc3b9
Show file tree
Hide file tree
Showing 8 changed files with 18,726 additions and 22,845 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ repos:
language: system
entry: pixi run -e lint trailing-whitespace-fixer
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- id: end-of-file-fixer
name: fix end of files
language: system
entry: pixi run -e lint end-of-file-fixer
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- id: check-merge-conflict
name: check for merge conflicts
language: system
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
Changelog
=========

0.12.0 (2025-01-29)
-------------------

**Other changes**

* Comply with ``scikit-learn`` versions 1.6 and higher.


0.11.0 (2024-09-05)
-------------------

Expand Down
4 changes: 3 additions & 1 deletion metalearners/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import numpy as np
import pandas as pd
import scipy
from sklearn.base import check_array, check_X_y, is_classifier, is_regressor
from sklearn.base import is_classifier, is_regressor
from sklearn.ensemble import (
HistGradientBoostingClassifier,
HistGradientBoostingRegressor,
)
from sklearn.utils import check_array, check_X_y

from metalearners._typing import Matrix, PredictMethod, Vector, _ScikitModel

Expand Down Expand Up @@ -131,6 +132,7 @@ def check_propensity_score(
)

if features is not None:

check_X_y(features, propensity_scores, multi_output=True, **check_kwargs)
else:
check_array(propensity_scores, **check_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion metalearners/grid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _fit_and_score(job: _FitAndScoreJob) -> GSResult:


def _format_results(
results: list[GSResult] | Generator[GSResult, None, None]
results: list[GSResult] | Generator[GSResult, None, None],
) -> pd.DataFrame:
rows = []
for result in results:
Expand Down
2 changes: 1 addition & 1 deletion metalearners/rlearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def _pseudo_outcome_and_weights(
) -> tuple[np.ndarray, np.ndarray]:
"""Compute the R-Learner pseudo outcome and corresponding weights.
If `mask` is provided, the retuned pseudo outcomes and weights are only
If `mask` is provided, the returned pseudo outcomes and weights are only
with respect the observations that the mask selects.
Since the pseudo outcome is a fraction of residuals, we add a small
Expand Down
41,539 changes: 18,704 additions & 22,835 deletions pixi.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ mypy = "*"
pytest = ">=6"
pytest-cov = "*"
pytest-xdist = "*"
scikit-learn = ">=1.4"
# Remove the upper bound once this xgboost problem
# has been fixed: https://github.com/dmlc/xgboost/issues/11093
scikit-learn = ">=1.4,<1.6"
numpy = "*"
pandas = "*"
typing-extensions = "*"
Expand Down Expand Up @@ -84,7 +86,7 @@ docs-build = "mkdocs build --strict"
readthedocs = "rm -rf $READTHEDOCS_OUTPUT/html && cp -r site/ $READTHEDOCS_OUTPUT/html"

[feature.build.dependencies]
build = "*"
python-build = "*"

[feature.build.tasks]
build = "python -m build"
Expand All @@ -93,7 +95,7 @@ build = "python -m build"
platforms = ["linux-64", "osx-arm64", "osx-64"]
[feature.benchmark.dependencies]
git_root = "*"
python = "3.10"
python = "3.10.*"
scikit-learn = ">=1.3"
numpy = "*"
pandas = "*"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rlearner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) QuantCo 2024-2024
# Copyright (c) QuantCo 2024-2025
# SPDX-License-Identifier: BSD-3-Clause

from itertools import repeat
Expand Down Expand Up @@ -137,4 +137,4 @@ def test_rlearner_onnx(
["tau"],
{"X": onnx_X},
)
np.testing.assert_allclose(ml.predict(X, True, "overall"), pred_onnx, atol=5e-4)
np.testing.assert_allclose(ml.predict(X, True, "overall"), pred_onnx, atol=5e-3)

0 comments on commit 57cc3b9

Please sign in to comment.