Skip to content

Commit bf87e38

Browse files
committed
Merge branch 'main' into 0.8.X
2 parents db1a0ec + a0d21e4 commit bf87e38

File tree

7 files changed

+19
-34
lines changed

7 files changed

+19
-34
lines changed

.github/workflows/deploy_pkg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Install python
2020
uses: actions/setup-python@v5
2121
with:
22-
python-version: '3.8'
22+
python-version: '3.9'
2323

2424
- name: Install dependencies
2525
run: |

.github/workflows/pytest.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
strategy:
2323
matrix:
2424
config:
25-
- {os: 'ubuntu-latest', python-version: '3.8'}
26-
- {os: 'windows-latest', python-version: '3.8'}
27-
- {os: 'macOS-latest', python-version: '3.8'}
2825
- {os: 'ubuntu-latest', python-version: '3.9'}
26+
- {os: 'windows-latest', python-version: '3.9'}
27+
- {os: 'macOS-latest', python-version: '3.9'}
2928
- {os: 'ubuntu-latest', python-version: '3.10'}
3029
- {os: 'ubuntu-latest', python-version: '3.11'}
30+
- {os: 'ubuntu-latest', python-version: '3.12'}
3131

3232
steps:
3333
- uses: actions/checkout@v4
@@ -63,15 +63,15 @@ jobs:
6363
- name: Test with pytest and coverage
6464
if: |
6565
matrix.config.os == 'ubuntu-latest' &&
66-
matrix.config.python-version == '3.8'
66+
matrix.config.python-version == '3.9'
6767
run: |
6868
pip install pytest-cov
6969
pytest --cov=./ --cov-report=xml
7070
7171
- name: Upload coverage to Codecov
7272
if: |
7373
matrix.config.os == 'ubuntu-latest' &&
74-
matrix.config.python-version == '3.8'
74+
matrix.config.python-version == '3.9'
7575
uses: codecov/codecov-action@v3
7676
with:
7777
file: ./coverage.xml
@@ -80,7 +80,7 @@ jobs:
8080
- name: Upload coverage to codacy
8181
if: |
8282
matrix.config.os == 'ubuntu-latest' &&
83-
matrix.config.python-version == '3.8'
83+
matrix.config.python-version == '3.9'
8484
uses: codacy/codacy-coverage-reporter-action@v1
8585
with:
8686
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}

doubleml/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pkg_resources import get_distribution
1+
import importlib.metadata
22

33
from .double_ml_framework import concat
44
from .double_ml_framework import DoubleMLFramework
@@ -36,4 +36,4 @@
3636
'DoubleMLPolicyTree',
3737
'DoubleMLSSM']
3838

39-
__version__ = get_distribution('doubleml').version
39+
__version__ = importlib.metadata.version('doubleml')

