openstef 3.4.30__py3-none-any.whl → 3.4.32__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import numpy as np
7
7
  import pandas as pd
8
8
  from sklearn.impute import SimpleImputer
9
9
  from sklearn.preprocessing import FunctionTransformer
10
- from sklearn.utils.validation import check_array
10
+ from sklearn.utils.validation import check_array, check_is_fitted
11
11
 
12
12
 
13
13
  class MissingValuesTransformer:
@@ -42,6 +42,20 @@ class MissingValuesTransformer:
42
42
  self.missing_values = missing_values
43
43
  self.imputation_strategy = imputation_strategy
44
44
  self.fill_value = fill_value
45
+ self.is_fitted_ = False
46
+
47
+ # Build the proper imputation transformer
48
+ # - Identity function if strategy is None
49
+ # - SimpleImputer with the dedicated strategy
50
+ if self.imputation_strategy is None:
51
+ self.imputer_ = FunctionTransformer(func=self._identity)
52
+ else:
53
+ self.imputer_ = SimpleImputer(
54
+ missing_values=self.missing_values,
55
+ strategy=self.imputation_strategy,
56
+ fill_value=self.fill_value,
57
+ ).set_output(transform="pandas")
58
+ self.imputer_._validate_params()
45
59
 
46
60
  def fit(self, x, y=None):
47
61
  """Fit the imputer on the input data."""
@@ -56,23 +70,13 @@ class MissingValuesTransformer:
56
70
  is_column_null = x.isnull().all(axis="index")
57
71
  self.non_null_feature_names = list(x.columns[~is_column_null])
58
72
 
59
- # Build the proper imputation transformer
60
- # - Identity function if strategy is None
61
- # - SimpleImputer with the dedicated strategy
62
- if self.imputation_strategy is None:
63
- self.imputer_ = FunctionTransformer(func=self._identity)
64
- else:
65
- self.imputer_ = SimpleImputer(
66
- missing_values=self.missing_values,
67
- strategy=self.imputation_strategy,
68
- fill_value=self.fill_value,
69
- ).set_output(transform="pandas")
70
-
71
73
  # Imputers do not support labels
72
- self.imputer_.fit(X=x, y=None)
74
+ self.imputer_.fit(X=x[self.non_null_feature_names], y=None)
75
+ self.is_fitted_ = True
73
76
 
74
77
  def transform(self, x) -> pd.DataFrame:
75
78
  """Transform the input data by imputing missing values."""
79
+ check_is_fitted(self)
76
80
  _ = check_array(x, force_all_finite="allow-nan")
77
81
  if not isinstance(x, pd.DataFrame):
78
82
  x = pd.DataFrame(np.asarray(x))
@@ -231,7 +231,7 @@ class LinearQuantileOpenstfRegressor(OpenstfRegressor, RegressorMixin):
231
231
  return np.array(
232
232
  [
233
233
  reg_feature_importances_dict.get(c, 0)
234
- for c in self.imputer_.in_feature_names
234
+ for c in self.imputer_.non_null_feature_names
235
235
  ]
236
236
  )
237
237
 
@@ -1,6 +1,10 @@
1
1
  # SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project <korte.termijn.prognoses@alliander.com> # noqa E501>
2
2
  #
3
3
  # SPDX-License-Identifier: MPL-2.0
4
+ from typing import Optional
5
+
6
+ import numpy as np
7
+ from sklearn.base import RegressorMixin
4
8
 
5
9
  from xgboost import XGBRegressor
6
10
 
@@ -27,3 +31,22 @@ class XGBOpenstfRegressor(XGBRegressor, OpenstfRegressor):
27
31
  "gain_importance_name": "total_gain",
28
32
  "weight_importance_name": "weight",
29
33
  }
