openstef 3.4.79__py3-none-any.whl → 3.4.80__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.
@@ -4,9 +4,15 @@
4
4
  from typing import Dict, List, Optional, Tuple
5
5
 
6
6
  import pandas as pd
7
+ from pydantic import BaseModel
7
8
  from sklearn.base import BaseEstimator, TransformerMixin
8
9
 
9
10
 
11
+ class FeatureStats(BaseModel):
12
+ mean: float
13
+ std: float
14
+
15
+
10
16
  class FeatureClipper(BaseEstimator, TransformerMixin):
11
17
  """
12
18
  A transformer that clips the values of specified columns to the minimum and
@@ -14,7 +20,7 @@ class FeatureClipper(BaseEstimator, TransformerMixin):
14
20
  extrapolating beyond these values during prediction.
15
21
  """
16
22
 
17
- def __init__(self, columns: List[str]):
23
+ def __init__(self, columns: List[str], clip_number_of_std: float = 2.0):
18
24
  """
19
25
  Initialize the FeatureClipper.
20
26
 
@@ -24,7 +30,8 @@ class FeatureClipper(BaseEstimator, TransformerMixin):
24
30
  List of column names to be clipped.
25
31
  """
26
32
  self.columns: List[str] = columns
27
- self.feature_ranges: Dict[str, Tuple[float, float]] = {}
33
+ self.feature_ranges: Dict[str, Tuple[float, float] | FeatureStats] = {}
34
+ self.clip_number_of_std = clip_number_of_std
28
35
 
29
36
  def fit(self, X: pd.DataFrame, y: Optional[pd.Series] = None) -> "FeatureClipper":
30
37
  """
@@ -54,7 +61,9 @@ class FeatureClipper(BaseEstimator, TransformerMixin):
54
61
 
55
62
  for col in self.columns:
56
63
  if col in X.columns:
57
- self.feature_ranges[col] = (X[col].min(), X[col].max())
64
+ self.feature_ranges[col] = FeatureStats(
65
+ mean=X[col].mean(), std=X[col].std()
66
+ )
58
67
 
59
68
  return self
60
69
 
@@ -85,7 +94,15 @@ class FeatureClipper(BaseEstimator, TransformerMixin):
85
94
 
86
95
  for col in self.columns:
87
96
  if col in X_copy.columns and col in self.feature_ranges:
88
- min_val, max_val = self.feature_ranges[col]
89
- X_copy[col] = X_copy[col].clip(lower=min_val, upper=max_val)
97
+ if isinstance(self.feature_ranges[col], FeatureStats):
98
+ stats = self.feature_ranges[col]
99
+ X_copy[col] = X_copy[col].clip(
100
+ lower=stats.mean - self.clip_number_of_std * stats.std,
101
+ upper=stats.mean + self.clip_number_of_std * stats.std,
102
+ )
103
+ else:
104
+ # Backward compatibility with previous minmax-based implementation
105
+ min_val, max_val = self.feature_ranges[col]
106
+ X_copy[col] = X_copy[col].clip(lower=min_val, upper=max_val)
90
107
 
91
108
  return X_copy
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openstef
3
- Version: 3.4.79
3
+ Version: 3.4.80
4
4
  Summary: Open short term energy forecaster
5
5
  Home-page: https://github.com/OpenSTEF/openstef
6
6
  Author: Alliander N.V
@@ -52,7 +52,7 @@ openstef/model/objective_creator.py,sha256=3jJgcmY1sm-Yoe3SfjKrJukrsqtYyloUFaPbB
52
52
  openstef/model/serializer.py,sha256=8vESYq2TmtEzEViBR7qbJ3rjm68LZkbiET2cUPGvFMs,17925
53
53
  openstef/model/standard_deviation_generator.py,sha256=OorRvX2wRScU7f4SIBoiT24yJeeM50sETP3xC6m5IG4,2865
54
54
  openstef/model/metamodels/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
55
- openstef/model/metamodels/feature_clipper.py,sha256=DNsyYdjUT7ZNimJJIyTvv1nmwTwDUk5fX9EDgV9FbUQ,2862
55
+ openstef/model/metamodels/feature_clipper.py,sha256=moAZKC8fY3wB_k5x_imNXiS0VgwCdEj80oveVb6M1g8,3593
56
56
  openstef/model/metamodels/grouped_regressor.py,sha256=yMN_a6TnQSyFaqlB_6Nifq-ydpb5hs6w_b97IaBbHj4,8337
57
57
  openstef/model/metamodels/missing_values_handler.py,sha256=glgAlkeubLZFWbD8trTYBik7_qOJi4GCPGl1sSybSkQ,5257
58
58
  openstef/model/regressors/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
@@ -104,8 +104,8 @@ openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCt
104
104
  openstef/tasks/utils/taskcontext.py,sha256=O-LZ_wHEl5vbT8oB7EYtOeMkvk6EqCnI1-KiyER7Eu4,5407
105
105
  openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
106
106
  openstef/validation/validation.py,sha256=r6UqkdH5TMjsGfn8Ta07K1jkqmrVmwcPGfyQvMmZyO4,11459
107
- openstef-3.4.79.dist-info/licenses/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
108
- openstef-3.4.79.dist-info/METADATA,sha256=zfFVPR_RhCyKZ50LSCxuA46CI8L8d2tIJH02ryc9bUk,8834
109
- openstef-3.4.79.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
110
- openstef-3.4.79.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
111
- openstef-3.4.79.dist-info/RECORD,,
107
+ openstef-3.4.80.dist-info/licenses/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
108
+ openstef-3.4.80.dist-info/METADATA,sha256=dOp_BpkALreNj6bd4oGsF7H-m-wlFMwf0PTWsqrG1oU,8834
109
+ openstef-3.4.80.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
110
+ openstef-3.4.80.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
111
+ openstef-3.4.80.dist-info/RECORD,,