doubleml/datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ def fetch_bonus(return_type='DoubleMLData', polynomial_features=False):
8181
doi:`10.1111/ectj.12097 <https://doi.org/10.1111/ectj.12097>`_.
8282
"""
8383
url = 'https://raw.githubusercontent.com/VC2015/DMLonGitHub/master/penn_jae.dat'
84-
raw_data = pd.read_csv(url, delim_whitespace=True)
84+
raw_data = pd.read_csv(url, sep='\s+')
8585

8686
ind = (raw_data['tg'] == 0) | (raw_data['tg'] == 4)
8787
data = raw_data.copy()[ind]
8888
data.reset_index(inplace=True)
89-
data['tg'].replace(4, 1, inplace=True)
89+
data['tg'] = data['tg'].replace(4, 1)
9090
data['inuidur1'] = np.log(data['inuidur1'])
9191

9292
# variable dep as factor (dummy encoding)

doubleml/tests/_utils_dml_cv_predict.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@
88
from sklearn.preprocessing import LabelEncoder
99
from sklearn.model_selection._validation import _fit_and_predict, _check_is_permutation
1010

11-
# Adapt _fit_and_predict for earlier sklearn versions
12-
from distutils.version import LooseVersion
13-
from sklearn import __version__ as sklearn_version
14-
15-
if LooseVersion(sklearn_version) < LooseVersion("1.4.0"):
16-
def _fit_and_predict_adapted(estimator, x, y, train, test, fit_params, method):
17-
res = _fit_and_predict(estimator, x, y, train, test,
18-
verbose=0,
19-
fit_params=fit_params,
20-
method=method)
21-
return res
22-
else:
23-
def _fit_and_predict_adapted(estimator, x, y, train, test, fit_params, method):
24-
return _fit_and_predict(estimator, x, y, train, test, fit_params, method)
25-
2611

2712
def _dml_cv_predict_ut_version(estimator, x, y, smpls=None,
2813
n_jobs=None, est_params=None, method='predict'):
@@ -42,12 +27,12 @@ def _dml_cv_predict_ut_version(estimator, x, y, smpls=None,
4227
else:
4328
predictions = np.full(len(y), np.nan)
4429
if est_params is None:
45-
xx = _fit_and_predict_adapted(
30+
xx = _fit_and_predict(
4631
clone(estimator),
4732
x, y, train_index, test_index, fit_params, method)
4833
else:
4934
assert isinstance(est_params, dict)
50-
xx = _fit_and_predict_adapted(
35+
xx = _fit_and_predict(
5136
clone(estimator).set_params(**est_params),
5237
x, y, train_index, test_index, fit_params, method)
5338

@@ -77,20 +62,20 @@ def _dml_cv_predict_ut_version(estimator, x, y, smpls=None,
7762
pre_dispatch=pre_dispatch)
7863
# FixMe: Find a better way to handle the different combinations of paramters and smpls_is_partition
7964
if est_params is None:
80-
prediction_blocks = parallel(delayed(_fit_and_predict_adapted)(
65+
prediction_blocks = parallel(delayed(_fit_and_predict)(
8166
estimator,
8267
x, y, train_index, test_index, fit_params, method)
8368
for idx, (train_index, test_index) in enumerate(smpls))
8469
elif isinstance(est_params, dict):
8570
# if no fold-specific parameters we redirect to the standard method
8671
# warnings.warn("Using the same (hyper-)parameters for all folds")
87-
prediction_blocks = parallel(delayed(_fit_and_predict_adapted)(
72+
prediction_blocks = parallel(delayed(_fit_and_predict)(
8873
clone(estimator).set_params(**est_params),
8974
x, y, train_index, test_index, fit_params, method)
9075
for idx, (train_index, test_index) in enumerate(smpls))
9176
else:
9277
assert len(est_params) == len(smpls), 'provide one parameter setting per fold'
93-
prediction_blocks = parallel(delayed(_fit_and_predict_adapted)(
78+
prediction_blocks = parallel(delayed(_fit_and_predict)(
9479
clone(estimator).set_params(**est_params[idx]),
9580
x, y, train_index, test_index, fit_params, method)
9681
for idx, (train_index, test_index) in enumerate(smpls))

doubleml/utils/_estimation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from sklearn.base import clone
77
from sklearn.preprocessing import LabelEncoder
88
from sklearn.model_selection import KFold, GridSearchCV, RandomizedSearchCV
9-
from sklearn.metrics import mean_squared_error
9+
from sklearn.metrics import root_mean_squared_error
1010

1111
from statsmodels.nonparametric.kde import KDEUnivariate
1212

@@ -200,7 +200,7 @@ def _normalize_ipw(propensity, treatment):
200200

201201
def _rmse(y_true, y_pred):
202202
subset = np.logical_not(np.isnan(y_true))
203-
rmse = mean_squared_error(y_true[subset], y_pred[subset], squared=False)
203+
rmse = root_mean_squared_error(y_true[subset], y_pred[subset])
204204
return rmse
205205

206206

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name='DoubleML',
14-
version='0.8.0',
14+
version='0.8.1',
1515
author='Bach, P., Chernozhukov, V., Kurz, M. S., and Spindler, M.',
1616
maintainer='Malte S. Kurz',
1717
maintainer_email='malte.simon.kurz@uni-hamburg.de',

0 commit comments

Comments
 (0)