34
+
35
+ def fit(
36
+ self,
37
+ x: np.array,
38
+ y: np.array,
39
+ *,
40
+ early_stopping_rounds: Optional[int] = None,
41
+ callbacks: Optional[list] = None,
42
+ eval_metric: Optional[str] = None,
43
+ **kwargs
44
+ ):
45
+ if early_stopping_rounds is not None:
46
+ self.set_params(early_stopping_rounds=early_stopping_rounds)
47
+ if callbacks is not None:
48
+ self.set_params(callbacks=callbacks)
49
+ if eval_metric is not None:
50
+ self.set_params(eval_metric=eval_metric)
51
+
52
+ super().fit(x, y, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openstef
3
- Version: 3.4.30
3
+ Version: 3.4.32
4
4
  Summary: Open short term energy forecaster
5
5
  Home-page: https://github.com/OpenSTEF/openstef
6
6
  Author: Alliander N.V
@@ -31,7 +31,7 @@ Requires-Dist: pydantic-settings ~=2.3
31
31
  Requires-Dist: pymsteams ~=0.2.2
32
32
  Requires-Dist: scikit-learn ~=1.3
33
33
  Requires-Dist: scipy ~=1.10
34
- Requires-Dist: statsmodels ~=0.13.5
34
+ Requires-Dist: statsmodels <1.0.0,>=0.13.5
35
35
  Requires-Dist: structlog <25,>=23.1
36
36
  Requires-Dist: xgboost ~=2.0
37
37
 
@@ -21,7 +21,7 @@ openstef/feature_engineering/feature_applicator.py,sha256=DR7jayrEMlra4BFL1Ps5WV
21
21
  openstef/feature_engineering/general.py,sha256=tgU4_1stag9jJmaQAfWCMhfBscznVuQvW5hPK_z9_9g,4438
22
22
  openstef/feature_engineering/holiday_features.py,sha256=3Ff4Lkm26h8wJVoBplUewt4HfsvOUS9zj0x0MxewIm8,7842
23
23
  openstef/feature_engineering/lag_features.py,sha256=Dr6qS8UhdgEHPZZSe-w6ibtjl_lcbcQohhqdZN9fqEU,5652
24
- openstef/feature_engineering/missing_values_transformer.py,sha256=pKz_vRZRzfUNBw9Z-mF2AXRPeCzKbTha2gPb73bpkdw,3381
24
+ openstef/feature_engineering/missing_values_transformer.py,sha256=M5FNzpGubgAO-VoHoKpTlp6vLt6DlXt8lEYa96g7IMg,3565
25
25
  openstef/feature_engineering/weather_features.py,sha256=Lr9DItyHvJ2CpWQ1r6A83tJKtR2k_Wwn32FdFTGblO0,15750
26
26
  openstef/metrics/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
27
27
  openstef/metrics/figure.py,sha256=KDoezYem9wdS13kUx7M7FOy-4u88Sg3OX1DuhNT6kgQ,9751
@@ -46,9 +46,9 @@ openstef/model/regressors/dazls.py,sha256=Xt89yFHjkwpIUTkkhPmPZ74F8_tht_XV88INuP
46
46
  openstef/model/regressors/flatliner.py,sha256=J9p872FtobG49oMbc6mpl43TuEPt7DPSx8ZOeF6So-M,3017
47
47
  openstef/model/regressors/lgbm.py,sha256=zCdn1euEdSFxYJzH8XqQFFnb6R4JVUnmineKjX_Gy-g,800
48
48
  openstef/model/regressors/linear.py,sha256=uOvZMLGZH_9nXfmS5honCMfyVeyGXP1Cza9A_BdXlVw,3665
49
- openstef/model/regressors/linear_quantile.py,sha256=N-cia8aba39Th6BzOdtcESLuxhY9YtSGaOYIc6STgag,7830
49
+ openstef/model/regressors/linear_quantile.py,sha256=oYr5scc1k9wInPD0v6JBe1VgtsEKQycNvEzX5BWHaN0,7836
50
50
  openstef/model/regressors/regressor.py,sha256=uJcx59AyCPE9f_yPcAQ59h2ZS7eNsDpIHJrladKvHIw,3461
51
- openstef/model/regressors/xgb.py,sha256=HggA1U10srzdysjV560BMMX66kfaxCKAnOZB3JyyT_Y,808
51
+ openstef/model/regressors/xgb.py,sha256=SH-UiYJtMbfmRBK6738dU0ZRfYfzNynnikwbxINCE7Q,1467
52
52
  openstef/model/regressors/xgb_multioutput_quantile.py,sha256=xWzA7tymC_o-F1OS3I7vUKf9zP6RR1ZglEeY4NAgjU0,9146
53
53
  openstef/model/regressors/xgb_quantile.py,sha256=PzKIxqN_CnEPFmzXACNuzLSmZSHbooTuiJ5ckJ9vh_E,7805
54
54
  openstef/model_selection/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
@@ -84,8 +84,8 @@ openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCt
84
84
  openstef/tasks/utils/taskcontext.py,sha256=L9K14ycwgVxbIVUjH2DIn_QWbnu-OfxcGtQ1K9T6sus,5630
85
85
  openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
86
86
  openstef/validation/validation.py,sha256=628xaDbAm8B4AYtFOAn8_SXLjejNfULGCfX3hVf_mU0,11119
87
- openstef-3.4.30.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
88
- openstef-3.4.30.dist-info/METADATA,sha256=qL32qVnXP9ZMeTVBXPNWv0y94_SlY_Cbtir0eqek7yw,7392
89
- openstef-3.4.30.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
90
- openstef-3.4.30.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
91
- openstef-3.4.30.dist-info/RECORD,,
87
+ openstef-3.4.32.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
88
+ openstef-3.4.32.dist-info/METADATA,sha256=rRgKlS3ItbiQ1xkQwJGlgQ_oTq32dCxQY6HZzBFLF4A,7399
89
+ openstef-3.4.32.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
90
+ openstef-3.4.32.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
91
+ openstef-3.4.32.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.0)
2
+ Generator: setuptools (70.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5